documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1054. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1055. */
  1056. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1057. /**
  1058. * Constant used to retrieve the position texture index in the textures array in the prepass
  1059. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1060. */
  1061. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1062. /**
  1063. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1065. */
  1066. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1069. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1070. */
  1071. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1074. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1075. */
  1076. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve albedo index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * This represents the required contract to create a new type of texture loader.
  1092. */
  1093. export interface IInternalTextureLoader {
  1094. /**
  1095. * Defines wether the loader supports cascade loading the different faces.
  1096. */
  1097. supportCascades: boolean;
  1098. /**
  1099. * This returns if the loader support the current file information.
  1100. * @param extension defines the file extension of the file being loaded
  1101. * @param mimeType defines the optional mime type of the file being loaded
  1102. * @returns true if the loader can load the specified file
  1103. */
  1104. canLoad(extension: string, mimeType?: string): boolean;
  1105. /**
  1106. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1107. * @param data contains the texture data
  1108. * @param texture defines the BabylonJS internal texture
  1109. * @param createPolynomials will be true if polynomials have been requested
  1110. * @param onLoad defines the callback to trigger once the texture is ready
  1111. * @param onError defines the callback to trigger in case of error
  1112. */
  1113. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1114. /**
  1115. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1116. * @param data contains the texture data
  1117. * @param texture defines the BabylonJS internal texture
  1118. * @param callback defines the method to call once ready to upload
  1119. */
  1120. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /**
  1125. * Class used to store and describe the pipeline context associated with an effect
  1126. */
  1127. export interface IPipelineContext {
  1128. /**
  1129. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1130. */
  1131. isAsync: boolean;
  1132. /**
  1133. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1134. */
  1135. isReady: boolean;
  1136. /** @hidden */
  1137. _getVertexShaderCode(): string | null;
  1138. /** @hidden */
  1139. _getFragmentShaderCode(): string | null;
  1140. /** @hidden */
  1141. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1142. }
  1143. }
  1144. declare module BABYLON {
  1145. /**
  1146. * Class used to store gfx data (like WebGLBuffer)
  1147. */
  1148. export class DataBuffer {
  1149. /**
  1150. * Gets or sets the number of objects referencing this buffer
  1151. */
  1152. references: number;
  1153. /** Gets or sets the size of the underlying buffer */
  1154. capacity: number;
  1155. /**
  1156. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1157. */
  1158. is32Bits: boolean;
  1159. /**
  1160. * Gets the underlying buffer
  1161. */
  1162. get underlyingResource(): any;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export interface IShaderProcessor {
  1168. attributeProcessor?: (attribute: string) => string;
  1169. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1170. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1171. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1172. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1173. lineProcessor?: (line: string, isFragment: boolean) => string;
  1174. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1175. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1176. }
  1177. }
  1178. declare module BABYLON {
  1179. /** @hidden */
  1180. export interface ProcessingOptions {
  1181. defines: string[];
  1182. indexParameters: any;
  1183. isFragment: boolean;
  1184. shouldUseHighPrecisionShader: boolean;
  1185. supportsUniformBuffers: boolean;
  1186. shadersRepository: string;
  1187. includesShadersStore: {
  1188. [key: string]: string;
  1189. };
  1190. processor?: IShaderProcessor;
  1191. version: string;
  1192. platformName: string;
  1193. lookForClosingBracketForUniformBuffer?: boolean;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderCodeNode {
  1199. line: string;
  1200. children: ShaderCodeNode[];
  1201. additionalDefineKey?: string;
  1202. additionalDefineValue?: string;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. process(preprocessors: {
  1207. [key: string]: string;
  1208. }, options: ProcessingOptions): string;
  1209. }
  1210. }
  1211. declare module BABYLON {
  1212. /** @hidden */
  1213. export class ShaderCodeCursor {
  1214. private _lines;
  1215. lineIndex: number;
  1216. get currentLine(): string;
  1217. get canRead(): boolean;
  1218. set lines(value: string[]);
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineExpression {
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. private static _OperatorPriority;
  1236. private static _Stack;
  1237. static postfixToInfix(postfix: string[]): string;
  1238. static infixToPostfix(infix: string): string[];
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderCodeTestNode extends ShaderCodeNode {
  1244. testExpression: ShaderDefineExpression;
  1245. isValid(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module BABYLON {
  1251. /** @hidden */
  1252. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1253. define: string;
  1254. not: boolean;
  1255. constructor(define: string, not?: boolean);
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module BABYLON {
  1262. /** @hidden */
  1263. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1264. leftOperand: ShaderDefineExpression;
  1265. rightOperand: ShaderDefineExpression;
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1284. define: string;
  1285. operand: string;
  1286. testValue: string;
  1287. constructor(define: string, operand: string, testValue: string);
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /**
  1295. * Class used to enable access to offline support
  1296. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1297. */
  1298. export interface IOfflineProvider {
  1299. /**
  1300. * Gets a boolean indicating if scene must be saved in the database
  1301. */
  1302. enableSceneOffline: boolean;
  1303. /**
  1304. * Gets a boolean indicating if textures must be saved in the database
  1305. */
  1306. enableTexturesOffline: boolean;
  1307. /**
  1308. * Open the offline support and make it available
  1309. * @param successCallback defines the callback to call on success
  1310. * @param errorCallback defines the callback to call on error
  1311. */
  1312. open(successCallback: () => void, errorCallback: () => void): void;
  1313. /**
  1314. * Loads an image from the offline support
  1315. * @param url defines the url to load from
  1316. * @param image defines the target DOM image
  1317. */
  1318. loadImage(url: string, image: HTMLImageElement): void;
  1319. /**
  1320. * Loads a file from offline support
  1321. * @param url defines the URL to load from
  1322. * @param sceneLoaded defines a callback to call on success
  1323. * @param progressCallBack defines a callback to call when progress changed
  1324. * @param errorCallback defines a callback to call on error
  1325. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1326. */
  1327. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1328. }
  1329. }
  1330. declare module BABYLON {
  1331. /**
  1332. * Class used to help managing file picking and drag'n'drop
  1333. * File Storage
  1334. */
  1335. export class FilesInputStore {
  1336. /**
  1337. * List of files ready to be loaded
  1338. */
  1339. static FilesToLoad: {
  1340. [key: string]: File;
  1341. };
  1342. }
  1343. }
  1344. declare module BABYLON {
  1345. /**
  1346. * Class used to define a retry strategy when error happens while loading assets
  1347. */
  1348. export class RetryStrategy {
  1349. /**
  1350. * Function used to defines an exponential back off strategy
  1351. * @param maxRetries defines the maximum number of retries (3 by default)
  1352. * @param baseInterval defines the interval between retries
  1353. * @returns the strategy function to use
  1354. */
  1355. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1356. }
  1357. }
  1358. declare module BABYLON {
  1359. /**
  1360. * @ignore
  1361. * Application error to support additional information when loading a file
  1362. */
  1363. export abstract class BaseError extends Error {
  1364. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1365. }
  1366. }
  1367. declare module BABYLON {
  1368. /** @ignore */
  1369. export class LoadFileError extends BaseError {
  1370. request?: WebRequest;
  1371. file?: File;
  1372. /**
  1373. * Creates a new LoadFileError
  1374. * @param message defines the message of the error
  1375. * @param request defines the optional web request
  1376. * @param file defines the optional file
  1377. */
  1378. constructor(message: string, object?: WebRequest | File);
  1379. }
  1380. /** @ignore */
  1381. export class RequestFileError extends BaseError {
  1382. request: WebRequest;
  1383. /**
  1384. * Creates a new LoadFileError
  1385. * @param message defines the message of the error
  1386. * @param request defines the optional web request
  1387. */
  1388. constructor(message: string, request: WebRequest);
  1389. }
  1390. /** @ignore */
  1391. export class ReadFileError extends BaseError {
  1392. file: File;
  1393. /**
  1394. * Creates a new ReadFileError
  1395. * @param message defines the message of the error
  1396. * @param file defines the optional file
  1397. */
  1398. constructor(message: string, file: File);
  1399. }
  1400. /**
  1401. * @hidden
  1402. */
  1403. export class FileTools {
  1404. /**
  1405. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1406. */
  1407. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1408. /**
  1409. * Gets or sets the base URL to use to load assets
  1410. */
  1411. static BaseUrl: string;
  1412. /**
  1413. * Default behaviour for cors in the application.
  1414. * It can be a string if the expected behavior is identical in the entire app.
  1415. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1416. */
  1417. static CorsBehavior: string | ((url: string | string[]) => string);
  1418. /**
  1419. * Gets or sets a function used to pre-process url before using them to load assets
  1420. */
  1421. static PreprocessUrl: (url: string) => string;
  1422. /**
  1423. * Removes unwanted characters from an url
  1424. * @param url defines the url to clean
  1425. * @returns the cleaned url
  1426. */
  1427. private static _CleanUrl;
  1428. /**
  1429. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1430. * @param url define the url we are trying
  1431. * @param element define the dom element where to configure the cors policy
  1432. */
  1433. static SetCorsBehavior(url: string | string[], element: {
  1434. crossOrigin: string | null;
  1435. }): void;
  1436. /**
  1437. * Loads an image as an HTMLImageElement.
  1438. * @param input url string, ArrayBuffer, or Blob to load
  1439. * @param onLoad callback called when the image successfully loads
  1440. * @param onError callback called when the image fails to load
  1441. * @param offlineProvider offline provider for caching
  1442. * @param mimeType optional mime type
  1443. * @returns the HTMLImageElement of the loaded image
  1444. */
  1445. 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>;
  1446. /**
  1447. * Reads a file from a File object
  1448. * @param file defines the file to load
  1449. * @param onSuccess defines the callback to call when data is loaded
  1450. * @param onProgress defines the callback to call during loading process
  1451. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1452. * @param onError defines the callback to call when an error occurs
  1453. * @returns a file request object
  1454. */
  1455. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1456. /**
  1457. * Loads a file from a url
  1458. * @param url url to load
  1459. * @param onSuccess callback called when the file successfully loads
  1460. * @param onProgress callback called while file is loading (if the server supports this mode)
  1461. * @param offlineProvider defines the offline provider for caching
  1462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1463. * @param onError callback called when the file fails to load
  1464. * @returns a file request object
  1465. */
  1466. 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;
  1467. /**
  1468. * Loads a file
  1469. * @param url url to load
  1470. * @param onSuccess callback called when the file successfully loads
  1471. * @param onProgress callback called while file is loading (if the server supports this mode)
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @param onOpened callback called when the web request is opened
  1475. * @returns a file request object
  1476. */
  1477. 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;
  1478. /**
  1479. * Checks if the loaded document was accessed via `file:`-Protocol.
  1480. * @returns boolean
  1481. */
  1482. static IsFileURL(): boolean;
  1483. }
  1484. }
  1485. declare module BABYLON {
  1486. /** @hidden */
  1487. export class ShaderProcessor {
  1488. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1489. private static _ProcessPrecision;
  1490. private static _ExtractOperation;
  1491. private static _BuildSubExpression;
  1492. private static _BuildExpression;
  1493. private static _MoveCursorWithinIf;
  1494. private static _MoveCursor;
  1495. private static _EvaluatePreProcessors;
  1496. private static _PreparePreProcessors;
  1497. private static _ProcessShaderConversion;
  1498. private static _ProcessIncludes;
  1499. /**
  1500. * Loads a file from a url
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param offlineProvider defines the offline provider for caching
  1505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1506. * @param onError callback called when the file fails to load
  1507. * @returns a file request object
  1508. * @hidden
  1509. */
  1510. 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;
  1511. }
  1512. }
  1513. declare module BABYLON {
  1514. /**
  1515. * @hidden
  1516. */
  1517. export interface IColor4Like {
  1518. r: float;
  1519. g: float;
  1520. b: float;
  1521. a: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor3Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. }
  1531. /**
  1532. * @hidden
  1533. */
  1534. export interface IVector4Like {
  1535. x: float;
  1536. y: float;
  1537. z: float;
  1538. w: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector3Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IVector2Like {
  1552. x: float;
  1553. y: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IMatrixLike {
  1559. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1560. updateFlag: int;
  1561. }
  1562. /**
  1563. * @hidden
  1564. */
  1565. export interface IViewportLike {
  1566. x: float;
  1567. y: float;
  1568. width: float;
  1569. height: float;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IPlaneLike {
  1575. normal: IVector3Like;
  1576. d: float;
  1577. normalize(): void;
  1578. }
  1579. }
  1580. declare module BABYLON {
  1581. /**
  1582. * Interface used to define common properties for effect fallbacks
  1583. */
  1584. export interface IEffectFallbacks {
  1585. /**
  1586. * Removes the defines that should be removed when falling back.
  1587. * @param currentDefines defines the current define statements for the shader.
  1588. * @param effect defines the current effect we try to compile
  1589. * @returns The resulting defines with defines of the current rank removed.
  1590. */
  1591. reduce(currentDefines: string, effect: Effect): string;
  1592. /**
  1593. * Removes the fallback from the bound mesh.
  1594. */
  1595. unBindMesh(): void;
  1596. /**
  1597. * Checks to see if more fallbacks are still availible.
  1598. */
  1599. hasMoreFallbacks: boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /**
  1604. * Class used to evalaute queries containing `and` and `or` operators
  1605. */
  1606. export class AndOrNotEvaluator {
  1607. /**
  1608. * Evaluate a query
  1609. * @param query defines the query to evaluate
  1610. * @param evaluateCallback defines the callback used to filter result
  1611. * @returns true if the query matches
  1612. */
  1613. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1614. private static _HandleParenthesisContent;
  1615. private static _SimplifyNegation;
  1616. }
  1617. }
  1618. declare module BABYLON {
  1619. /**
  1620. * Class used to store custom tags
  1621. */
  1622. export class Tags {
  1623. /**
  1624. * Adds support for tags on the given object
  1625. * @param obj defines the object to use
  1626. */
  1627. static EnableFor(obj: any): void;
  1628. /**
  1629. * Removes tags support
  1630. * @param obj defines the object to use
  1631. */
  1632. static DisableFor(obj: any): void;
  1633. /**
  1634. * Gets a boolean indicating if the given object has tags
  1635. * @param obj defines the object to use
  1636. * @returns a boolean
  1637. */
  1638. static HasTags(obj: any): boolean;
  1639. /**
  1640. * Gets the tags available on a given object
  1641. * @param obj defines the object to use
  1642. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1643. * @returns the tags
  1644. */
  1645. static GetTags(obj: any, asString?: boolean): any;
  1646. /**
  1647. * Adds tags to an object
  1648. * @param obj defines the object to use
  1649. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1650. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1651. */
  1652. static AddTagsTo(obj: any, tagsString: string): void;
  1653. /**
  1654. * @hidden
  1655. */
  1656. static _AddTagTo(obj: any, tag: string): void;
  1657. /**
  1658. * Removes specific tags from a specific object
  1659. * @param obj defines the object to use
  1660. * @param tagsString defines the tags to remove
  1661. */
  1662. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _RemoveTagFrom(obj: any, tag: string): void;
  1667. /**
  1668. * Defines if tags hosted on an object match a given query
  1669. * @param obj defines the object to use
  1670. * @param tagsQuery defines the tag query
  1671. * @returns a boolean
  1672. */
  1673. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1674. }
  1675. }
  1676. declare module BABYLON {
  1677. /**
  1678. * Scalar computation library
  1679. */
  1680. export class Scalar {
  1681. /**
  1682. * Two pi constants convenient for computation.
  1683. */
  1684. static TwoPi: number;
  1685. /**
  1686. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1687. * @param a number
  1688. * @param b number
  1689. * @param epsilon (default = 1.401298E-45)
  1690. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1691. */
  1692. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1693. /**
  1694. * Returns a string : the upper case translation of the number i to hexadecimal.
  1695. * @param i number
  1696. * @returns the upper case translation of the number i to hexadecimal.
  1697. */
  1698. static ToHex(i: number): string;
  1699. /**
  1700. * Returns -1 if value is negative and +1 is value is positive.
  1701. * @param value the value
  1702. * @returns the value itself if it's equal to zero.
  1703. */
  1704. static Sign(value: number): number;
  1705. /**
  1706. * Returns the value itself if it's between min and max.
  1707. * Returns min if the value is lower than min.
  1708. * Returns max if the value is greater than max.
  1709. * @param value the value to clmap
  1710. * @param min the min value to clamp to (default: 0)
  1711. * @param max the max value to clamp to (default: 1)
  1712. * @returns the clamped value
  1713. */
  1714. static Clamp(value: number, min?: number, max?: number): number;
  1715. /**
  1716. * the log2 of value.
  1717. * @param value the value to compute log2 of
  1718. * @returns the log2 of value.
  1719. */
  1720. static Log2(value: number): number;
  1721. /**
  1722. * Loops the value, so that it is never larger than length and never smaller than 0.
  1723. *
  1724. * This is similar to the modulo operator but it works with floating point numbers.
  1725. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1726. * With t = 5 and length = 2.5, the result would be 0.0.
  1727. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1728. * @param value the value
  1729. * @param length the length
  1730. * @returns the looped value
  1731. */
  1732. static Repeat(value: number, length: number): number;
  1733. /**
  1734. * Normalize the value between 0.0 and 1.0 using min and max values
  1735. * @param value value to normalize
  1736. * @param min max to normalize between
  1737. * @param max min to normalize between
  1738. * @returns the normalized value
  1739. */
  1740. static Normalize(value: number, min: number, max: number): number;
  1741. /**
  1742. * Denormalize the value from 0.0 and 1.0 using min and max values
  1743. * @param normalized value to denormalize
  1744. * @param min max to denormalize between
  1745. * @param max min to denormalize between
  1746. * @returns the denormalized value
  1747. */
  1748. static Denormalize(normalized: number, min: number, max: number): number;
  1749. /**
  1750. * Calculates the shortest difference between two given angles given in degrees.
  1751. * @param current current angle in degrees
  1752. * @param target target angle in degrees
  1753. * @returns the delta
  1754. */
  1755. static DeltaAngle(current: number, target: number): number;
  1756. /**
  1757. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1758. * @param tx value
  1759. * @param length length
  1760. * @returns The returned value will move back and forth between 0 and length
  1761. */
  1762. static PingPong(tx: number, length: number): number;
  1763. /**
  1764. * Interpolates between min and max with smoothing at the limits.
  1765. *
  1766. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1767. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1768. * @param from from
  1769. * @param to to
  1770. * @param tx value
  1771. * @returns the smooth stepped value
  1772. */
  1773. static SmoothStep(from: number, to: number, tx: number): number;
  1774. /**
  1775. * Moves a value current towards target.
  1776. *
  1777. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1778. * Negative values of maxDelta pushes the value away from target.
  1779. * @param current current value
  1780. * @param target target value
  1781. * @param maxDelta max distance to move
  1782. * @returns resulting value
  1783. */
  1784. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1785. /**
  1786. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. *
  1788. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1789. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1790. * @param current current value
  1791. * @param target target value
  1792. * @param maxDelta max distance to move
  1793. * @returns resulting angle
  1794. */
  1795. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1796. /**
  1797. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1798. * @param start start value
  1799. * @param end target value
  1800. * @param amount amount to lerp between
  1801. * @returns the lerped value
  1802. */
  1803. static Lerp(start: number, end: number, amount: number): number;
  1804. /**
  1805. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1806. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1807. * @param start start value
  1808. * @param end target value
  1809. * @param amount amount to lerp between
  1810. * @returns the lerped value
  1811. */
  1812. static LerpAngle(start: number, end: number, amount: number): number;
  1813. /**
  1814. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1815. * @param a start value
  1816. * @param b target value
  1817. * @param value value between a and b
  1818. * @returns the inverseLerp value
  1819. */
  1820. static InverseLerp(a: number, b: number, value: number): number;
  1821. /**
  1822. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1823. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1824. * @param value1 spline value
  1825. * @param tangent1 spline value
  1826. * @param value2 spline value
  1827. * @param tangent2 spline value
  1828. * @param amount input value
  1829. * @returns hermite result
  1830. */
  1831. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1832. /**
  1833. * Returns a random float number between and min and max values
  1834. * @param min min value of random
  1835. * @param max max value of random
  1836. * @returns random value
  1837. */
  1838. static RandomRange(min: number, max: number): number;
  1839. /**
  1840. * This function returns percentage of a number in a given range.
  1841. *
  1842. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1843. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1844. * @param number to convert to percentage
  1845. * @param min min range
  1846. * @param max max range
  1847. * @returns the percentage
  1848. */
  1849. static RangeToPercent(number: number, min: number, max: number): number;
  1850. /**
  1851. * This function returns number that corresponds to the percentage in a given range.
  1852. *
  1853. * PercentToRange(0.34,0,100) will return 34.
  1854. * @param percent to convert to number
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the number
  1858. */
  1859. static PercentToRange(percent: number, min: number, max: number): number;
  1860. /**
  1861. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1862. * @param angle The angle to normalize in radian.
  1863. * @return The converted angle.
  1864. */
  1865. static NormalizeRadians(angle: number): number;
  1866. }
  1867. }
  1868. declare module BABYLON {
  1869. /**
  1870. * Constant used to convert a value to gamma space
  1871. * @ignorenaming
  1872. */
  1873. export const ToGammaSpace: number;
  1874. /**
  1875. * Constant used to convert a value to linear space
  1876. * @ignorenaming
  1877. */
  1878. export const ToLinearSpace = 2.2;
  1879. /**
  1880. * Constant used to define the minimal number value in Babylon.js
  1881. * @ignorenaming
  1882. */
  1883. let Epsilon: number;
  1884. }
  1885. declare module BABYLON {
  1886. /**
  1887. * Class used to represent a viewport on screen
  1888. */
  1889. export class Viewport {
  1890. /** viewport left coordinate */
  1891. x: number;
  1892. /** viewport top coordinate */
  1893. y: number;
  1894. /**viewport width */
  1895. width: number;
  1896. /** viewport height */
  1897. height: number;
  1898. /**
  1899. * Creates a Viewport object located at (x, y) and sized (width, height)
  1900. * @param x defines viewport left coordinate
  1901. * @param y defines viewport top coordinate
  1902. * @param width defines the viewport width
  1903. * @param height defines the viewport height
  1904. */
  1905. constructor(
  1906. /** viewport left coordinate */
  1907. x: number,
  1908. /** viewport top coordinate */
  1909. y: number,
  1910. /**viewport width */
  1911. width: number,
  1912. /** viewport height */
  1913. height: number);
  1914. /**
  1915. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1916. * @param renderWidth defines the rendering width
  1917. * @param renderHeight defines the rendering height
  1918. * @returns a new Viewport
  1919. */
  1920. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1921. /**
  1922. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1923. * @param renderWidth defines the rendering width
  1924. * @param renderHeight defines the rendering height
  1925. * @param ref defines the target viewport
  1926. * @returns the current viewport
  1927. */
  1928. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1929. /**
  1930. * Returns a new Viewport copied from the current one
  1931. * @returns a new Viewport
  1932. */
  1933. clone(): Viewport;
  1934. }
  1935. }
  1936. declare module BABYLON {
  1937. /**
  1938. * Class containing a set of static utilities functions for arrays.
  1939. */
  1940. export class ArrayTools {
  1941. /**
  1942. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1943. * @param size the number of element to construct and put in the array
  1944. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1945. * @returns a new array filled with new objects
  1946. */
  1947. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1948. }
  1949. }
  1950. declare module BABYLON {
  1951. /**
  1952. * Represents a plane by the equation ax + by + cz + d = 0
  1953. */
  1954. export class Plane {
  1955. private static _TmpMatrix;
  1956. /**
  1957. * Normal of the plane (a,b,c)
  1958. */
  1959. normal: Vector3;
  1960. /**
  1961. * d component of the plane
  1962. */
  1963. d: number;
  1964. /**
  1965. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1966. * @param a a component of the plane
  1967. * @param b b component of the plane
  1968. * @param c c component of the plane
  1969. * @param d d component of the plane
  1970. */
  1971. constructor(a: number, b: number, c: number, d: number);
  1972. /**
  1973. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * @returns a new plane copied from the current Plane.
  1978. */
  1979. clone(): Plane;
  1980. /**
  1981. * @returns the string "Plane".
  1982. */
  1983. getClassName(): string;
  1984. /**
  1985. * @returns the Plane hash code.
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Normalize the current Plane in place.
  1990. * @returns the updated Plane.
  1991. */
  1992. normalize(): Plane;
  1993. /**
  1994. * Applies a transformation the plane and returns the result
  1995. * @param transformation the transformation matrix to be applied to the plane
  1996. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1997. */
  1998. transform(transformation: DeepImmutable<Matrix>): Plane;
  1999. /**
  2000. * Compute the dot product between the point and the plane normal
  2001. * @param point point to calculate the dot product with
  2002. * @returns the dot product (float) of the point coordinates and the plane normal.
  2003. */
  2004. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2005. /**
  2006. * Updates the current Plane from the plane defined by the three given points.
  2007. * @param point1 one of the points used to contruct the plane
  2008. * @param point2 one of the points used to contruct the plane
  2009. * @param point3 one of the points used to contruct the plane
  2010. * @returns the updated Plane.
  2011. */
  2012. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2013. /**
  2014. * Checks if the plane is facing a given direction
  2015. * @param direction the direction to check if the plane is facing
  2016. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2017. * @returns True is the vector "direction" is the same side than the plane normal.
  2018. */
  2019. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2020. /**
  2021. * Calculates the distance to a point
  2022. * @param point point to calculate distance to
  2023. * @returns the signed distance (float) from the given point to the Plane.
  2024. */
  2025. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2026. /**
  2027. * Creates a plane from an array
  2028. * @param array the array to create a plane from
  2029. * @returns a new Plane from the given array.
  2030. */
  2031. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2032. /**
  2033. * Creates a plane from three points
  2034. * @param point1 point used to create the plane
  2035. * @param point2 point used to create the plane
  2036. * @param point3 point used to create the plane
  2037. * @returns a new Plane defined by the three given points.
  2038. */
  2039. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2040. /**
  2041. * Creates a plane from an origin point and a normal
  2042. * @param origin origin of the plane to be constructed
  2043. * @param normal normal of the plane to be constructed
  2044. * @returns a new Plane the normal vector to this plane at the given origin point.
  2045. * Note : the vector "normal" is updated because normalized.
  2046. */
  2047. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2048. /**
  2049. * Calculates the distance from a plane and a point
  2050. * @param origin origin of the plane to be constructed
  2051. * @param normal normal of the plane to be constructed
  2052. * @param point point to calculate distance to
  2053. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2054. */
  2055. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2056. }
  2057. }
  2058. declare module BABYLON {
  2059. /** @hidden */
  2060. export class PerformanceConfigurator {
  2061. /** @hidden */
  2062. static MatrixUse64Bits: boolean;
  2063. /** @hidden */
  2064. static MatrixTrackPrecisionChange: boolean;
  2065. /** @hidden */
  2066. static MatrixCurrentType: any;
  2067. /** @hidden */
  2068. static MatrixTrackedMatrices: Array<any> | null;
  2069. /** @hidden */
  2070. static SetMatrixPrecision(use64bits: boolean): void;
  2071. }
  2072. }
  2073. declare module BABYLON {
  2074. /**
  2075. * Class representing a vector containing 2 coordinates
  2076. */
  2077. export class Vector2 {
  2078. /** defines the first coordinate */
  2079. x: number;
  2080. /** defines the second coordinate */
  2081. y: number;
  2082. /**
  2083. * Creates a new Vector2 from the given x and y coordinates
  2084. * @param x defines the first coordinate
  2085. * @param y defines the second coordinate
  2086. */
  2087. constructor(
  2088. /** defines the first coordinate */
  2089. x?: number,
  2090. /** defines the second coordinate */
  2091. y?: number);
  2092. /**
  2093. * Gets a string with the Vector2 coordinates
  2094. * @returns a string with the Vector2 coordinates
  2095. */
  2096. toString(): string;
  2097. /**
  2098. * Gets class name
  2099. * @returns the string "Vector2"
  2100. */
  2101. getClassName(): string;
  2102. /**
  2103. * Gets current vector hash code
  2104. * @returns the Vector2 hash code as a number
  2105. */
  2106. getHashCode(): number;
  2107. /**
  2108. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2109. * @param array defines the source array
  2110. * @param index defines the offset in source array
  2111. * @returns the current Vector2
  2112. */
  2113. toArray(array: FloatArray, index?: number): Vector2;
  2114. /**
  2115. * Update the current vector from an array
  2116. * @param array defines the destination array
  2117. * @param index defines the offset in the destination array
  2118. * @returns the current Vector3
  2119. */
  2120. fromArray(array: FloatArray, index?: number): Vector2;
  2121. /**
  2122. * Copy the current vector to an array
  2123. * @returns a new array with 2 elements: the Vector2 coordinates.
  2124. */
  2125. asArray(): number[];
  2126. /**
  2127. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2128. * @param source defines the source Vector2
  2129. * @returns the current updated Vector2
  2130. */
  2131. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Sets the Vector2 coordinates with the given floats
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. * @returns the current updated Vector2
  2137. */
  2138. copyFromFloats(x: number, y: number): Vector2;
  2139. /**
  2140. * Sets the Vector2 coordinates with the given floats
  2141. * @param x defines the first coordinate
  2142. * @param y defines the second coordinate
  2143. * @returns the current updated Vector2
  2144. */
  2145. set(x: number, y: number): Vector2;
  2146. /**
  2147. * Add another vector with the current one
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2150. */
  2151. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2152. /**
  2153. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2154. * @param otherVector defines the other vector
  2155. * @param result defines the target vector
  2156. * @returns the unmodified current Vector2
  2157. */
  2158. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2159. /**
  2160. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2161. * @param otherVector defines the other vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2165. /**
  2166. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns a new Vector2
  2169. */
  2170. addVector3(otherVector: Vector3): Vector2;
  2171. /**
  2172. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2173. * @param otherVector defines the other vector
  2174. * @returns a new Vector2
  2175. */
  2176. subtract(otherVector: Vector2): Vector2;
  2177. /**
  2178. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2179. * @param otherVector defines the other vector
  2180. * @param result defines the target vector
  2181. * @returns the unmodified current Vector2
  2182. */
  2183. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2184. /**
  2185. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2186. * @param otherVector defines the other vector
  2187. * @returns the current updated Vector2
  2188. */
  2189. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Multiplies in place the current Vector2 coordinates by the given ones
  2192. * @param otherVector defines the other vector
  2193. * @returns the current updated Vector2
  2194. */
  2195. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2196. /**
  2197. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2
  2200. */
  2201. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2211. * @param x defines the first coordinate
  2212. * @param y defines the second coordinate
  2213. * @returns a new Vector2
  2214. */
  2215. multiplyByFloats(x: number, y: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2218. * @param otherVector defines the other vector
  2219. * @returns a new Vector2
  2220. */
  2221. divide(otherVector: Vector2): Vector2;
  2222. /**
  2223. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2224. * @param otherVector defines the other vector
  2225. * @param result defines the target vector
  2226. * @returns the unmodified current Vector2
  2227. */
  2228. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2229. /**
  2230. * Divides the current Vector2 coordinates by the given ones
  2231. * @param otherVector defines the other vector
  2232. * @returns the current updated Vector2
  2233. */
  2234. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 with current Vector2 negated coordinates
  2237. * @returns a new Vector2
  2238. */
  2239. negate(): Vector2;
  2240. /**
  2241. * Negate this vector in place
  2242. * @returns this
  2243. */
  2244. negateInPlace(): Vector2;
  2245. /**
  2246. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2247. * @param result defines the Vector3 object where to store the result
  2248. * @returns the current Vector2
  2249. */
  2250. negateToRef(result: Vector2): Vector2;
  2251. /**
  2252. * Multiply the Vector2 coordinates by scale
  2253. * @param scale defines the scaling factor
  2254. * @returns the current updated Vector2
  2255. */
  2256. scaleInPlace(scale: number): Vector2;
  2257. /**
  2258. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2259. * @param scale defines the scaling factor
  2260. * @returns a new Vector2
  2261. */
  2262. scale(scale: number): Vector2;
  2263. /**
  2264. * Scale the current Vector2 values by a factor to a given Vector2
  2265. * @param scale defines the scale factor
  2266. * @param result defines the Vector2 object where to store the result
  2267. * @returns the unmodified current Vector2
  2268. */
  2269. scaleToRef(scale: number, result: Vector2): Vector2;
  2270. /**
  2271. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2272. * @param scale defines the scale factor
  2273. * @param result defines the Vector2 object where to store the result
  2274. * @returns the unmodified current Vector2
  2275. */
  2276. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2277. /**
  2278. * Gets a boolean if two vectors are equals
  2279. * @param otherVector defines the other vector
  2280. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2281. */
  2282. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2283. /**
  2284. * Gets a boolean if two vectors are equals (using an epsilon value)
  2285. * @param otherVector defines the other vector
  2286. * @param epsilon defines the minimal distance to consider equality
  2287. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2288. */
  2289. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2290. /**
  2291. * Gets a new Vector2 from current Vector2 floored values
  2292. * @returns a new Vector2
  2293. */
  2294. floor(): Vector2;
  2295. /**
  2296. * Gets a new Vector2 from current Vector2 floored values
  2297. * @returns a new Vector2
  2298. */
  2299. fract(): Vector2;
  2300. /**
  2301. * Gets the length of the vector
  2302. * @returns the vector length (float)
  2303. */
  2304. length(): number;
  2305. /**
  2306. * Gets the vector squared length
  2307. * @returns the vector squared length (float)
  2308. */
  2309. lengthSquared(): number;
  2310. /**
  2311. * Normalize the vector
  2312. * @returns the current updated Vector2
  2313. */
  2314. normalize(): Vector2;
  2315. /**
  2316. * Gets a new Vector2 copied from the Vector2
  2317. * @returns a new Vector2
  2318. */
  2319. clone(): Vector2;
  2320. /**
  2321. * Gets a new Vector2(0, 0)
  2322. * @returns a new Vector2
  2323. */
  2324. static Zero(): Vector2;
  2325. /**
  2326. * Gets a new Vector2(1, 1)
  2327. * @returns a new Vector2
  2328. */
  2329. static One(): Vector2;
  2330. /**
  2331. * Gets a new Vector2 set from the given index element of the given array
  2332. * @param array defines the data source
  2333. * @param offset defines the offset in the data source
  2334. * @returns a new Vector2
  2335. */
  2336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2337. /**
  2338. * Sets "result" from the given index element of the given array
  2339. * @param array defines the data source
  2340. * @param offset defines the offset in the data source
  2341. * @param result defines the target vector
  2342. */
  2343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2344. /**
  2345. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2346. * @param value1 defines 1st point of control
  2347. * @param value2 defines 2nd point of control
  2348. * @param value3 defines 3rd point of control
  2349. * @param value4 defines 4th point of control
  2350. * @param amount defines the interpolation factor
  2351. * @returns a new Vector2
  2352. */
  2353. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2354. /**
  2355. * 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".
  2356. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2357. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2358. * @param value defines the value to clamp
  2359. * @param min defines the lower limit
  2360. * @param max defines the upper limit
  2361. * @returns a new Vector2
  2362. */
  2363. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2364. /**
  2365. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2366. * @param value1 defines the 1st control point
  2367. * @param tangent1 defines the outgoing tangent
  2368. * @param value2 defines the 2nd control point
  2369. * @param tangent2 defines the incoming tangent
  2370. * @param amount defines the interpolation factor
  2371. * @returns a new Vector2
  2372. */
  2373. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2376. * @param start defines the start vector
  2377. * @param end defines the end vector
  2378. * @param amount defines the interpolation factor
  2379. * @returns a new Vector2
  2380. */
  2381. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2382. /**
  2383. * Gets the dot product of the vector "left" and the vector "right"
  2384. * @param left defines first vector
  2385. * @param right defines second vector
  2386. * @returns the dot product (float)
  2387. */
  2388. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2389. /**
  2390. * Returns a new Vector2 equal to the normalized given vector
  2391. * @param vector defines the vector to normalize
  2392. * @returns a new Vector2
  2393. */
  2394. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2397. * @param left defines 1st vector
  2398. * @param right defines 2nd vector
  2399. * @returns a new Vector2
  2400. */
  2401. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2402. /**
  2403. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2404. * @param left defines 1st vector
  2405. * @param right defines 2nd vector
  2406. * @returns a new Vector2
  2407. */
  2408. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2409. /**
  2410. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2411. * @param vector defines the vector to transform
  2412. * @param transformation defines the matrix to apply
  2413. * @returns a new Vector2
  2414. */
  2415. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2416. /**
  2417. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2418. * @param vector defines the vector to transform
  2419. * @param transformation defines the matrix to apply
  2420. * @param result defines the target vector
  2421. */
  2422. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2423. /**
  2424. * Determines if a given vector is included in a triangle
  2425. * @param p defines the vector to test
  2426. * @param p0 defines 1st triangle point
  2427. * @param p1 defines 2nd triangle point
  2428. * @param p2 defines 3rd triangle point
  2429. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2430. */
  2431. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2432. /**
  2433. * Gets the distance between the vectors "value1" and "value2"
  2434. * @param value1 defines first vector
  2435. * @param value2 defines second vector
  2436. * @returns the distance between vectors
  2437. */
  2438. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns the squared distance between the vectors "value1" and "value2"
  2441. * @param value1 defines first vector
  2442. * @param value2 defines second vector
  2443. * @returns the squared distance between vectors
  2444. */
  2445. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2446. /**
  2447. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2448. * @param value1 defines first vector
  2449. * @param value2 defines second vector
  2450. * @returns a new Vector2
  2451. */
  2452. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2453. /**
  2454. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2455. * @param p defines the middle point
  2456. * @param segA defines one point of the segment
  2457. * @param segB defines the other point of the segment
  2458. * @returns the shortest distance
  2459. */
  2460. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2461. }
  2462. /**
  2463. * Class used to store (x,y,z) vector representation
  2464. * A Vector3 is the main object used in 3D geometry
  2465. * It can represent etiher the coordinates of a point the space, either a direction
  2466. * Reminder: js uses a left handed forward facing system
  2467. */
  2468. export class Vector3 {
  2469. private static _UpReadOnly;
  2470. private static _ZeroReadOnly;
  2471. /** @hidden */
  2472. _x: number;
  2473. /** @hidden */
  2474. _y: number;
  2475. /** @hidden */
  2476. _z: number;
  2477. /** @hidden */
  2478. _isDirty: boolean;
  2479. /** Gets or sets the x coordinate */
  2480. get x(): number;
  2481. set x(value: number);
  2482. /** Gets or sets the y coordinate */
  2483. get y(): number;
  2484. set y(value: number);
  2485. /** Gets or sets the z coordinate */
  2486. get z(): number;
  2487. set z(value: number);
  2488. /**
  2489. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2490. * @param x defines the first coordinates (on X axis)
  2491. * @param y defines the second coordinates (on Y axis)
  2492. * @param z defines the third coordinates (on Z axis)
  2493. */
  2494. constructor(x?: number, y?: number, z?: number);
  2495. /**
  2496. * Creates a string representation of the Vector3
  2497. * @returns a string with the Vector3 coordinates.
  2498. */
  2499. toString(): string;
  2500. /**
  2501. * Gets the class name
  2502. * @returns the string "Vector3"
  2503. */
  2504. getClassName(): string;
  2505. /**
  2506. * Creates the Vector3 hash code
  2507. * @returns a number which tends to be unique between Vector3 instances
  2508. */
  2509. getHashCode(): number;
  2510. /**
  2511. * Creates an array containing three elements : the coordinates of the Vector3
  2512. * @returns a new array of numbers
  2513. */
  2514. asArray(): number[];
  2515. /**
  2516. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2517. * @param array defines the destination array
  2518. * @param index defines the offset in the destination array
  2519. * @returns the current Vector3
  2520. */
  2521. toArray(array: FloatArray, index?: number): Vector3;
  2522. /**
  2523. * Update the current vector from an array
  2524. * @param array defines the destination array
  2525. * @param index defines the offset in the destination array
  2526. * @returns the current Vector3
  2527. */
  2528. fromArray(array: FloatArray, index?: number): Vector3;
  2529. /**
  2530. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2531. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2532. */
  2533. toQuaternion(): Quaternion;
  2534. /**
  2535. * Adds the given vector to the current Vector3
  2536. * @param otherVector defines the second operand
  2537. * @returns the current updated Vector3
  2538. */
  2539. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2540. /**
  2541. * Adds the given coordinates to the current Vector3
  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. * @returns the current updated Vector3
  2546. */
  2547. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2548. /**
  2549. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Subtract the given vector from the current Vector3
  2563. * @param otherVector defines the second operand
  2564. * @returns the current updated Vector3
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2567. /**
  2568. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2569. * @param otherVector defines the second operand
  2570. * @returns the resulting Vector3
  2571. */
  2572. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2573. /**
  2574. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2575. * @param otherVector defines the second operand
  2576. * @param result defines the Vector3 object where to store the result
  2577. * @returns the current Vector3
  2578. */
  2579. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2580. /**
  2581. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the resulting Vector3
  2586. */
  2587. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2590. * @param x defines the x coordinate of the operand
  2591. * @param y defines the y coordinate of the operand
  2592. * @param z defines the z coordinate of the operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2597. /**
  2598. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2599. * @returns a new Vector3
  2600. */
  2601. negate(): Vector3;
  2602. /**
  2603. * Negate this vector in place
  2604. * @returns this
  2605. */
  2606. negateInPlace(): Vector3;
  2607. /**
  2608. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. negateToRef(result: Vector3): Vector3;
  2613. /**
  2614. * Multiplies the Vector3 coordinates by the float "scale"
  2615. * @param scale defines the multiplier factor
  2616. * @returns the current updated Vector3
  2617. */
  2618. scaleInPlace(scale: number): Vector3;
  2619. /**
  2620. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2621. * @param scale defines the multiplier factor
  2622. * @returns a new Vector3
  2623. */
  2624. scale(scale: number): Vector3;
  2625. /**
  2626. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2627. * @param scale defines the multiplier factor
  2628. * @param result defines the Vector3 object where to store the result
  2629. * @returns the current Vector3
  2630. */
  2631. scaleToRef(scale: number, result: Vector3): Vector3;
  2632. /**
  2633. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2634. * @param scale defines the scale factor
  2635. * @param result defines the Vector3 object where to store the result
  2636. * @returns the unmodified current Vector3
  2637. */
  2638. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2639. /**
  2640. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2641. * @param origin defines the origin of the projection ray
  2642. * @param plane defines the plane to project to
  2643. * @returns the projected vector3
  2644. */
  2645. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2646. /**
  2647. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2648. * @param origin defines the origin of the projection ray
  2649. * @param plane defines the plane to project to
  2650. * @param result defines the Vector3 where to store the result
  2651. */
  2652. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2653. /**
  2654. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2655. * @param otherVector defines the second operand
  2656. * @returns true if both vectors are equals
  2657. */
  2658. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2659. /**
  2660. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2661. * @param otherVector defines the second operand
  2662. * @param epsilon defines the minimal distance to define values as equals
  2663. * @returns true if both vectors are distant less than epsilon
  2664. */
  2665. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2666. /**
  2667. * Returns true if the current Vector3 coordinates equals the given floats
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns true if both vectors are equals
  2672. */
  2673. equalsToFloats(x: number, y: number, z: number): boolean;
  2674. /**
  2675. * Multiplies the current Vector3 coordinates by the given ones
  2676. * @param otherVector defines the second operand
  2677. * @returns the current updated Vector3
  2678. */
  2679. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2682. * @param otherVector defines the second operand
  2683. * @returns the new Vector3
  2684. */
  2685. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2686. /**
  2687. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2688. * @param otherVector defines the second operand
  2689. * @param result defines the Vector3 object where to store the result
  2690. * @returns the current Vector3
  2691. */
  2692. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2693. /**
  2694. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the new Vector3
  2699. */
  2700. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2703. * @param otherVector defines the second operand
  2704. * @returns the new Vector3
  2705. */
  2706. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2709. * @param otherVector defines the second operand
  2710. * @param result defines the Vector3 object where to store the result
  2711. * @returns the current Vector3
  2712. */
  2713. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2714. /**
  2715. * Divides the current Vector3 coordinates by the given ones.
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. divideInPlace(otherVector: Vector3): Vector3;
  2720. /**
  2721. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2722. * @param other defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2728. * @param other defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2734. * @param x defines the x coordinate of the operand
  2735. * @param y defines the y coordinate of the operand
  2736. * @param z defines the z coordinate of the operand
  2737. * @returns the current updated Vector3
  2738. */
  2739. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2740. /**
  2741. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2742. * @param x defines the x coordinate of the operand
  2743. * @param y defines the y coordinate of the operand
  2744. * @param z defines the z coordinate of the operand
  2745. * @returns the current updated Vector3
  2746. */
  2747. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2748. /**
  2749. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2750. * Check if is non uniform within a certain amount of decimal places to account for this
  2751. * @param epsilon the amount the values can differ
  2752. * @returns if the the vector is non uniform to a certain number of decimal places
  2753. */
  2754. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2755. /**
  2756. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2757. */
  2758. get isNonUniform(): boolean;
  2759. /**
  2760. * Gets a new Vector3 from current Vector3 floored values
  2761. * @returns a new Vector3
  2762. */
  2763. floor(): Vector3;
  2764. /**
  2765. * Gets a new Vector3 from current Vector3 floored values
  2766. * @returns a new Vector3
  2767. */
  2768. fract(): Vector3;
  2769. /**
  2770. * Gets the length of the Vector3
  2771. * @returns the length of the Vector3
  2772. */
  2773. length(): number;
  2774. /**
  2775. * Gets the squared length of the Vector3
  2776. * @returns squared length of the Vector3
  2777. */
  2778. lengthSquared(): number;
  2779. /**
  2780. * Normalize the current Vector3.
  2781. * Please note that this is an in place operation.
  2782. * @returns the current updated Vector3
  2783. */
  2784. normalize(): Vector3;
  2785. /**
  2786. * Reorders the x y z properties of the vector in place
  2787. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2788. * @returns the current updated vector
  2789. */
  2790. reorderInPlace(order: string): this;
  2791. /**
  2792. * Rotates the vector around 0,0,0 by a quaternion
  2793. * @param quaternion the rotation quaternion
  2794. * @param result vector to store the result
  2795. * @returns the resulting vector
  2796. */
  2797. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2798. /**
  2799. * Rotates a vector around a given point
  2800. * @param quaternion the rotation quaternion
  2801. * @param point the point to rotate around
  2802. * @param result vector to store the result
  2803. * @returns the resulting vector
  2804. */
  2805. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2806. /**
  2807. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2808. * The cross product is then orthogonal to both current and "other"
  2809. * @param other defines the right operand
  2810. * @returns the cross product
  2811. */
  2812. cross(other: Vector3): Vector3;
  2813. /**
  2814. * Normalize the current Vector3 with the given input length.
  2815. * Please note that this is an in place operation.
  2816. * @param len the length of the vector
  2817. * @returns the current updated Vector3
  2818. */
  2819. normalizeFromLength(len: number): Vector3;
  2820. /**
  2821. * Normalize the current Vector3 to a new vector
  2822. * @returns the new Vector3
  2823. */
  2824. normalizeToNew(): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 to the reference
  2827. * @param reference define the Vector3 to update
  2828. * @returns the updated Vector3
  2829. */
  2830. normalizeToRef(reference: Vector3): Vector3;
  2831. /**
  2832. * Creates a new Vector3 copied from the current Vector3
  2833. * @returns the new Vector3
  2834. */
  2835. clone(): Vector3;
  2836. /**
  2837. * Copies the given vector coordinates to the current Vector3 ones
  2838. * @param source defines the source Vector3
  2839. * @returns the current updated Vector3
  2840. */
  2841. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * Copies the given floats to the current Vector3 coordinates
  2844. * @param x defines the x coordinate of the operand
  2845. * @param y defines the y coordinate of the operand
  2846. * @param z defines the z coordinate of the operand
  2847. * @returns the current updated Vector3
  2848. */
  2849. copyFromFloats(x: number, y: number, z: number): Vector3;
  2850. /**
  2851. * Copies the given floats to the current Vector3 coordinates
  2852. * @param x defines the x coordinate of the operand
  2853. * @param y defines the y coordinate of the operand
  2854. * @param z defines the z coordinate of the operand
  2855. * @returns the current updated Vector3
  2856. */
  2857. set(x: number, y: number, z: number): Vector3;
  2858. /**
  2859. * Copies the given float to the current Vector3 coordinates
  2860. * @param v defines the x, y and z coordinates of the operand
  2861. * @returns the current updated Vector3
  2862. */
  2863. setAll(v: number): Vector3;
  2864. /**
  2865. * Get the clip factor between two vectors
  2866. * @param vector0 defines the first operand
  2867. * @param vector1 defines the second operand
  2868. * @param axis defines the axis to use
  2869. * @param size defines the size along the axis
  2870. * @returns the clip factor
  2871. */
  2872. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2873. /**
  2874. * Get angle between two vectors
  2875. * @param vector0 angle between vector0 and vector1
  2876. * @param vector1 angle between vector0 and vector1
  2877. * @param normal direction of the normal
  2878. * @return the angle between vector0 and vector1
  2879. */
  2880. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2881. /**
  2882. * Returns a new Vector3 set from the index "offset" of the given array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @returns the new Vector3
  2886. */
  2887. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2890. * @param array defines the source array
  2891. * @param offset defines the offset in the source array
  2892. * @returns the new Vector3
  2893. * @deprecated Please use FromArray instead.
  2894. */
  2895. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2898. * @param array defines the source array
  2899. * @param offset defines the offset in the source array
  2900. * @param result defines the Vector3 where to store the result
  2901. */
  2902. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2903. /**
  2904. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2905. * @param array defines the source array
  2906. * @param offset defines the offset in the source array
  2907. * @param result defines the Vector3 where to store the result
  2908. * @deprecated Please use FromArrayToRef instead.
  2909. */
  2910. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2911. /**
  2912. * Sets the given vector "result" with the given floats.
  2913. * @param x defines the x coordinate of the source
  2914. * @param y defines the y coordinate of the source
  2915. * @param z defines the z coordinate of the source
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2921. * @returns a new empty Vector3
  2922. */
  2923. static Zero(): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2926. * @returns a new unit Vector3
  2927. */
  2928. static One(): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2931. * @returns a new up Vector3
  2932. */
  2933. static Up(): Vector3;
  2934. /**
  2935. * Gets a up Vector3 that must not be updated
  2936. */
  2937. static get UpReadOnly(): DeepImmutable<Vector3>;
  2938. /**
  2939. * Gets a zero Vector3 that must not be updated
  2940. */
  2941. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2942. /**
  2943. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2944. * @returns a new down Vector3
  2945. */
  2946. static Down(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2949. * @param rightHandedSystem is the scene right-handed (negative z)
  2950. * @returns a new forward Vector3
  2951. */
  2952. static Forward(rightHandedSystem?: boolean): Vector3;
  2953. /**
  2954. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2955. * @param rightHandedSystem is the scene right-handed (negative-z)
  2956. * @returns a new forward Vector3
  2957. */
  2958. static Backward(rightHandedSystem?: boolean): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2961. * @returns a new right Vector3
  2962. */
  2963. static Right(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2966. * @returns a new left Vector3
  2967. */
  2968. static Left(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2971. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2972. * @param vector defines the Vector3 to transform
  2973. * @param transformation defines the transformation matrix
  2974. * @returns the transformed Vector3
  2975. */
  2976. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2977. /**
  2978. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2979. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2980. * @param vector defines the Vector3 to transform
  2981. * @param transformation defines the transformation matrix
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2987. * This method computes tranformed coordinates only, not transformed direction vectors
  2988. * @param x define the x coordinate of the source vector
  2989. * @param y define the y coordinate of the source vector
  2990. * @param z define the z coordinate of the source vector
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2997. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2998. * @param vector defines the Vector3 to transform
  2999. * @param transformation defines the transformation matrix
  3000. * @returns the new Vector3
  3001. */
  3002. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3003. /**
  3004. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3005. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3006. * @param vector defines the Vector3 to transform
  3007. * @param transformation defines the transformation matrix
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3013. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3014. * @param x define the x coordinate of the source vector
  3015. * @param y define the y coordinate of the source vector
  3016. * @param z define the z coordinate of the source vector
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3023. * @param value1 defines the first control point
  3024. * @param value2 defines the second control point
  3025. * @param value3 defines the third control point
  3026. * @param value4 defines the fourth control point
  3027. * @param amount defines the amount on the spline to use
  3028. * @returns the new Vector3
  3029. */
  3030. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3031. /**
  3032. * 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"
  3033. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3034. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3035. * @param value defines the current value
  3036. * @param min defines the lower range value
  3037. * @param max defines the upper range value
  3038. * @returns the new Vector3
  3039. */
  3040. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * 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"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3051. /**
  3052. * Checks if a given vector is inside a specific range
  3053. * @param v defines the vector to test
  3054. * @param min defines the minimum range
  3055. * @param max defines the maximum range
  3056. */
  3057. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3058. /**
  3059. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3060. * @param value1 defines the first control point
  3061. * @param tangent1 defines the first tangent vector
  3062. * @param value2 defines the second control point
  3063. * @param tangent2 defines the second tangent vector
  3064. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3065. * @returns the new Vector3
  3066. */
  3067. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3070. * @param start defines the start value
  3071. * @param end defines the end value
  3072. * @param amount max defines amount between both (between 0 and 1)
  3073. * @returns the new Vector3
  3074. */
  3075. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3076. /**
  3077. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3078. * @param start defines the start value
  3079. * @param end defines the end value
  3080. * @param amount max defines amount between both (between 0 and 1)
  3081. * @param result defines the Vector3 where to store the result
  3082. */
  3083. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3084. /**
  3085. * Returns the dot product (float) between the vectors "left" and "right"
  3086. * @param left defines the left operand
  3087. * @param right defines the right operand
  3088. * @returns the dot product
  3089. */
  3090. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3091. /**
  3092. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3093. * The cross product is then orthogonal to both "left" and "right"
  3094. * @param left defines the left operand
  3095. * @param right defines the right operand
  3096. * @returns the cross product
  3097. */
  3098. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3099. /**
  3100. * Sets the given vector "result" with the cross product of "left" and "right"
  3101. * The cross product is then orthogonal to both "left" and "right"
  3102. * @param left defines the left operand
  3103. * @param right defines the right operand
  3104. * @param result defines the Vector3 where to store the result
  3105. */
  3106. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3107. /**
  3108. * Returns a new Vector3 as the normalization of the given vector
  3109. * @param vector defines the Vector3 to normalize
  3110. * @returns the new Vector3
  3111. */
  3112. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3113. /**
  3114. * Sets the given vector "result" with the normalization of the given first vector
  3115. * @param vector defines the Vector3 to normalize
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Project a Vector3 onto screen space
  3121. * @param vector defines the Vector3 to project
  3122. * @param world defines the world matrix to use
  3123. * @param transform defines the transform (view x projection) matrix to use
  3124. * @param viewport defines the screen viewport to use
  3125. * @returns the new Vector3
  3126. */
  3127. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3128. /** @hidden */
  3129. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3130. /**
  3131. * Unproject from screen space to object space
  3132. * @param source defines the screen space Vector3 to use
  3133. * @param viewportWidth defines the current width of the viewport
  3134. * @param viewportHeight defines the current height of the viewport
  3135. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3136. * @param transform defines the transform (view x projection) matrix to use
  3137. * @returns the new Vector3
  3138. */
  3139. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param source defines the screen space Vector3 to use
  3143. * @param viewportWidth defines the current width of the viewport
  3144. * @param viewportHeight defines the current height of the viewport
  3145. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3146. * @param view defines the view matrix to use
  3147. * @param projection defines the projection matrix to use
  3148. * @returns the new Vector3
  3149. */
  3150. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3151. /**
  3152. * Unproject from screen space to object space
  3153. * @param source defines the screen space Vector3 to use
  3154. * @param viewportWidth defines the current width of the viewport
  3155. * @param viewportHeight defines the current height of the viewport
  3156. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3157. * @param view defines the view matrix to use
  3158. * @param projection defines the projection matrix to use
  3159. * @param result defines the Vector3 where to store the result
  3160. */
  3161. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param sourceX defines the screen space x coordinate to use
  3165. * @param sourceY defines the screen space y coordinate to use
  3166. * @param sourceZ defines the screen space z coordinate to use
  3167. * @param viewportWidth defines the current width of the viewport
  3168. * @param viewportHeight defines the current height of the viewport
  3169. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3170. * @param view defines the view matrix to use
  3171. * @param projection defines the projection matrix to use
  3172. * @param result defines the Vector3 where to store the result
  3173. */
  3174. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3175. /**
  3176. * Gets the minimal coordinate values between two Vector3
  3177. * @param left defines the first operand
  3178. * @param right defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Gets the maximal coordinate values between two Vector3
  3184. * @param left defines the first operand
  3185. * @param right defines the second operand
  3186. * @returns the new Vector3
  3187. */
  3188. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3189. /**
  3190. * Returns the distance between the vectors "value1" and "value2"
  3191. * @param value1 defines the first operand
  3192. * @param value2 defines the second operand
  3193. * @returns the distance
  3194. */
  3195. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3196. /**
  3197. * Returns the squared distance between the vectors "value1" and "value2"
  3198. * @param value1 defines the first operand
  3199. * @param value2 defines the second operand
  3200. * @returns the squared distance
  3201. */
  3202. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3203. /**
  3204. * Returns a new Vector3 located at the center between "value1" and "value2"
  3205. * @param value1 defines the first operand
  3206. * @param value2 defines the second operand
  3207. * @returns the new Vector3
  3208. */
  3209. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3210. /**
  3211. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3212. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3213. * to something in order to rotate it from its local system to the given target system
  3214. * Note: axis1, axis2 and axis3 are normalized during this operation
  3215. * @param axis1 defines the first axis
  3216. * @param axis2 defines the second axis
  3217. * @param axis3 defines the third axis
  3218. * @returns a new Vector3
  3219. */
  3220. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3223. * @param axis1 defines the first axis
  3224. * @param axis2 defines the second axis
  3225. * @param axis3 defines the third axis
  3226. * @param ref defines the Vector3 where to store the result
  3227. */
  3228. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3229. }
  3230. /**
  3231. * Vector4 class created for EulerAngle class conversion to Quaternion
  3232. */
  3233. export class Vector4 {
  3234. /** x value of the vector */
  3235. x: number;
  3236. /** y value of the vector */
  3237. y: number;
  3238. /** z value of the vector */
  3239. z: number;
  3240. /** w value of the vector */
  3241. w: number;
  3242. /**
  3243. * Creates a Vector4 object from the given floats.
  3244. * @param x x value of the vector
  3245. * @param y y value of the vector
  3246. * @param z z value of the vector
  3247. * @param w w value of the vector
  3248. */
  3249. constructor(
  3250. /** x value of the vector */
  3251. x: number,
  3252. /** y value of the vector */
  3253. y: number,
  3254. /** z value of the vector */
  3255. z: number,
  3256. /** w value of the vector */
  3257. w: number);
  3258. /**
  3259. * Returns the string with the Vector4 coordinates.
  3260. * @returns a string containing all the vector values
  3261. */
  3262. toString(): string;
  3263. /**
  3264. * Returns the string "Vector4".
  3265. * @returns "Vector4"
  3266. */
  3267. getClassName(): string;
  3268. /**
  3269. * Returns the Vector4 hash code.
  3270. * @returns a unique hash code
  3271. */
  3272. getHashCode(): number;
  3273. /**
  3274. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3275. * @returns the resulting array
  3276. */
  3277. asArray(): number[];
  3278. /**
  3279. * Populates the given array from the given index with the Vector4 coordinates.
  3280. * @param array array to populate
  3281. * @param index index of the array to start at (default: 0)
  3282. * @returns the Vector4.
  3283. */
  3284. toArray(array: FloatArray, index?: number): Vector4;
  3285. /**
  3286. * Update the current vector from an array
  3287. * @param array defines the destination array
  3288. * @param index defines the offset in the destination array
  3289. * @returns the current Vector3
  3290. */
  3291. fromArray(array: FloatArray, index?: number): Vector4;
  3292. /**
  3293. * Adds the given vector to the current Vector4.
  3294. * @param otherVector the vector to add
  3295. * @returns the updated Vector4.
  3296. */
  3297. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3300. * @param otherVector the vector to add
  3301. * @returns the resulting vector
  3302. */
  3303. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3306. * @param otherVector the vector to add
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Subtract in place the given vector from the current Vector4.
  3313. * @param otherVector the vector to subtract
  3314. * @returns the updated Vector4.
  3315. */
  3316. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3319. * @param otherVector the vector to add
  3320. * @returns the new vector with the result
  3321. */
  3322. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3323. /**
  3324. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3325. * @param otherVector the vector to subtract
  3326. * @param result the vector to store the result
  3327. * @returns the current Vector4.
  3328. */
  3329. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3332. */
  3333. /**
  3334. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3335. * @param x value to subtract
  3336. * @param y value to subtract
  3337. * @param z value to subtract
  3338. * @param w value to subtract
  3339. * @returns new vector containing the result
  3340. */
  3341. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3342. /**
  3343. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3344. * @param x value to subtract
  3345. * @param y value to subtract
  3346. * @param z value to subtract
  3347. * @param w value to subtract
  3348. * @param result the vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3354. * @returns a new vector with the negated values
  3355. */
  3356. negate(): Vector4;
  3357. /**
  3358. * Negate this vector in place
  3359. * @returns this
  3360. */
  3361. negateInPlace(): Vector4;
  3362. /**
  3363. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3364. * @param result defines the Vector3 object where to store the result
  3365. * @returns the current Vector4
  3366. */
  3367. negateToRef(result: Vector4): Vector4;
  3368. /**
  3369. * Multiplies the current Vector4 coordinates by scale (float).
  3370. * @param scale the number to scale with
  3371. * @returns the updated Vector4.
  3372. */
  3373. scaleInPlace(scale: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3376. * @param scale the number to scale with
  3377. * @returns a new vector with the result
  3378. */
  3379. scale(scale: number): Vector4;
  3380. /**
  3381. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3382. * @param scale the number to scale with
  3383. * @param result a vector to store the result in
  3384. * @returns the current Vector4.
  3385. */
  3386. scaleToRef(scale: number, result: Vector4): Vector4;
  3387. /**
  3388. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3389. * @param scale defines the scale factor
  3390. * @param result defines the Vector4 object where to store the result
  3391. * @returns the unmodified current Vector4
  3392. */
  3393. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3394. /**
  3395. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3396. * @param otherVector the vector to compare against
  3397. * @returns true if they are equal
  3398. */
  3399. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3400. /**
  3401. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3402. * @param otherVector vector to compare against
  3403. * @param epsilon (Default: very small number)
  3404. * @returns true if they are equal
  3405. */
  3406. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3407. /**
  3408. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3409. * @param x x value to compare against
  3410. * @param y y value to compare against
  3411. * @param z z value to compare against
  3412. * @param w w value to compare against
  3413. * @returns true if equal
  3414. */
  3415. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3416. /**
  3417. * Multiplies in place the current Vector4 by the given one.
  3418. * @param otherVector vector to multiple with
  3419. * @returns the updated Vector4.
  3420. */
  3421. multiplyInPlace(otherVector: Vector4): Vector4;
  3422. /**
  3423. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3424. * @param otherVector vector to multiple with
  3425. * @returns resulting new vector
  3426. */
  3427. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3430. * @param otherVector vector to multiple with
  3431. * @param result vector to store the result
  3432. * @returns the current Vector4.
  3433. */
  3434. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3435. /**
  3436. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3437. * @param x x value multiply with
  3438. * @param y y value multiply with
  3439. * @param z z value multiply with
  3440. * @param w w value multiply with
  3441. * @returns resulting new vector
  3442. */
  3443. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3446. * @param otherVector vector to devide with
  3447. * @returns resulting new vector
  3448. */
  3449. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3452. * @param otherVector vector to devide with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Divides the current Vector3 coordinates by the given ones.
  3459. * @param otherVector vector to devide with
  3460. * @returns the updated Vector3.
  3461. */
  3462. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3463. /**
  3464. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3465. * @param other defines the second operand
  3466. * @returns the current updated Vector4
  3467. */
  3468. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3469. /**
  3470. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3471. * @param other defines the second operand
  3472. * @returns the current updated Vector4
  3473. */
  3474. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3475. /**
  3476. * Gets a new Vector4 from current Vector4 floored values
  3477. * @returns a new Vector4
  3478. */
  3479. floor(): Vector4;
  3480. /**
  3481. * Gets a new Vector4 from current Vector3 floored values
  3482. * @returns a new Vector4
  3483. */
  3484. fract(): Vector4;
  3485. /**
  3486. * Returns the Vector4 length (float).
  3487. * @returns the length
  3488. */
  3489. length(): number;
  3490. /**
  3491. * Returns the Vector4 squared length (float).
  3492. * @returns the length squared
  3493. */
  3494. lengthSquared(): number;
  3495. /**
  3496. * Normalizes in place the Vector4.
  3497. * @returns the updated Vector4.
  3498. */
  3499. normalize(): Vector4;
  3500. /**
  3501. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3502. * @returns this converted to a new vector3
  3503. */
  3504. toVector3(): Vector3;
  3505. /**
  3506. * Returns a new Vector4 copied from the current one.
  3507. * @returns the new cloned vector
  3508. */
  3509. clone(): Vector4;
  3510. /**
  3511. * Updates the current Vector4 with the given one coordinates.
  3512. * @param source the source vector to copy from
  3513. * @returns the updated Vector4.
  3514. */
  3515. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3516. /**
  3517. * Updates the current Vector4 coordinates with the given floats.
  3518. * @param x float to copy from
  3519. * @param y float to copy from
  3520. * @param z float to copy from
  3521. * @param w float to copy from
  3522. * @returns the updated Vector4.
  3523. */
  3524. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3525. /**
  3526. * Updates the current Vector4 coordinates with the given floats.
  3527. * @param x float to set from
  3528. * @param y float to set from
  3529. * @param z float to set from
  3530. * @param w float to set from
  3531. * @returns the updated Vector4.
  3532. */
  3533. set(x: number, y: number, z: number, w: number): Vector4;
  3534. /**
  3535. * Copies the given float to the current Vector3 coordinates
  3536. * @param v defines the x, y, z and w coordinates of the operand
  3537. * @returns the current updated Vector3
  3538. */
  3539. setAll(v: number): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set from the starting index of the given array.
  3542. * @param array the array to pull values from
  3543. * @param offset the offset into the array to start at
  3544. * @returns the new vector
  3545. */
  3546. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3547. /**
  3548. * Updates the given vector "result" from the starting index of the given array.
  3549. * @param array the array to pull values from
  3550. * @param offset the offset into the array to start at
  3551. * @param result the vector to store the result in
  3552. */
  3553. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3554. /**
  3555. * Updates the given vector "result" from the starting index of the given Float32Array.
  3556. * @param array the array to pull values from
  3557. * @param offset the offset into the array to start at
  3558. * @param result the vector to store the result in
  3559. */
  3560. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3561. /**
  3562. * Updates the given vector "result" coordinates from the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @param result the vector to the floats in
  3568. */
  3569. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3570. /**
  3571. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3572. * @returns the new vector
  3573. */
  3574. static Zero(): Vector4;
  3575. /**
  3576. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3577. * @returns the new vector
  3578. */
  3579. static One(): Vector4;
  3580. /**
  3581. * Returns a new normalized Vector4 from the given one.
  3582. * @param vector the vector to normalize
  3583. * @returns the vector
  3584. */
  3585. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3586. /**
  3587. * Updates the given vector "result" from the normalization of the given one.
  3588. * @param vector the vector to normalize
  3589. * @param result the vector to store the result in
  3590. */
  3591. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3592. /**
  3593. * Returns a vector with the minimum values from the left and right vectors
  3594. * @param left left vector to minimize
  3595. * @param right right vector to minimize
  3596. * @returns a new vector with the minimum of the left and right vector values
  3597. */
  3598. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3599. /**
  3600. * Returns a vector with the maximum values from the left and right vectors
  3601. * @param left left vector to maximize
  3602. * @param right right vector to maximize
  3603. * @returns a new vector with the maximum of the left and right vector values
  3604. */
  3605. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3606. /**
  3607. * Returns the distance (float) between the vectors "value1" and "value2".
  3608. * @param value1 value to calulate the distance between
  3609. * @param value2 value to calulate the distance between
  3610. * @return the distance between the two vectors
  3611. */
  3612. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3613. /**
  3614. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3615. * @param value1 value to calulate the distance between
  3616. * @param value2 value to calulate the distance between
  3617. * @return the distance between the two vectors squared
  3618. */
  3619. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3620. /**
  3621. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3622. * @param value1 value to calulate the center between
  3623. * @param value2 value to calulate the center between
  3624. * @return the center between the two vectors
  3625. */
  3626. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3627. /**
  3628. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3629. * This methods computes transformed normalized direction vectors only.
  3630. * @param vector the vector to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @returns the new vector
  3633. */
  3634. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3635. /**
  3636. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3637. * This methods computes transformed normalized direction vectors only.
  3638. * @param vector the vector to transform
  3639. * @param transformation the transformation matrix to apply
  3640. * @param result the vector to store the result in
  3641. */
  3642. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3643. /**
  3644. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3645. * This methods computes transformed normalized direction vectors only.
  3646. * @param x value to transform
  3647. * @param y value to transform
  3648. * @param z value to transform
  3649. * @param w value to transform
  3650. * @param transformation the transformation matrix to apply
  3651. * @param result the vector to store the results in
  3652. */
  3653. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3654. /**
  3655. * Creates a new Vector4 from a Vector3
  3656. * @param source defines the source data
  3657. * @param w defines the 4th component (default is 0)
  3658. * @returns a new Vector4
  3659. */
  3660. static FromVector3(source: Vector3, w?: number): Vector4;
  3661. }
  3662. /**
  3663. * Class used to store quaternion data
  3664. * @see https://en.wikipedia.org/wiki/Quaternion
  3665. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3666. */
  3667. export class Quaternion {
  3668. /** @hidden */
  3669. _x: number;
  3670. /** @hidden */
  3671. _y: number;
  3672. /** @hidden */
  3673. _z: number;
  3674. /** @hidden */
  3675. _w: number;
  3676. /** @hidden */
  3677. _isDirty: boolean;
  3678. /** Gets or sets the x coordinate */
  3679. get x(): number;
  3680. set x(value: number);
  3681. /** Gets or sets the y coordinate */
  3682. get y(): number;
  3683. set y(value: number);
  3684. /** Gets or sets the z coordinate */
  3685. get z(): number;
  3686. set z(value: number);
  3687. /** Gets or sets the w coordinate */
  3688. get w(): number;
  3689. set w(value: number);
  3690. /**
  3691. * Creates a new Quaternion from the given floats
  3692. * @param x defines the first component (0 by default)
  3693. * @param y defines the second component (0 by default)
  3694. * @param z defines the third component (0 by default)
  3695. * @param w defines the fourth component (1.0 by default)
  3696. */
  3697. constructor(x?: number, y?: number, z?: number, w?: number);
  3698. /**
  3699. * Gets a string representation for the current quaternion
  3700. * @returns a string with the Quaternion coordinates
  3701. */
  3702. toString(): string;
  3703. /**
  3704. * Gets the class name of the quaternion
  3705. * @returns the string "Quaternion"
  3706. */
  3707. getClassName(): string;
  3708. /**
  3709. * Gets a hash code for this quaternion
  3710. * @returns the quaternion hash code
  3711. */
  3712. getHashCode(): number;
  3713. /**
  3714. * Copy the quaternion to an array
  3715. * @returns a new array populated with 4 elements from the quaternion coordinates
  3716. */
  3717. asArray(): number[];
  3718. /**
  3719. * Check if two quaternions are equals
  3720. * @param otherQuaternion defines the second operand
  3721. * @return true if the current quaternion and the given one coordinates are strictly equals
  3722. */
  3723. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3726. * @param otherQuaternion defines the other quaternion
  3727. * @param epsilon defines the minimal distance to consider equality
  3728. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3729. */
  3730. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3731. /**
  3732. * Clone the current quaternion
  3733. * @returns a new quaternion copied from the current one
  3734. */
  3735. clone(): Quaternion;
  3736. /**
  3737. * Copy a quaternion to the current one
  3738. * @param other defines the other quaternion
  3739. * @returns the updated current quaternion
  3740. */
  3741. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3742. /**
  3743. * Updates the current quaternion with the given float coordinates
  3744. * @param x defines the x coordinate
  3745. * @param y defines the y coordinate
  3746. * @param z defines the z coordinate
  3747. * @param w defines the w coordinate
  3748. * @returns the updated current quaternion
  3749. */
  3750. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3751. /**
  3752. * Updates the current quaternion from the given float coordinates
  3753. * @param x defines the x coordinate
  3754. * @param y defines the y coordinate
  3755. * @param z defines the z coordinate
  3756. * @param w defines the w coordinate
  3757. * @returns the updated current quaternion
  3758. */
  3759. set(x: number, y: number, z: number, w: number): Quaternion;
  3760. /**
  3761. * Adds two quaternions
  3762. * @param other defines the second operand
  3763. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3764. */
  3765. add(other: DeepImmutable<Quaternion>): Quaternion;
  3766. /**
  3767. * Add a quaternion to the current one
  3768. * @param other defines the quaternion to add
  3769. * @returns the current quaternion
  3770. */
  3771. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3772. /**
  3773. * Subtract two quaternions
  3774. * @param other defines the second operand
  3775. * @returns a new quaternion as the subtraction result of the given one from the current one
  3776. */
  3777. subtract(other: Quaternion): Quaternion;
  3778. /**
  3779. * Multiplies the current quaternion by a scale factor
  3780. * @param value defines the scale factor
  3781. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3782. */
  3783. scale(value: number): Quaternion;
  3784. /**
  3785. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3786. * @param scale defines the scale factor
  3787. * @param result defines the Quaternion object where to store the result
  3788. * @returns the unmodified current quaternion
  3789. */
  3790. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3791. /**
  3792. * Multiplies in place the current quaternion by a scale factor
  3793. * @param value defines the scale factor
  3794. * @returns the current modified quaternion
  3795. */
  3796. scaleInPlace(value: number): Quaternion;
  3797. /**
  3798. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3799. * @param scale defines the scale factor
  3800. * @param result defines the Quaternion object where to store the result
  3801. * @returns the unmodified current quaternion
  3802. */
  3803. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3804. /**
  3805. * Multiplies two quaternions
  3806. * @param q1 defines the second operand
  3807. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3808. */
  3809. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3810. /**
  3811. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3812. * @param q1 defines the second operand
  3813. * @param result defines the target quaternion
  3814. * @returns the current quaternion
  3815. */
  3816. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3817. /**
  3818. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3819. * @param q1 defines the second operand
  3820. * @returns the currentupdated quaternion
  3821. */
  3822. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3823. /**
  3824. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3825. * @param ref defines the target quaternion
  3826. * @returns the current quaternion
  3827. */
  3828. conjugateToRef(ref: Quaternion): Quaternion;
  3829. /**
  3830. * Conjugates in place (1-q) the current quaternion
  3831. * @returns the current updated quaternion
  3832. */
  3833. conjugateInPlace(): Quaternion;
  3834. /**
  3835. * Conjugates in place (1-q) the current quaternion
  3836. * @returns a new quaternion
  3837. */
  3838. conjugate(): Quaternion;
  3839. /**
  3840. * Gets length of current quaternion
  3841. * @returns the quaternion length (float)
  3842. */
  3843. length(): number;
  3844. /**
  3845. * Normalize in place the current quaternion
  3846. * @returns the current updated quaternion
  3847. */
  3848. normalize(): Quaternion;
  3849. /**
  3850. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3851. * @param order is a reserved parameter and is ignored for now
  3852. * @returns a new Vector3 containing the Euler angles
  3853. */
  3854. toEulerAngles(order?: string): Vector3;
  3855. /**
  3856. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3857. * @param result defines the vector which will be filled with the Euler angles
  3858. * @returns the current unchanged quaternion
  3859. */
  3860. toEulerAnglesToRef(result: Vector3): Quaternion;
  3861. /**
  3862. * Updates the given rotation matrix with the current quaternion values
  3863. * @param result defines the target matrix
  3864. * @returns the current unchanged quaternion
  3865. */
  3866. toRotationMatrix(result: Matrix): Quaternion;
  3867. /**
  3868. * Updates the current quaternion from the given rotation matrix values
  3869. * @param matrix defines the source matrix
  3870. * @returns the current updated quaternion
  3871. */
  3872. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from a rotation matrix
  3875. * @param matrix defines the source matrix
  3876. * @returns a new quaternion created from the given rotation matrix values
  3877. */
  3878. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3879. /**
  3880. * Updates the given quaternion with the given rotation matrix values
  3881. * @param matrix defines the source matrix
  3882. * @param result defines the target quaternion
  3883. */
  3884. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3885. /**
  3886. * Returns the dot product (float) between the quaternions "left" and "right"
  3887. * @param left defines the left operand
  3888. * @param right defines the right operand
  3889. * @returns the dot product
  3890. */
  3891. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3892. /**
  3893. * Checks if the two quaternions are close to each other
  3894. * @param quat0 defines the first quaternion to check
  3895. * @param quat1 defines the second quaternion to check
  3896. * @returns true if the two quaternions are close to each other
  3897. */
  3898. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3899. /**
  3900. * Creates an empty quaternion
  3901. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3902. */
  3903. static Zero(): Quaternion;
  3904. /**
  3905. * Inverse a given quaternion
  3906. * @param q defines the source quaternion
  3907. * @returns a new quaternion as the inverted current quaternion
  3908. */
  3909. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3910. /**
  3911. * Inverse a given quaternion
  3912. * @param q defines the source quaternion
  3913. * @param result the quaternion the result will be stored in
  3914. * @returns the result quaternion
  3915. */
  3916. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates an identity quaternion
  3919. * @returns the identity quaternion
  3920. */
  3921. static Identity(): Quaternion;
  3922. /**
  3923. * Gets a boolean indicating if the given quaternion is identity
  3924. * @param quaternion defines the quaternion to check
  3925. * @returns true if the quaternion is identity
  3926. */
  3927. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3928. /**
  3929. * Creates a quaternion from a rotation around an axis
  3930. * @param axis defines the axis to use
  3931. * @param angle defines the angle to use
  3932. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3933. */
  3934. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3935. /**
  3936. * Creates a rotation around an axis and stores it into the given quaternion
  3937. * @param axis defines the axis to use
  3938. * @param angle defines the angle to use
  3939. * @param result defines the target quaternion
  3940. * @returns the target quaternion
  3941. */
  3942. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3943. /**
  3944. * Creates a new quaternion from data stored into an array
  3945. * @param array defines the data source
  3946. * @param offset defines the offset in the source array where the data starts
  3947. * @returns a new quaternion
  3948. */
  3949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3950. /**
  3951. * Updates the given quaternion "result" from the starting index of the given array.
  3952. * @param array the array to pull values from
  3953. * @param offset the offset into the array to start at
  3954. * @param result the quaternion to store the result in
  3955. */
  3956. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3957. /**
  3958. * Create a quaternion from Euler rotation angles
  3959. * @param x Pitch
  3960. * @param y Yaw
  3961. * @param z Roll
  3962. * @returns the new Quaternion
  3963. */
  3964. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3965. /**
  3966. * Updates a quaternion from Euler rotation angles
  3967. * @param x Pitch
  3968. * @param y Yaw
  3969. * @param z Roll
  3970. * @param result the quaternion to store the result
  3971. * @returns the updated quaternion
  3972. */
  3973. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3974. /**
  3975. * Create a quaternion from Euler rotation vector
  3976. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3977. * @returns the new Quaternion
  3978. */
  3979. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3980. /**
  3981. * Updates a quaternion from Euler rotation vector
  3982. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3983. * @param result the quaternion to store the result
  3984. * @returns the updated quaternion
  3985. */
  3986. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3987. /**
  3988. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3989. * @param yaw defines the rotation around Y axis
  3990. * @param pitch defines the rotation around X axis
  3991. * @param roll defines the rotation around Z axis
  3992. * @returns the new quaternion
  3993. */
  3994. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3995. /**
  3996. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3997. * @param yaw defines the rotation around Y axis
  3998. * @param pitch defines the rotation around X axis
  3999. * @param roll defines the rotation around Z axis
  4000. * @param result defines the target quaternion
  4001. */
  4002. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4003. /**
  4004. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4005. * @param alpha defines the rotation around first axis
  4006. * @param beta defines the rotation around second axis
  4007. * @param gamma defines the rotation around third axis
  4008. * @returns the new quaternion
  4009. */
  4010. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4011. /**
  4012. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4013. * @param alpha defines the rotation around first axis
  4014. * @param beta defines the rotation around second axis
  4015. * @param gamma defines the rotation around third axis
  4016. * @param result defines the target quaternion
  4017. */
  4018. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4019. /**
  4020. * 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)
  4021. * @param axis1 defines the first axis
  4022. * @param axis2 defines the second axis
  4023. * @param axis3 defines the third axis
  4024. * @returns the new quaternion
  4025. */
  4026. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4027. /**
  4028. * 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
  4029. * @param axis1 defines the first axis
  4030. * @param axis2 defines the second axis
  4031. * @param axis3 defines the third axis
  4032. * @param ref defines the target quaternion
  4033. */
  4034. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4035. /**
  4036. * Interpolates between two quaternions
  4037. * @param left defines first quaternion
  4038. * @param right defines second quaternion
  4039. * @param amount defines the gradient to use
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. /**
  4044. * Interpolates between two quaternions and stores it into a target quaternion
  4045. * @param left defines first quaternion
  4046. * @param right defines second quaternion
  4047. * @param amount defines the gradient to use
  4048. * @param result defines the target quaternion
  4049. */
  4050. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4051. /**
  4052. * Interpolate between two quaternions using Hermite interpolation
  4053. * @param value1 defines first quaternion
  4054. * @param tangent1 defines the incoming tangent
  4055. * @param value2 defines second quaternion
  4056. * @param tangent2 defines the outgoing tangent
  4057. * @param amount defines the target quaternion
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. }
  4062. /**
  4063. * Class used to store matrix data (4x4)
  4064. */
  4065. export class Matrix {
  4066. /**
  4067. * Gets the precision of matrix computations
  4068. */
  4069. static get Use64Bits(): boolean;
  4070. private static _updateFlagSeed;
  4071. private static _identityReadOnly;
  4072. private _isIdentity;
  4073. private _isIdentityDirty;
  4074. private _isIdentity3x2;
  4075. private _isIdentity3x2Dirty;
  4076. /**
  4077. * Gets the update flag of the matrix which is an unique number for the matrix.
  4078. * It will be incremented every time the matrix data change.
  4079. * You can use it to speed the comparison between two versions of the same matrix.
  4080. */
  4081. updateFlag: number;
  4082. private readonly _m;
  4083. /**
  4084. * Gets the internal data of the matrix
  4085. */
  4086. get m(): DeepImmutable<Float32Array | Array<number>>;
  4087. /** @hidden */
  4088. _markAsUpdated(): void;
  4089. /** @hidden */
  4090. private _updateIdentityStatus;
  4091. /**
  4092. * Creates an empty matrix (filled with zeros)
  4093. */
  4094. constructor();
  4095. /**
  4096. * Check if the current matrix is identity
  4097. * @returns true is the matrix is the identity matrix
  4098. */
  4099. isIdentity(): boolean;
  4100. /**
  4101. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4102. * @returns true is the matrix is the identity matrix
  4103. */
  4104. isIdentityAs3x2(): boolean;
  4105. /**
  4106. * Gets the determinant of the matrix
  4107. * @returns the matrix determinant
  4108. */
  4109. determinant(): number;
  4110. /**
  4111. * Returns the matrix as a Float32Array or Array<number>
  4112. * @returns the matrix underlying array
  4113. */
  4114. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4115. /**
  4116. * Returns the matrix as a Float32Array or Array<number>
  4117. * @returns the matrix underlying array.
  4118. */
  4119. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4120. /**
  4121. * Inverts the current matrix in place
  4122. * @returns the current inverted matrix
  4123. */
  4124. invert(): Matrix;
  4125. /**
  4126. * Sets all the matrix elements to zero
  4127. * @returns the current matrix
  4128. */
  4129. reset(): Matrix;
  4130. /**
  4131. * Adds the current matrix with a second one
  4132. * @param other defines the matrix to add
  4133. * @returns a new matrix as the addition of the current matrix and the given one
  4134. */
  4135. add(other: DeepImmutable<Matrix>): Matrix;
  4136. /**
  4137. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4138. * @param other defines the matrix to add
  4139. * @param result defines the target matrix
  4140. * @returns the current matrix
  4141. */
  4142. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4143. /**
  4144. * Adds in place the given matrix to the current matrix
  4145. * @param other defines the second operand
  4146. * @returns the current updated matrix
  4147. */
  4148. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4149. /**
  4150. * Sets the given matrix to the current inverted Matrix
  4151. * @param other defines the target matrix
  4152. * @returns the unmodified current matrix
  4153. */
  4154. invertToRef(other: Matrix): Matrix;
  4155. /**
  4156. * add a value at the specified position in the current Matrix
  4157. * @param index the index of the value within the matrix. between 0 and 15.
  4158. * @param value the value to be added
  4159. * @returns the current updated matrix
  4160. */
  4161. addAtIndex(index: number, value: number): Matrix;
  4162. /**
  4163. * mutiply the specified position in the current Matrix by a value
  4164. * @param index the index of the value within the matrix. between 0 and 15.
  4165. * @param value the value to be added
  4166. * @returns the current updated matrix
  4167. */
  4168. multiplyAtIndex(index: number, value: number): Matrix;
  4169. /**
  4170. * Inserts the translation vector (using 3 floats) in the current matrix
  4171. * @param x defines the 1st component of the translation
  4172. * @param y defines the 2nd component of the translation
  4173. * @param z defines the 3rd component of the translation
  4174. * @returns the current updated matrix
  4175. */
  4176. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4177. /**
  4178. * Adds the translation vector (using 3 floats) in the current matrix
  4179. * @param x defines the 1st component of the translation
  4180. * @param y defines the 2nd component of the translation
  4181. * @param z defines the 3rd component of the translation
  4182. * @returns the current updated matrix
  4183. */
  4184. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4185. /**
  4186. * Inserts the translation vector in the current matrix
  4187. * @param vector3 defines the translation to insert
  4188. * @returns the current updated matrix
  4189. */
  4190. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Gets the translation value of the current matrix
  4193. * @returns a new Vector3 as the extracted translation from the matrix
  4194. */
  4195. getTranslation(): Vector3;
  4196. /**
  4197. * Fill a Vector3 with the extracted translation from the matrix
  4198. * @param result defines the Vector3 where to store the translation
  4199. * @returns the current matrix
  4200. */
  4201. getTranslationToRef(result: Vector3): Matrix;
  4202. /**
  4203. * Remove rotation and scaling part from the matrix
  4204. * @returns the updated matrix
  4205. */
  4206. removeRotationAndScaling(): Matrix;
  4207. /**
  4208. * Multiply two matrices
  4209. * @param other defines the second operand
  4210. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4211. */
  4212. multiply(other: DeepImmutable<Matrix>): Matrix;
  4213. /**
  4214. * Copy the current matrix from the given one
  4215. * @param other defines the source matrix
  4216. * @returns the current updated matrix
  4217. */
  4218. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4219. /**
  4220. * Populates the given array from the starting index with the current matrix values
  4221. * @param array defines the target array
  4222. * @param offset defines the offset in the target array where to start storing values
  4223. * @returns the current matrix
  4224. */
  4225. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4226. /**
  4227. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4228. * @param other defines the second operand
  4229. * @param result defines the matrix where to store the multiplication
  4230. * @returns the current matrix
  4231. */
  4232. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4233. /**
  4234. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4235. * @param other defines the second operand
  4236. * @param result defines the array where to store the multiplication
  4237. * @param offset defines the offset in the target array where to start storing values
  4238. * @returns the current matrix
  4239. */
  4240. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4241. /**
  4242. * Check equality between this matrix and a second one
  4243. * @param value defines the second matrix to compare
  4244. * @returns true is the current matrix and the given one values are strictly equal
  4245. */
  4246. equals(value: DeepImmutable<Matrix>): boolean;
  4247. /**
  4248. * Clone the current matrix
  4249. * @returns a new matrix from the current matrix
  4250. */
  4251. clone(): Matrix;
  4252. /**
  4253. * Returns the name of the current matrix class
  4254. * @returns the string "Matrix"
  4255. */
  4256. getClassName(): string;
  4257. /**
  4258. * Gets the hash code of the current matrix
  4259. * @returns the hash code
  4260. */
  4261. getHashCode(): number;
  4262. /**
  4263. * Decomposes the current Matrix into a translation, rotation and scaling components
  4264. * @param scale defines the scale vector3 given as a reference to update
  4265. * @param rotation defines the rotation quaternion given as a reference to update
  4266. * @param translation defines the translation vector3 given as a reference to update
  4267. * @returns true if operation was successful
  4268. */
  4269. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4270. /**
  4271. * Gets specific row of the matrix
  4272. * @param index defines the number of the row to get
  4273. * @returns the index-th row of the current matrix as a new Vector4
  4274. */
  4275. getRow(index: number): Nullable<Vector4>;
  4276. /**
  4277. * Sets the index-th row of the current matrix to the vector4 values
  4278. * @param index defines the number of the row to set
  4279. * @param row defines the target vector4
  4280. * @returns the updated current matrix
  4281. */
  4282. setRow(index: number, row: Vector4): Matrix;
  4283. /**
  4284. * Compute the transpose of the matrix
  4285. * @returns the new transposed matrix
  4286. */
  4287. transpose(): Matrix;
  4288. /**
  4289. * Compute the transpose of the matrix and store it in a given matrix
  4290. * @param result defines the target matrix
  4291. * @returns the current matrix
  4292. */
  4293. transposeToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Sets the index-th row of the current matrix with the given 4 x float values
  4296. * @param index defines the row index
  4297. * @param x defines the x component to set
  4298. * @param y defines the y component to set
  4299. * @param z defines the z component to set
  4300. * @param w defines the w component to set
  4301. * @returns the updated current matrix
  4302. */
  4303. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4304. /**
  4305. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4306. * @param scale defines the scale factor
  4307. * @returns a new matrix
  4308. */
  4309. scale(scale: number): Matrix;
  4310. /**
  4311. * Scale the current matrix values by a factor to a given result matrix
  4312. * @param scale defines the scale factor
  4313. * @param result defines the matrix to store the result
  4314. * @returns the current matrix
  4315. */
  4316. scaleToRef(scale: number, result: Matrix): Matrix;
  4317. /**
  4318. * Scale the current matrix values by a factor and add the result to a given matrix
  4319. * @param scale defines the scale factor
  4320. * @param result defines the Matrix to store the result
  4321. * @returns the current matrix
  4322. */
  4323. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4324. /**
  4325. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4326. * @param ref matrix to store the result
  4327. */
  4328. toNormalMatrix(ref: Matrix): void;
  4329. /**
  4330. * Gets only rotation part of the current matrix
  4331. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4332. */
  4333. getRotationMatrix(): Matrix;
  4334. /**
  4335. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4336. * @param result defines the target matrix to store data to
  4337. * @returns the current matrix
  4338. */
  4339. getRotationMatrixToRef(result: Matrix): Matrix;
  4340. /**
  4341. * Toggles model matrix from being right handed to left handed in place and vice versa
  4342. */
  4343. toggleModelMatrixHandInPlace(): void;
  4344. /**
  4345. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4346. */
  4347. toggleProjectionMatrixHandInPlace(): void;
  4348. /**
  4349. * Creates a matrix from an array
  4350. * @param array defines the source array
  4351. * @param offset defines an offset in the source array
  4352. * @returns a new Matrix set from the starting index of the given array
  4353. */
  4354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4355. /**
  4356. * Copy the content of an array into a given matrix
  4357. * @param array defines the source array
  4358. * @param offset defines an offset in the source array
  4359. * @param result defines the target matrix
  4360. */
  4361. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4362. /**
  4363. * Stores an array into a matrix after having multiplied each component by a given factor
  4364. * @param array defines the source array
  4365. * @param offset defines the offset in the source array
  4366. * @param scale defines the scaling factor
  4367. * @param result defines the target matrix
  4368. */
  4369. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4370. /**
  4371. * Gets an identity matrix that must not be updated
  4372. */
  4373. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4374. /**
  4375. * Stores a list of values (16) inside a given matrix
  4376. * @param initialM11 defines 1st value of 1st row
  4377. * @param initialM12 defines 2nd value of 1st row
  4378. * @param initialM13 defines 3rd value of 1st row
  4379. * @param initialM14 defines 4th value of 1st row
  4380. * @param initialM21 defines 1st value of 2nd row
  4381. * @param initialM22 defines 2nd value of 2nd row
  4382. * @param initialM23 defines 3rd value of 2nd row
  4383. * @param initialM24 defines 4th value of 2nd row
  4384. * @param initialM31 defines 1st value of 3rd row
  4385. * @param initialM32 defines 2nd value of 3rd row
  4386. * @param initialM33 defines 3rd value of 3rd row
  4387. * @param initialM34 defines 4th value of 3rd row
  4388. * @param initialM41 defines 1st value of 4th row
  4389. * @param initialM42 defines 2nd value of 4th row
  4390. * @param initialM43 defines 3rd value of 4th row
  4391. * @param initialM44 defines 4th value of 4th row
  4392. * @param result defines the target matrix
  4393. */
  4394. 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;
  4395. /**
  4396. * Creates new matrix from a list of values (16)
  4397. * @param initialM11 defines 1st value of 1st row
  4398. * @param initialM12 defines 2nd value of 1st row
  4399. * @param initialM13 defines 3rd value of 1st row
  4400. * @param initialM14 defines 4th value of 1st row
  4401. * @param initialM21 defines 1st value of 2nd row
  4402. * @param initialM22 defines 2nd value of 2nd row
  4403. * @param initialM23 defines 3rd value of 2nd row
  4404. * @param initialM24 defines 4th value of 2nd row
  4405. * @param initialM31 defines 1st value of 3rd row
  4406. * @param initialM32 defines 2nd value of 3rd row
  4407. * @param initialM33 defines 3rd value of 3rd row
  4408. * @param initialM34 defines 4th value of 3rd row
  4409. * @param initialM41 defines 1st value of 4th row
  4410. * @param initialM42 defines 2nd value of 4th row
  4411. * @param initialM43 defines 3rd value of 4th row
  4412. * @param initialM44 defines 4th value of 4th row
  4413. * @returns the new matrix
  4414. */
  4415. 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;
  4416. /**
  4417. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4418. * @param scale defines the scale vector3
  4419. * @param rotation defines the rotation quaternion
  4420. * @param translation defines the translation vector3
  4421. * @returns a new matrix
  4422. */
  4423. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4426. * @param scale defines the scale vector3
  4427. * @param rotation defines the rotation quaternion
  4428. * @param translation defines the translation vector3
  4429. * @param result defines the target matrix
  4430. */
  4431. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4432. /**
  4433. * Creates a new identity matrix
  4434. * @returns a new identity matrix
  4435. */
  4436. static Identity(): Matrix;
  4437. /**
  4438. * Creates a new identity matrix and stores the result in a given matrix
  4439. * @param result defines the target matrix
  4440. */
  4441. static IdentityToRef(result: Matrix): void;
  4442. /**
  4443. * Creates a new zero matrix
  4444. * @returns a new zero matrix
  4445. */
  4446. static Zero(): Matrix;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the X axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationX(angle: number): Matrix;
  4453. /**
  4454. * Creates a new matrix as the invert of a given matrix
  4455. * @param source defines the source matrix
  4456. * @returns the new matrix
  4457. */
  4458. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationXToRef(angle: number, result: Matrix): void;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Y axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationY(angle: number): Matrix;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4473. * @param angle defines the angle (in radians) to use
  4474. * @param result defines the target matrix
  4475. */
  4476. static RotationYToRef(angle: number, result: Matrix): void;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the Z axis
  4479. * @param angle defines the angle (in radians) to use
  4480. * @return the new matrix
  4481. */
  4482. static RotationZ(angle: number): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4485. * @param angle defines the angle (in radians) to use
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationZToRef(angle: number, result: Matrix): void;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the given axis
  4491. * @param axis defines the axis to use
  4492. * @param angle defines the angle (in radians) to use
  4493. * @return the new matrix
  4494. */
  4495. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4496. /**
  4497. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4498. * @param axis defines the axis to use
  4499. * @param angle defines the angle (in radians) to use
  4500. * @param result defines the target matrix
  4501. */
  4502. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4503. /**
  4504. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4505. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4506. * @param from defines the vector to align
  4507. * @param to defines the vector to align to
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4511. /**
  4512. * Creates a rotation matrix
  4513. * @param yaw defines the yaw angle in radians (Y axis)
  4514. * @param pitch defines the pitch angle in radians (X axis)
  4515. * @param roll defines the roll angle in radians (Z axis)
  4516. * @returns the new rotation matrix
  4517. */
  4518. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4519. /**
  4520. * Creates a rotation matrix and stores it in a given matrix
  4521. * @param yaw defines the yaw angle in radians (Y axis)
  4522. * @param pitch defines the pitch angle in radians (X axis)
  4523. * @param roll defines the roll angle in radians (Z axis)
  4524. * @param result defines the target matrix
  4525. */
  4526. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4527. /**
  4528. * Creates a scaling matrix
  4529. * @param x defines the scale factor on X axis
  4530. * @param y defines the scale factor on Y axis
  4531. * @param z defines the scale factor on Z axis
  4532. * @returns the new matrix
  4533. */
  4534. static Scaling(x: number, y: number, z: number): Matrix;
  4535. /**
  4536. * Creates a scaling matrix and stores it in a given matrix
  4537. * @param x defines the scale factor on X axis
  4538. * @param y defines the scale factor on Y axis
  4539. * @param z defines the scale factor on Z axis
  4540. * @param result defines the target matrix
  4541. */
  4542. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4543. /**
  4544. * Creates a translation matrix
  4545. * @param x defines the translation on X axis
  4546. * @param y defines the translation on Y axis
  4547. * @param z defines the translationon Z axis
  4548. * @returns the new matrix
  4549. */
  4550. static Translation(x: number, y: number, z: number): Matrix;
  4551. /**
  4552. * Creates a translation matrix and stores it in a given matrix
  4553. * @param x defines the translation on X axis
  4554. * @param y defines the translation on Y axis
  4555. * @param z defines the translationon Z axis
  4556. * @param result defines the target matrix
  4557. */
  4558. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4559. /**
  4560. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4561. * @param startValue defines the start value
  4562. * @param endValue defines the end value
  4563. * @param gradient defines the gradient factor
  4564. * @returns the new matrix
  4565. */
  4566. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4567. /**
  4568. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4569. * @param startValue defines the start value
  4570. * @param endValue defines the end value
  4571. * @param gradient defines the gradient factor
  4572. * @param result defines the Matrix object where to store data
  4573. */
  4574. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4575. /**
  4576. * Builds a new matrix whose values are computed by:
  4577. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4578. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4579. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4580. * @param startValue defines the first matrix
  4581. * @param endValue defines the second matrix
  4582. * @param gradient defines the gradient between the two matrices
  4583. * @returns the new matrix
  4584. */
  4585. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4586. /**
  4587. * Update a matrix to values which are computed by:
  4588. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4589. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4590. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4591. * @param startValue defines the first matrix
  4592. * @param endValue defines the second matrix
  4593. * @param gradient defines the gradient between the two matrices
  4594. * @param result defines the target matrix
  4595. */
  4596. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * 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"
  4599. * This function works in left handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * 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".
  4608. * This function works in left handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * 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"
  4617. * This function works in right handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * 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".
  4626. * This function works in right handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param width defines the viewport width
  4636. * @param height defines the viewport height
  4637. * @param znear defines the near clip plane
  4638. * @param zfar defines the far clip plane
  4639. * @returns a new matrix as a left-handed orthographic projection matrix
  4640. */
  4641. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4642. /**
  4643. * Store a left-handed orthographic projection to a given matrix
  4644. * @param width defines the viewport width
  4645. * @param height defines the viewport height
  4646. * @param znear defines the near clip plane
  4647. * @param zfar defines the far clip plane
  4648. * @param result defines the target matrix
  4649. */
  4650. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param left defines the viewport left coordinate
  4654. * @param right defines the viewport right coordinate
  4655. * @param bottom defines the viewport bottom coordinate
  4656. * @param top defines the viewport top coordinate
  4657. * @param znear defines the near clip plane
  4658. * @param zfar defines the far clip plane
  4659. * @returns a new matrix as a left-handed orthographic projection matrix
  4660. */
  4661. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4662. /**
  4663. * Stores a left-handed orthographic projection into a given matrix
  4664. * @param left defines the viewport left coordinate
  4665. * @param right defines the viewport right coordinate
  4666. * @param bottom defines the viewport bottom coordinate
  4667. * @param top defines the viewport top coordinate
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Creates a right-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a right-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a right-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a left-handed perspective projection matrix
  4697. * @param width defines the viewport width
  4698. * @param height defines the viewport height
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a left-handed perspective projection matrix
  4702. */
  4703. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Creates a left-handed perspective projection matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @returns a new matrix as a left-handed perspective projection matrix
  4711. */
  4712. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4713. /**
  4714. * Stores a left-handed perspective projection into a given matrix
  4715. * @param fov defines the horizontal field of view
  4716. * @param aspect defines the aspect ratio
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4725. * @param fov defines the horizontal field of view
  4726. * @param aspect defines the aspect ratio
  4727. * @param znear defines the near clip plane
  4728. * @param zfar not used as infinity is used as far clip
  4729. * @param result defines the target matrix
  4730. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4731. */
  4732. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4733. /**
  4734. * Creates a right-handed perspective projection matrix
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @returns a new matrix as a right-handed perspective projection matrix
  4740. */
  4741. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4742. /**
  4743. * Stores a right-handed perspective projection into a given matrix
  4744. * @param fov defines the horizontal field of view
  4745. * @param aspect defines the aspect ratio
  4746. * @param znear defines the near clip plane
  4747. * @param zfar defines the far clip plane
  4748. * @param result defines the target matrix
  4749. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4750. */
  4751. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4752. /**
  4753. * Stores a right-handed perspective projection into a given matrix
  4754. * @param fov defines the horizontal field of view
  4755. * @param aspect defines the aspect ratio
  4756. * @param znear defines the near clip plane
  4757. * @param zfar not used as infinity is used as far clip
  4758. * @param result defines the target matrix
  4759. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4760. */
  4761. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4762. /**
  4763. * Stores a perspective projection for WebVR info a given matrix
  4764. * @param fov defines the field of view
  4765. * @param znear defines the near clip plane
  4766. * @param zfar defines the far clip plane
  4767. * @param result defines the target matrix
  4768. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4769. */
  4770. static PerspectiveFovWebVRToRef(fov: {
  4771. upDegrees: number;
  4772. downDegrees: number;
  4773. leftDegrees: number;
  4774. rightDegrees: number;
  4775. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4776. /**
  4777. * Computes a complete transformation matrix
  4778. * @param viewport defines the viewport to use
  4779. * @param world defines the world matrix
  4780. * @param view defines the view matrix
  4781. * @param projection defines the projection matrix
  4782. * @param zmin defines the near clip plane
  4783. * @param zmax defines the far clip plane
  4784. * @returns the transformation matrix
  4785. */
  4786. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4787. /**
  4788. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4789. * @param matrix defines the matrix to use
  4790. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4791. */
  4792. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4793. /**
  4794. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4795. * @param matrix defines the matrix to use
  4796. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4797. */
  4798. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4799. /**
  4800. * Compute the transpose of a given matrix
  4801. * @param matrix defines the matrix to transpose
  4802. * @returns the new matrix
  4803. */
  4804. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4805. /**
  4806. * Compute the transpose of a matrix and store it in a target matrix
  4807. * @param matrix defines the matrix to transpose
  4808. * @param result defines the target matrix
  4809. */
  4810. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4811. /**
  4812. * Computes a reflection matrix from a plane
  4813. * @param plane defines the reflection plane
  4814. * @returns a new matrix
  4815. */
  4816. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4817. /**
  4818. * Computes a reflection matrix from a plane
  4819. * @param plane defines the reflection plane
  4820. * @param result defines the target matrix
  4821. */
  4822. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4823. /**
  4824. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4825. * @param xaxis defines the value of the 1st axis
  4826. * @param yaxis defines the value of the 2nd axis
  4827. * @param zaxis defines the value of the 3rd axis
  4828. * @param result defines the target matrix
  4829. */
  4830. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4831. /**
  4832. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4833. * @param quat defines the quaternion to use
  4834. * @param result defines the target matrix
  4835. */
  4836. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4837. }
  4838. /**
  4839. * @hidden
  4840. */
  4841. export class TmpVectors {
  4842. static Vector2: Vector2[];
  4843. static Vector3: Vector3[];
  4844. static Vector4: Vector4[];
  4845. static Quaternion: Quaternion[];
  4846. static Matrix: Matrix[];
  4847. }
  4848. }
  4849. declare module BABYLON {
  4850. /**
  4851. * Defines potential orientation for back face culling
  4852. */
  4853. export enum Orientation {
  4854. /**
  4855. * Clockwise
  4856. */
  4857. CW = 0,
  4858. /** Counter clockwise */
  4859. CCW = 1
  4860. }
  4861. /** Class used to represent a Bezier curve */
  4862. export class BezierCurve {
  4863. /**
  4864. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4865. * @param t defines the time
  4866. * @param x1 defines the left coordinate on X axis
  4867. * @param y1 defines the left coordinate on Y axis
  4868. * @param x2 defines the right coordinate on X axis
  4869. * @param y2 defines the right coordinate on Y axis
  4870. * @returns the interpolated value
  4871. */
  4872. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4873. }
  4874. /**
  4875. * Defines angle representation
  4876. */
  4877. export class Angle {
  4878. private _radians;
  4879. /**
  4880. * Creates an Angle object of "radians" radians (float).
  4881. * @param radians the angle in radians
  4882. */
  4883. constructor(radians: number);
  4884. /**
  4885. * Get value in degrees
  4886. * @returns the Angle value in degrees (float)
  4887. */
  4888. degrees(): number;
  4889. /**
  4890. * Get value in radians
  4891. * @returns the Angle value in radians (float)
  4892. */
  4893. radians(): number;
  4894. /**
  4895. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4896. * @param a defines first point as the origin
  4897. * @param b defines point
  4898. * @returns a new Angle
  4899. */
  4900. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4901. /**
  4902. * Gets a new Angle object from the given float in radians
  4903. * @param radians defines the angle value in radians
  4904. * @returns a new Angle
  4905. */
  4906. static FromRadians(radians: number): Angle;
  4907. /**
  4908. * Gets a new Angle object from the given float in degrees
  4909. * @param degrees defines the angle value in degrees
  4910. * @returns a new Angle
  4911. */
  4912. static FromDegrees(degrees: number): Angle;
  4913. }
  4914. /**
  4915. * This represents an arc in a 2d space.
  4916. */
  4917. export class Arc2 {
  4918. /** Defines the start point of the arc */
  4919. startPoint: Vector2;
  4920. /** Defines the mid point of the arc */
  4921. midPoint: Vector2;
  4922. /** Defines the end point of the arc */
  4923. endPoint: Vector2;
  4924. /**
  4925. * Defines the center point of the arc.
  4926. */
  4927. centerPoint: Vector2;
  4928. /**
  4929. * Defines the radius of the arc.
  4930. */
  4931. radius: number;
  4932. /**
  4933. * Defines the angle of the arc (from mid point to end point).
  4934. */
  4935. angle: Angle;
  4936. /**
  4937. * Defines the start angle of the arc (from start point to middle point).
  4938. */
  4939. startAngle: Angle;
  4940. /**
  4941. * Defines the orientation of the arc (clock wise/counter clock wise).
  4942. */
  4943. orientation: Orientation;
  4944. /**
  4945. * Creates an Arc object from the three given points : start, middle and end.
  4946. * @param startPoint Defines the start point of the arc
  4947. * @param midPoint Defines the midlle point of the arc
  4948. * @param endPoint Defines the end point of the arc
  4949. */
  4950. constructor(
  4951. /** Defines the start point of the arc */
  4952. startPoint: Vector2,
  4953. /** Defines the mid point of the arc */
  4954. midPoint: Vector2,
  4955. /** Defines the end point of the arc */
  4956. endPoint: Vector2);
  4957. }
  4958. /**
  4959. * Represents a 2D path made up of multiple 2D points
  4960. */
  4961. export class Path2 {
  4962. private _points;
  4963. private _length;
  4964. /**
  4965. * If the path start and end point are the same
  4966. */
  4967. closed: boolean;
  4968. /**
  4969. * Creates a Path2 object from the starting 2D coordinates x and y.
  4970. * @param x the starting points x value
  4971. * @param y the starting points y value
  4972. */
  4973. constructor(x: number, y: number);
  4974. /**
  4975. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4976. * @param x the added points x value
  4977. * @param y the added points y value
  4978. * @returns the updated Path2.
  4979. */
  4980. addLineTo(x: number, y: number): Path2;
  4981. /**
  4982. * 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.
  4983. * @param midX middle point x value
  4984. * @param midY middle point y value
  4985. * @param endX end point x value
  4986. * @param endY end point y value
  4987. * @param numberOfSegments (default: 36)
  4988. * @returns the updated Path2.
  4989. */
  4990. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4991. /**
  4992. * Closes the Path2.
  4993. * @returns the Path2.
  4994. */
  4995. close(): Path2;
  4996. /**
  4997. * Gets the sum of the distance between each sequential point in the path
  4998. * @returns the Path2 total length (float).
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Gets the points which construct the path
  5003. * @returns the Path2 internal array of points.
  5004. */
  5005. getPoints(): Vector2[];
  5006. /**
  5007. * Retreives the point at the distance aways from the starting point
  5008. * @param normalizedLengthPosition the length along the path to retreive the point from
  5009. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5010. */
  5011. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5012. /**
  5013. * Creates a new path starting from an x and y position
  5014. * @param x starting x value
  5015. * @param y starting y value
  5016. * @returns a new Path2 starting at the coordinates (x, y).
  5017. */
  5018. static StartingAt(x: number, y: number): Path2;
  5019. }
  5020. /**
  5021. * Represents a 3D path made up of multiple 3D points
  5022. */
  5023. export class Path3D {
  5024. /**
  5025. * an array of Vector3, the curve axis of the Path3D
  5026. */
  5027. path: Vector3[];
  5028. private _curve;
  5029. private _distances;
  5030. private _tangents;
  5031. private _normals;
  5032. private _binormals;
  5033. private _raw;
  5034. private _alignTangentsWithPath;
  5035. private readonly _pointAtData;
  5036. /**
  5037. * new Path3D(path, normal, raw)
  5038. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5039. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5040. * @param path an array of Vector3, the curve axis of the Path3D
  5041. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5042. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5043. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5044. */
  5045. constructor(
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5050. /**
  5051. * Returns the Path3D array of successive Vector3 designing its curve.
  5052. * @returns the Path3D array of successive Vector3 designing its curve.
  5053. */
  5054. getCurve(): Vector3[];
  5055. /**
  5056. * Returns the Path3D array of successive Vector3 designing its curve.
  5057. * @returns the Path3D array of successive Vector3 designing its curve.
  5058. */
  5059. getPoints(): Vector3[];
  5060. /**
  5061. * @returns the computed length (float) of the path.
  5062. */
  5063. length(): number;
  5064. /**
  5065. * Returns an array populated with tangent vectors on each Path3D curve point.
  5066. * @returns an array populated with tangent vectors on each Path3D curve point.
  5067. */
  5068. getTangents(): Vector3[];
  5069. /**
  5070. * Returns an array populated with normal vectors on each Path3D curve point.
  5071. * @returns an array populated with normal vectors on each Path3D curve point.
  5072. */
  5073. getNormals(): Vector3[];
  5074. /**
  5075. * Returns an array populated with binormal vectors on each Path3D curve point.
  5076. * @returns an array populated with binormal vectors on each Path3D curve point.
  5077. */
  5078. getBinormals(): Vector3[];
  5079. /**
  5080. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5081. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5082. */
  5083. getDistances(): number[];
  5084. /**
  5085. * Returns an interpolated point along this path
  5086. * @param position the position of the point along this path, from 0.0 to 1.0
  5087. * @returns a new Vector3 as the point
  5088. */
  5089. getPointAt(position: number): Vector3;
  5090. /**
  5091. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5092. * @param position the position of the point along this path, from 0.0 to 1.0
  5093. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5094. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5095. */
  5096. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5097. /**
  5098. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5099. * @param position the position of the point along this path, from 0.0 to 1.0
  5100. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5101. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5102. */
  5103. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5104. /**
  5105. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5108. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5109. */
  5110. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5111. /**
  5112. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5113. * @param position the position of the point along this path, from 0.0 to 1.0
  5114. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5115. */
  5116. getDistanceAt(position: number): number;
  5117. /**
  5118. * Returns the array index of the previous point of an interpolated point along this path
  5119. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5120. * @returns the array index
  5121. */
  5122. getPreviousPointIndexAt(position: number): number;
  5123. /**
  5124. * 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)
  5125. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5126. * @returns the sub position
  5127. */
  5128. getSubPositionAt(position: number): number;
  5129. /**
  5130. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5131. * @param target the vector of which to get the closest position to
  5132. * @returns the position of the closest virtual point on this path to the target vector
  5133. */
  5134. getClosestPositionTo(target: Vector3): number;
  5135. /**
  5136. * Returns a sub path (slice) of this path
  5137. * @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
  5138. * @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
  5139. * @returns a sub path (slice) of this path
  5140. */
  5141. slice(start?: number, end?: number): Path3D;
  5142. /**
  5143. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5144. * @param path path which all values are copied into the curves points
  5145. * @param firstNormal which should be projected onto the curve
  5146. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5147. * @returns the same object updated.
  5148. */
  5149. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5150. private _compute;
  5151. private _getFirstNonNullVector;
  5152. private _getLastNonNullVector;
  5153. private _normalVector;
  5154. /**
  5155. * Updates the point at data for an interpolated point along this curve
  5156. * @param position the position of the point along this curve, from 0.0 to 1.0
  5157. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5158. * @returns the (updated) point at data
  5159. */
  5160. private _updatePointAtData;
  5161. /**
  5162. * Updates the point at data from the specified parameters
  5163. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5164. * @param point the interpolated point
  5165. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5166. */
  5167. private _setPointAtData;
  5168. /**
  5169. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5170. */
  5171. private _updateInterpolationMatrix;
  5172. }
  5173. /**
  5174. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5175. * A Curve3 is designed from a series of successive Vector3.
  5176. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5177. */
  5178. export class Curve3 {
  5179. private _points;
  5180. private _length;
  5181. /**
  5182. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5183. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5184. * @param v1 (Vector3) the control point
  5185. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5186. * @param nbPoints (integer) the wanted number of points in the curve
  5187. * @returns the created Curve3
  5188. */
  5189. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5190. /**
  5191. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5192. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5193. * @param v1 (Vector3) the first control point
  5194. * @param v2 (Vector3) the second control point
  5195. * @param v3 (Vector3) the end point of the Cubic Bezier
  5196. * @param nbPoints (integer) the wanted number of points in the curve
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5200. /**
  5201. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5202. * @param p1 (Vector3) the origin point of the Hermite Spline
  5203. * @param t1 (Vector3) the tangent vector at the origin point
  5204. * @param p2 (Vector3) the end point of the Hermite Spline
  5205. * @param t2 (Vector3) the tangent vector at the end point
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a CatmullRom Spline curve :
  5212. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5213. * @param nbPoints (integer) the wanted number of points between each curve control points
  5214. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5215. * @returns the created Curve3
  5216. */
  5217. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5218. /**
  5219. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5220. * A Curve3 is designed from a series of successive Vector3.
  5221. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5222. * @param points points which make up the curve
  5223. */
  5224. constructor(points: Vector3[]);
  5225. /**
  5226. * @returns the Curve3 stored array of successive Vector3
  5227. */
  5228. getPoints(): Vector3[];
  5229. /**
  5230. * @returns the computed length (float) of the curve.
  5231. */
  5232. length(): number;
  5233. /**
  5234. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5235. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5236. * curveA and curveB keep unchanged.
  5237. * @param curve the curve to continue from this curve
  5238. * @returns the newly constructed curve
  5239. */
  5240. continue(curve: DeepImmutable<Curve3>): Curve3;
  5241. private _computeLength;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This represents the main contract an easing function should follow.
  5247. * Easing functions are used throughout the animation system.
  5248. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export interface IEasingFunction {
  5251. /**
  5252. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5253. * of the easing function.
  5254. * The link below provides some of the most common examples of easing functions.
  5255. * @see https://easings.net/
  5256. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5257. * @returns the corresponding value on the curve defined by the easing function
  5258. */
  5259. ease(gradient: number): number;
  5260. }
  5261. /**
  5262. * Base class used for every default easing function.
  5263. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5264. */
  5265. export class EasingFunction implements IEasingFunction {
  5266. /**
  5267. * Interpolation follows the mathematical formula associated with the easing function.
  5268. */
  5269. static readonly EASINGMODE_EASEIN: number;
  5270. /**
  5271. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5272. */
  5273. static readonly EASINGMODE_EASEOUT: number;
  5274. /**
  5275. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5276. */
  5277. static readonly EASINGMODE_EASEINOUT: number;
  5278. private _easingMode;
  5279. /**
  5280. * Sets the easing mode of the current function.
  5281. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5282. */
  5283. setEasingMode(easingMode: number): void;
  5284. /**
  5285. * Gets the current easing mode.
  5286. * @returns the easing mode
  5287. */
  5288. getEasingMode(): number;
  5289. /**
  5290. * @hidden
  5291. */
  5292. easeInCore(gradient: number): number;
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corresponding value
  5295. * of the easing function.
  5296. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5297. * @returns the corresponding value on the curve defined by the easing function
  5298. */
  5299. ease(gradient: number): number;
  5300. }
  5301. /**
  5302. * Easing function with a circle shape (see link below).
  5303. * @see https://easings.net/#easeInCirc
  5304. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5305. */
  5306. export class CircleEase extends EasingFunction implements IEasingFunction {
  5307. /** @hidden */
  5308. easeInCore(gradient: number): number;
  5309. }
  5310. /**
  5311. * Easing function with a ease back shape (see link below).
  5312. * @see https://easings.net/#easeInBack
  5313. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5314. */
  5315. export class BackEase extends EasingFunction implements IEasingFunction {
  5316. /** Defines the amplitude of the function */
  5317. amplitude: number;
  5318. /**
  5319. * Instantiates a back ease easing
  5320. * @see https://easings.net/#easeInBack
  5321. * @param amplitude Defines the amplitude of the function
  5322. */
  5323. constructor(
  5324. /** Defines the amplitude of the function */
  5325. amplitude?: number);
  5326. /** @hidden */
  5327. easeInCore(gradient: number): number;
  5328. }
  5329. /**
  5330. * Easing function with a bouncing shape (see link below).
  5331. * @see https://easings.net/#easeInBounce
  5332. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5333. */
  5334. export class BounceEase extends EasingFunction implements IEasingFunction {
  5335. /** Defines the number of bounces */
  5336. bounces: number;
  5337. /** Defines the amplitude of the bounce */
  5338. bounciness: number;
  5339. /**
  5340. * Instantiates a bounce easing
  5341. * @see https://easings.net/#easeInBounce
  5342. * @param bounces Defines the number of bounces
  5343. * @param bounciness Defines the amplitude of the bounce
  5344. */
  5345. constructor(
  5346. /** Defines the number of bounces */
  5347. bounces?: number,
  5348. /** Defines the amplitude of the bounce */
  5349. bounciness?: number);
  5350. /** @hidden */
  5351. easeInCore(gradient: number): number;
  5352. }
  5353. /**
  5354. * Easing function with a power of 3 shape (see link below).
  5355. * @see https://easings.net/#easeInCubic
  5356. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5357. */
  5358. export class CubicEase extends EasingFunction implements IEasingFunction {
  5359. /** @hidden */
  5360. easeInCore(gradient: number): number;
  5361. }
  5362. /**
  5363. * Easing function with an elastic shape (see link below).
  5364. * @see https://easings.net/#easeInElastic
  5365. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5366. */
  5367. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5368. /** Defines the number of oscillations*/
  5369. oscillations: number;
  5370. /** Defines the amplitude of the oscillations*/
  5371. springiness: number;
  5372. /**
  5373. * Instantiates an elastic easing function
  5374. * @see https://easings.net/#easeInElastic
  5375. * @param oscillations Defines the number of oscillations
  5376. * @param springiness Defines the amplitude of the oscillations
  5377. */
  5378. constructor(
  5379. /** Defines the number of oscillations*/
  5380. oscillations?: number,
  5381. /** Defines the amplitude of the oscillations*/
  5382. springiness?: number);
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with an exponential shape (see link below).
  5388. * @see https://easings.net/#easeInExpo
  5389. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the exponent of the function */
  5393. exponent: number;
  5394. /**
  5395. * Instantiates an exponential easing function
  5396. * @see https://easings.net/#easeInExpo
  5397. * @param exponent Defines the exponent of the function
  5398. */
  5399. constructor(
  5400. /** Defines the exponent of the function */
  5401. exponent?: number);
  5402. /** @hidden */
  5403. easeInCore(gradient: number): number;
  5404. }
  5405. /**
  5406. * Easing function with a power shape (see link below).
  5407. * @see https://easings.net/#easeInQuad
  5408. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5409. */
  5410. export class PowerEase extends EasingFunction implements IEasingFunction {
  5411. /** Defines the power of the function */
  5412. power: number;
  5413. /**
  5414. * Instantiates an power base easing function
  5415. * @see https://easings.net/#easeInQuad
  5416. * @param power Defines the power of the function
  5417. */
  5418. constructor(
  5419. /** Defines the power of the function */
  5420. power?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 2 shape (see link below).
  5426. * @see https://easings.net/#easeInQuad
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a power of 4 shape (see link below).
  5435. * @see https://easings.net/#easeInQuart
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a power of 5 shape (see link below).
  5444. * @see https://easings.net/#easeInQuint
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5448. /** @hidden */
  5449. easeInCore(gradient: number): number;
  5450. }
  5451. /**
  5452. * Easing function with a sin shape (see link below).
  5453. * @see https://easings.net/#easeInSine
  5454. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5455. */
  5456. export class SineEase extends EasingFunction implements IEasingFunction {
  5457. /** @hidden */
  5458. easeInCore(gradient: number): number;
  5459. }
  5460. /**
  5461. * Easing function with a bezier shape (see link below).
  5462. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5463. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5464. */
  5465. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5466. /** Defines the x component of the start tangent in the bezier curve */
  5467. x1: number;
  5468. /** Defines the y component of the start tangent in the bezier curve */
  5469. y1: number;
  5470. /** Defines the x component of the end tangent in the bezier curve */
  5471. x2: number;
  5472. /** Defines the y component of the end tangent in the bezier curve */
  5473. y2: number;
  5474. /**
  5475. * Instantiates a bezier function
  5476. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5477. * @param x1 Defines the x component of the start tangent in the bezier curve
  5478. * @param y1 Defines the y component of the start tangent in the bezier curve
  5479. * @param x2 Defines the x component of the end tangent in the bezier curve
  5480. * @param y2 Defines the y component of the end tangent in the bezier curve
  5481. */
  5482. constructor(
  5483. /** Defines the x component of the start tangent in the bezier curve */
  5484. x1?: number,
  5485. /** Defines the y component of the start tangent in the bezier curve */
  5486. y1?: number,
  5487. /** Defines the x component of the end tangent in the bezier curve */
  5488. x2?: number,
  5489. /** Defines the y component of the end tangent in the bezier curve */
  5490. y2?: number);
  5491. /** @hidden */
  5492. easeInCore(gradient: number): number;
  5493. }
  5494. }
  5495. declare module BABYLON {
  5496. /**
  5497. * Class used to hold a RBG color
  5498. */
  5499. export class Color3 {
  5500. /**
  5501. * Defines the red component (between 0 and 1, default is 0)
  5502. */
  5503. r: number;
  5504. /**
  5505. * Defines the green component (between 0 and 1, default is 0)
  5506. */
  5507. g: number;
  5508. /**
  5509. * Defines the blue component (between 0 and 1, default is 0)
  5510. */
  5511. b: number;
  5512. /**
  5513. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5514. * @param r defines the red component (between 0 and 1, default is 0)
  5515. * @param g defines the green component (between 0 and 1, default is 0)
  5516. * @param b defines the blue component (between 0 and 1, default is 0)
  5517. */
  5518. constructor(
  5519. /**
  5520. * Defines the red component (between 0 and 1, default is 0)
  5521. */
  5522. r?: number,
  5523. /**
  5524. * Defines the green component (between 0 and 1, default is 0)
  5525. */
  5526. g?: number,
  5527. /**
  5528. * Defines the blue component (between 0 and 1, default is 0)
  5529. */
  5530. b?: number);
  5531. /**
  5532. * Creates a string with the Color3 current values
  5533. * @returns the string representation of the Color3 object
  5534. */
  5535. toString(): string;
  5536. /**
  5537. * Returns the string "Color3"
  5538. * @returns "Color3"
  5539. */
  5540. getClassName(): string;
  5541. /**
  5542. * Compute the Color3 hash code
  5543. * @returns an unique number that can be used to hash Color3 objects
  5544. */
  5545. getHashCode(): number;
  5546. /**
  5547. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5548. * @param array defines the array where to store the r,g,b components
  5549. * @param index defines an optional index in the target array to define where to start storing values
  5550. * @returns the current Color3 object
  5551. */
  5552. toArray(array: FloatArray, index?: number): Color3;
  5553. /**
  5554. * Update the current color with values stored in an array from the starting index of the given array
  5555. * @param array defines the source array
  5556. * @param offset defines an offset in the source array
  5557. * @returns the current Color3 object
  5558. */
  5559. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5560. /**
  5561. * Returns a new Color4 object from the current Color3 and the given alpha
  5562. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5563. * @returns a new Color4 object
  5564. */
  5565. toColor4(alpha?: number): Color4;
  5566. /**
  5567. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5568. * @returns the new array
  5569. */
  5570. asArray(): number[];
  5571. /**
  5572. * Returns the luminance value
  5573. * @returns a float value
  5574. */
  5575. toLuminance(): number;
  5576. /**
  5577. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5578. * @param otherColor defines the second operand
  5579. * @returns the new Color3 object
  5580. */
  5581. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5582. /**
  5583. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5584. * @param otherColor defines the second operand
  5585. * @param result defines the Color3 object where to store the result
  5586. * @returns the current Color3
  5587. */
  5588. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5589. /**
  5590. * Determines equality between Color3 objects
  5591. * @param otherColor defines the second operand
  5592. * @returns true if the rgb values are equal to the given ones
  5593. */
  5594. equals(otherColor: DeepImmutable<Color3>): boolean;
  5595. /**
  5596. * Determines equality between the current Color3 object and a set of r,b,g values
  5597. * @param r defines the red component to check
  5598. * @param g defines the green component to check
  5599. * @param b defines the blue component to check
  5600. * @returns true if the rgb values are equal to the given ones
  5601. */
  5602. equalsFloats(r: number, g: number, b: number): boolean;
  5603. /**
  5604. * Multiplies in place each rgb value by scale
  5605. * @param scale defines the scaling factor
  5606. * @returns the updated Color3
  5607. */
  5608. scale(scale: number): Color3;
  5609. /**
  5610. * Multiplies the rgb values by scale and stores the result into "result"
  5611. * @param scale defines the scaling factor
  5612. * @param result defines the Color3 object where to store the result
  5613. * @returns the unmodified current Color3
  5614. */
  5615. scaleToRef(scale: number, result: Color3): Color3;
  5616. /**
  5617. * Scale the current Color3 values by a factor and add the result to a given Color3
  5618. * @param scale defines the scale factor
  5619. * @param result defines color to store the result into
  5620. * @returns the unmodified current Color3
  5621. */
  5622. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5623. /**
  5624. * Clamps the rgb values by the min and max values and stores the result into "result"
  5625. * @param min defines minimum clamping value (default is 0)
  5626. * @param max defines maximum clamping value (default is 1)
  5627. * @param result defines color to store the result into
  5628. * @returns the original Color3
  5629. */
  5630. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5631. /**
  5632. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5633. * @param otherColor defines the second operand
  5634. * @returns the new Color3
  5635. */
  5636. add(otherColor: DeepImmutable<Color3>): Color3;
  5637. /**
  5638. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5639. * @param otherColor defines the second operand
  5640. * @param result defines Color3 object to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5644. /**
  5645. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5646. * @param otherColor defines the second operand
  5647. * @returns the new Color3
  5648. */
  5649. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5652. * @param otherColor defines the second operand
  5653. * @param result defines Color3 object to store the result into
  5654. * @returns the unmodified current Color3
  5655. */
  5656. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5657. /**
  5658. * Copy the current object
  5659. * @returns a new Color3 copied the current one
  5660. */
  5661. clone(): Color3;
  5662. /**
  5663. * Copies the rgb values from the source in the current Color3
  5664. * @param source defines the source Color3 object
  5665. * @returns the updated Color3 object
  5666. */
  5667. copyFrom(source: DeepImmutable<Color3>): Color3;
  5668. /**
  5669. * Updates the Color3 rgb values from the given floats
  5670. * @param r defines the red component to read from
  5671. * @param g defines the green component to read from
  5672. * @param b defines the blue component to read from
  5673. * @returns the current Color3 object
  5674. */
  5675. copyFromFloats(r: number, g: number, b: number): Color3;
  5676. /**
  5677. * Updates the Color3 rgb values from the given floats
  5678. * @param r defines the red component to read from
  5679. * @param g defines the green component to read from
  5680. * @param b defines the blue component to read from
  5681. * @returns the current Color3 object
  5682. */
  5683. set(r: number, g: number, b: number): Color3;
  5684. /**
  5685. * Compute the Color3 hexadecimal code as a string
  5686. * @returns a string containing the hexadecimal representation of the Color3 object
  5687. */
  5688. toHexString(): string;
  5689. /**
  5690. * Computes a new Color3 converted from the current one to linear space
  5691. * @returns a new Color3 object
  5692. */
  5693. toLinearSpace(): Color3;
  5694. /**
  5695. * Converts current color in rgb space to HSV values
  5696. * @returns a new color3 representing the HSV values
  5697. */
  5698. toHSV(): Color3;
  5699. /**
  5700. * Converts current color in rgb space to HSV values
  5701. * @param result defines the Color3 where to store the HSV values
  5702. */
  5703. toHSVToRef(result: Color3): void;
  5704. /**
  5705. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5706. * @param convertedColor defines the Color3 object where to store the linear space version
  5707. * @returns the unmodified Color3
  5708. */
  5709. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to gamma space
  5712. * @returns a new Color3 object
  5713. */
  5714. toGammaSpace(): Color3;
  5715. /**
  5716. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5717. * @param convertedColor defines the Color3 object where to store the gamma space version
  5718. * @returns the unmodified Color3
  5719. */
  5720. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5721. private static _BlackReadOnly;
  5722. /**
  5723. * Convert Hue, saturation and value to a Color3 (RGB)
  5724. * @param hue defines the hue
  5725. * @param saturation defines the saturation
  5726. * @param value defines the value
  5727. * @param result defines the Color3 where to store the RGB values
  5728. */
  5729. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5730. /**
  5731. * Creates a new Color3 from the string containing valid hexadecimal values
  5732. * @param hex defines a string containing valid hexadecimal values
  5733. * @returns a new Color3 object
  5734. */
  5735. static FromHexString(hex: string): Color3;
  5736. /**
  5737. * Creates a new Color3 from the starting index of the given array
  5738. * @param array defines the source array
  5739. * @param offset defines an offset in the source array
  5740. * @returns a new Color3 object
  5741. */
  5742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5743. /**
  5744. * Creates a new Color3 from the starting index element of the given array
  5745. * @param array defines the source array to read from
  5746. * @param offset defines the offset in the source array
  5747. * @param result defines the target Color3 object
  5748. */
  5749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5750. /**
  5751. * Creates a new Color3 from integer values (< 256)
  5752. * @param r defines the red component to read from (value between 0 and 255)
  5753. * @param g defines the green component to read from (value between 0 and 255)
  5754. * @param b defines the blue component to read from (value between 0 and 255)
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromInts(r: number, g: number, b: number): Color3;
  5758. /**
  5759. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5760. * @param start defines the start Color3 value
  5761. * @param end defines the end Color3 value
  5762. * @param amount defines the gradient value between start and end
  5763. * @returns a new Color3 object
  5764. */
  5765. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5766. /**
  5767. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5768. * @param left defines the start value
  5769. * @param right defines the end value
  5770. * @param amount defines the gradient factor
  5771. * @param result defines the Color3 object where to store the result
  5772. */
  5773. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5774. /**
  5775. * Returns a Color3 value containing a red color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Red(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a green color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Green(): Color3;
  5784. /**
  5785. * Returns a Color3 value containing a blue color
  5786. * @returns a new Color3 object
  5787. */
  5788. static Blue(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a black color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Black(): Color3;
  5794. /**
  5795. * Gets a Color3 value containing a black color that must not be updated
  5796. */
  5797. static get BlackReadOnly(): DeepImmutable<Color3>;
  5798. /**
  5799. * Returns a Color3 value containing a white color
  5800. * @returns a new Color3 object
  5801. */
  5802. static White(): Color3;
  5803. /**
  5804. * Returns a Color3 value containing a purple color
  5805. * @returns a new Color3 object
  5806. */
  5807. static Purple(): Color3;
  5808. /**
  5809. * Returns a Color3 value containing a magenta color
  5810. * @returns a new Color3 object
  5811. */
  5812. static Magenta(): Color3;
  5813. /**
  5814. * Returns a Color3 value containing a yellow color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Yellow(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a gray color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Gray(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a teal color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Teal(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a random color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Random(): Color3;
  5833. }
  5834. /**
  5835. * Class used to hold a RBGA color
  5836. */
  5837. export class Color4 {
  5838. /**
  5839. * Defines the red component (between 0 and 1, default is 0)
  5840. */
  5841. r: number;
  5842. /**
  5843. * Defines the green component (between 0 and 1, default is 0)
  5844. */
  5845. g: number;
  5846. /**
  5847. * Defines the blue component (between 0 and 1, default is 0)
  5848. */
  5849. b: number;
  5850. /**
  5851. * Defines the alpha component (between 0 and 1, default is 1)
  5852. */
  5853. a: number;
  5854. /**
  5855. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5856. * @param r defines the red component (between 0 and 1, default is 0)
  5857. * @param g defines the green component (between 0 and 1, default is 0)
  5858. * @param b defines the blue component (between 0 and 1, default is 0)
  5859. * @param a defines the alpha component (between 0 and 1, default is 1)
  5860. */
  5861. constructor(
  5862. /**
  5863. * Defines the red component (between 0 and 1, default is 0)
  5864. */
  5865. r?: number,
  5866. /**
  5867. * Defines the green component (between 0 and 1, default is 0)
  5868. */
  5869. g?: number,
  5870. /**
  5871. * Defines the blue component (between 0 and 1, default is 0)
  5872. */
  5873. b?: number,
  5874. /**
  5875. * Defines the alpha component (between 0 and 1, default is 1)
  5876. */
  5877. a?: number);
  5878. /**
  5879. * Adds in place the given Color4 values to the current Color4 object
  5880. * @param right defines the second operand
  5881. * @returns the current updated Color4 object
  5882. */
  5883. addInPlace(right: DeepImmutable<Color4>): Color4;
  5884. /**
  5885. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5886. * @returns the new array
  5887. */
  5888. asArray(): number[];
  5889. /**
  5890. * Stores from the starting index in the given array the Color4 successive values
  5891. * @param array defines the array where to store the r,g,b components
  5892. * @param index defines an optional index in the target array to define where to start storing values
  5893. * @returns the current Color4 object
  5894. */
  5895. toArray(array: number[], index?: number): Color4;
  5896. /**
  5897. * Update the current color with values stored in an array from the starting index of the given array
  5898. * @param array defines the source array
  5899. * @param offset defines an offset in the source array
  5900. * @returns the current Color4 object
  5901. */
  5902. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5903. /**
  5904. * Determines equality between Color4 objects
  5905. * @param otherColor defines the second operand
  5906. * @returns true if the rgba values are equal to the given ones
  5907. */
  5908. equals(otherColor: DeepImmutable<Color4>): boolean;
  5909. /**
  5910. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5911. * @param right defines the second operand
  5912. * @returns a new Color4 object
  5913. */
  5914. add(right: DeepImmutable<Color4>): Color4;
  5915. /**
  5916. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5917. * @param right defines the second operand
  5918. * @returns a new Color4 object
  5919. */
  5920. subtract(right: DeepImmutable<Color4>): Color4;
  5921. /**
  5922. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5923. * @param right defines the second operand
  5924. * @param result defines the Color4 object where to store the result
  5925. * @returns the current Color4 object
  5926. */
  5927. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5928. /**
  5929. * Creates a new Color4 with the current Color4 values multiplied by scale
  5930. * @param scale defines the scaling factor to apply
  5931. * @returns a new Color4 object
  5932. */
  5933. scale(scale: number): Color4;
  5934. /**
  5935. * Multiplies the current Color4 values by scale and stores the result in "result"
  5936. * @param scale defines the scaling factor to apply
  5937. * @param result defines the Color4 object where to store the result
  5938. * @returns the current unmodified Color4
  5939. */
  5940. scaleToRef(scale: number, result: Color4): Color4;
  5941. /**
  5942. * Scale the current Color4 values by a factor and add the result to a given Color4
  5943. * @param scale defines the scale factor
  5944. * @param result defines the Color4 object where to store the result
  5945. * @returns the unmodified current Color4
  5946. */
  5947. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5948. /**
  5949. * Clamps the rgb values by the min and max values and stores the result into "result"
  5950. * @param min defines minimum clamping value (default is 0)
  5951. * @param max defines maximum clamping value (default is 1)
  5952. * @param result defines color to store the result into.
  5953. * @returns the cuurent Color4
  5954. */
  5955. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5956. /**
  5957. * Multipy an Color4 value by another and return a new Color4 object
  5958. * @param color defines the Color4 value to multiply by
  5959. * @returns a new Color4 object
  5960. */
  5961. multiply(color: Color4): Color4;
  5962. /**
  5963. * Multipy a Color4 value by another and push the result in a reference value
  5964. * @param color defines the Color4 value to multiply by
  5965. * @param result defines the Color4 to fill the result in
  5966. * @returns the result Color4
  5967. */
  5968. multiplyToRef(color: Color4, result: Color4): Color4;
  5969. /**
  5970. * Creates a string with the Color4 current values
  5971. * @returns the string representation of the Color4 object
  5972. */
  5973. toString(): string;
  5974. /**
  5975. * Returns the string "Color4"
  5976. * @returns "Color4"
  5977. */
  5978. getClassName(): string;
  5979. /**
  5980. * Compute the Color4 hash code
  5981. * @returns an unique number that can be used to hash Color4 objects
  5982. */
  5983. getHashCode(): number;
  5984. /**
  5985. * Creates a new Color4 copied from the current one
  5986. * @returns a new Color4 object
  5987. */
  5988. clone(): Color4;
  5989. /**
  5990. * Copies the given Color4 values into the current one
  5991. * @param source defines the source Color4 object
  5992. * @returns the current updated Color4 object
  5993. */
  5994. copyFrom(source: Color4): Color4;
  5995. /**
  5996. * Copies the given float values into the current one
  5997. * @param r defines the red component to read from
  5998. * @param g defines the green component to read from
  5999. * @param b defines the blue component to read from
  6000. * @param a defines the alpha component to read from
  6001. * @returns the current updated Color4 object
  6002. */
  6003. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6004. /**
  6005. * Copies the given float values into the current one
  6006. * @param r defines the red component to read from
  6007. * @param g defines the green component to read from
  6008. * @param b defines the blue component to read from
  6009. * @param a defines the alpha component to read from
  6010. * @returns the current updated Color4 object
  6011. */
  6012. set(r: number, g: number, b: number, a: number): Color4;
  6013. /**
  6014. * Compute the Color4 hexadecimal code as a string
  6015. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6016. * @returns a string containing the hexadecimal representation of the Color4 object
  6017. */
  6018. toHexString(returnAsColor3?: boolean): string;
  6019. /**
  6020. * Computes a new Color4 converted from the current one to linear space
  6021. * @returns a new Color4 object
  6022. */
  6023. toLinearSpace(): Color4;
  6024. /**
  6025. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6026. * @param convertedColor defines the Color4 object where to store the linear space version
  6027. * @returns the unmodified Color4
  6028. */
  6029. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6030. /**
  6031. * Computes a new Color4 converted from the current one to gamma space
  6032. * @returns a new Color4 object
  6033. */
  6034. toGammaSpace(): Color4;
  6035. /**
  6036. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6037. * @param convertedColor defines the Color4 object where to store the gamma space version
  6038. * @returns the unmodified Color4
  6039. */
  6040. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6041. /**
  6042. * Creates a new Color4 from the string containing valid hexadecimal values
  6043. * @param hex defines a string containing valid hexadecimal values
  6044. * @returns a new Color4 object
  6045. */
  6046. static FromHexString(hex: string): Color4;
  6047. /**
  6048. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6049. * @param left defines the start value
  6050. * @param right defines the end value
  6051. * @param amount defines the gradient factor
  6052. * @returns a new Color4 object
  6053. */
  6054. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6055. /**
  6056. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6057. * @param left defines the start value
  6058. * @param right defines the end value
  6059. * @param amount defines the gradient factor
  6060. * @param result defines the Color4 object where to store data
  6061. */
  6062. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6063. /**
  6064. * Creates a new Color4 from a Color3 and an alpha value
  6065. * @param color3 defines the source Color3 to read from
  6066. * @param alpha defines the alpha component (1.0 by default)
  6067. * @returns a new Color4 object
  6068. */
  6069. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6070. /**
  6071. * Creates a new Color4 from the starting index element of the given array
  6072. * @param array defines the source array to read from
  6073. * @param offset defines the offset in the source array
  6074. * @returns a new Color4 object
  6075. */
  6076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6077. /**
  6078. * Creates a new Color4 from the starting index element of the given array
  6079. * @param array defines the source array to read from
  6080. * @param offset defines the offset in the source array
  6081. * @param result defines the target Color4 object
  6082. */
  6083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6084. /**
  6085. * Creates a new Color3 from integer values (< 256)
  6086. * @param r defines the red component to read from (value between 0 and 255)
  6087. * @param g defines the green component to read from (value between 0 and 255)
  6088. * @param b defines the blue component to read from (value between 0 and 255)
  6089. * @param a defines the alpha component to read from (value between 0 and 255)
  6090. * @returns a new Color3 object
  6091. */
  6092. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6093. /**
  6094. * Check the content of a given array and convert it to an array containing RGBA data
  6095. * If the original array was already containing count * 4 values then it is returned directly
  6096. * @param colors defines the array to check
  6097. * @param count defines the number of RGBA data to expect
  6098. * @returns an array containing count * 4 values (RGBA)
  6099. */
  6100. static CheckColors4(colors: number[], count: number): number[];
  6101. }
  6102. /**
  6103. * @hidden
  6104. */
  6105. export class TmpColors {
  6106. static Color3: Color3[];
  6107. static Color4: Color4[];
  6108. }
  6109. }
  6110. declare module BABYLON {
  6111. /**
  6112. * Defines an interface which represents an animation key frame
  6113. */
  6114. export interface IAnimationKey {
  6115. /**
  6116. * Frame of the key frame
  6117. */
  6118. frame: number;
  6119. /**
  6120. * Value at the specifies key frame
  6121. */
  6122. value: any;
  6123. /**
  6124. * The input tangent for the cubic hermite spline
  6125. */
  6126. inTangent?: any;
  6127. /**
  6128. * The output tangent for the cubic hermite spline
  6129. */
  6130. outTangent?: any;
  6131. /**
  6132. * The animation interpolation type
  6133. */
  6134. interpolation?: AnimationKeyInterpolation;
  6135. }
  6136. /**
  6137. * Enum for the animation key frame interpolation type
  6138. */
  6139. export enum AnimationKeyInterpolation {
  6140. /**
  6141. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6142. */
  6143. STEP = 1
  6144. }
  6145. }
  6146. declare module BABYLON {
  6147. /**
  6148. * Represents the range of an animation
  6149. */
  6150. export class AnimationRange {
  6151. /**The name of the animation range**/
  6152. name: string;
  6153. /**The starting frame of the animation */
  6154. from: number;
  6155. /**The ending frame of the animation*/
  6156. to: number;
  6157. /**
  6158. * Initializes the range of an animation
  6159. * @param name The name of the animation range
  6160. * @param from The starting frame of the animation
  6161. * @param to The ending frame of the animation
  6162. */
  6163. constructor(
  6164. /**The name of the animation range**/
  6165. name: string,
  6166. /**The starting frame of the animation */
  6167. from: number,
  6168. /**The ending frame of the animation*/
  6169. to: number);
  6170. /**
  6171. * Makes a copy of the animation range
  6172. * @returns A copy of the animation range
  6173. */
  6174. clone(): AnimationRange;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Composed of a frame, and an action function
  6180. */
  6181. export class AnimationEvent {
  6182. /** The frame for which the event is triggered **/
  6183. frame: number;
  6184. /** The event to perform when triggered **/
  6185. action: (currentFrame: number) => void;
  6186. /** Specifies if the event should be triggered only once**/
  6187. onlyOnce?: boolean | undefined;
  6188. /**
  6189. * Specifies if the animation event is done
  6190. */
  6191. isDone: boolean;
  6192. /**
  6193. * Initializes the animation event
  6194. * @param frame The frame for which the event is triggered
  6195. * @param action The event to perform when triggered
  6196. * @param onlyOnce Specifies if the event should be triggered only once
  6197. */
  6198. constructor(
  6199. /** The frame for which the event is triggered **/
  6200. frame: number,
  6201. /** The event to perform when triggered **/
  6202. action: (currentFrame: number) => void,
  6203. /** Specifies if the event should be triggered only once**/
  6204. onlyOnce?: boolean | undefined);
  6205. /** @hidden */
  6206. _clone(): AnimationEvent;
  6207. }
  6208. }
  6209. declare module BABYLON {
  6210. /**
  6211. * Interface used to define a behavior
  6212. */
  6213. export interface Behavior<T> {
  6214. /** gets or sets behavior's name */
  6215. name: string;
  6216. /**
  6217. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6218. */
  6219. init(): void;
  6220. /**
  6221. * Called when the behavior is attached to a target
  6222. * @param target defines the target where the behavior is attached to
  6223. */
  6224. attach(target: T): void;
  6225. /**
  6226. * Called when the behavior is detached from its target
  6227. */
  6228. detach(): void;
  6229. }
  6230. /**
  6231. * Interface implemented by classes supporting behaviors
  6232. */
  6233. export interface IBehaviorAware<T> {
  6234. /**
  6235. * Attach a behavior
  6236. * @param behavior defines the behavior to attach
  6237. * @returns the current host
  6238. */
  6239. addBehavior(behavior: Behavior<T>): T;
  6240. /**
  6241. * Remove a behavior from the current object
  6242. * @param behavior defines the behavior to detach
  6243. * @returns the current host
  6244. */
  6245. removeBehavior(behavior: Behavior<T>): T;
  6246. /**
  6247. * Gets a behavior using its name to search
  6248. * @param name defines the name to search
  6249. * @returns the behavior or null if not found
  6250. */
  6251. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6252. }
  6253. }
  6254. declare module BABYLON {
  6255. /**
  6256. * Defines an array and its length.
  6257. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6258. */
  6259. export interface ISmartArrayLike<T> {
  6260. /**
  6261. * The data of the array.
  6262. */
  6263. data: Array<T>;
  6264. /**
  6265. * The active length of the array.
  6266. */
  6267. length: number;
  6268. }
  6269. /**
  6270. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6271. */
  6272. export class SmartArray<T> implements ISmartArrayLike<T> {
  6273. /**
  6274. * The full set of data from the array.
  6275. */
  6276. data: Array<T>;
  6277. /**
  6278. * The active length of the array.
  6279. */
  6280. length: number;
  6281. protected _id: number;
  6282. /**
  6283. * Instantiates a Smart Array.
  6284. * @param capacity defines the default capacity of the array.
  6285. */
  6286. constructor(capacity: number);
  6287. /**
  6288. * Pushes a value at the end of the active data.
  6289. * @param value defines the object to push in the array.
  6290. */
  6291. push(value: T): void;
  6292. /**
  6293. * Iterates over the active data and apply the lambda to them.
  6294. * @param func defines the action to apply on each value.
  6295. */
  6296. forEach(func: (content: T) => void): void;
  6297. /**
  6298. * Sorts the full sets of data.
  6299. * @param compareFn defines the comparison function to apply.
  6300. */
  6301. sort(compareFn: (a: T, b: T) => number): void;
  6302. /**
  6303. * Resets the active data to an empty array.
  6304. */
  6305. reset(): void;
  6306. /**
  6307. * Releases all the data from the array as well as the array.
  6308. */
  6309. dispose(): void;
  6310. /**
  6311. * Concats the active data with a given array.
  6312. * @param array defines the data to concatenate with.
  6313. */
  6314. concat(array: any): void;
  6315. /**
  6316. * Returns the position of a value in the active data.
  6317. * @param value defines the value to find the index for
  6318. * @returns the index if found in the active data otherwise -1
  6319. */
  6320. indexOf(value: T): number;
  6321. /**
  6322. * Returns whether an element is part of the active data.
  6323. * @param value defines the value to look for
  6324. * @returns true if found in the active data otherwise false
  6325. */
  6326. contains(value: T): boolean;
  6327. private static _GlobalId;
  6328. }
  6329. /**
  6330. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6331. * The data in this array can only be present once
  6332. */
  6333. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6334. private _duplicateId;
  6335. /**
  6336. * Pushes a value at the end of the active data.
  6337. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6338. * @param value defines the object to push in the array.
  6339. */
  6340. push(value: T): void;
  6341. /**
  6342. * Pushes a value at the end of the active data.
  6343. * If the data is already present, it won t be added again
  6344. * @param value defines the object to push in the array.
  6345. * @returns true if added false if it was already present
  6346. */
  6347. pushNoDuplicate(value: T): boolean;
  6348. /**
  6349. * Resets the active data to an empty array.
  6350. */
  6351. reset(): void;
  6352. /**
  6353. * Concats the active data with a given array.
  6354. * This ensures no dupplicate will be present in the result.
  6355. * @param array defines the data to concatenate with.
  6356. */
  6357. concatWithNoDuplicate(array: any): void;
  6358. }
  6359. }
  6360. declare module BABYLON {
  6361. /**
  6362. * @ignore
  6363. * This is a list of all the different input types that are available in the application.
  6364. * Fo instance: ArcRotateCameraGamepadInput...
  6365. */
  6366. export var CameraInputTypes: {};
  6367. /**
  6368. * This is the contract to implement in order to create a new input class.
  6369. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6370. */
  6371. export interface ICameraInput<TCamera extends Camera> {
  6372. /**
  6373. * Defines the camera the input is attached to.
  6374. */
  6375. camera: Nullable<TCamera>;
  6376. /**
  6377. * Gets the class name of the current intput.
  6378. * @returns the class name
  6379. */
  6380. getClassName(): string;
  6381. /**
  6382. * Get the friendly name associated with the input class.
  6383. * @returns the input friendly name
  6384. */
  6385. getSimpleName(): string;
  6386. /**
  6387. * Attach the input controls to a specific dom element to get the input from.
  6388. * @param element Defines the element the controls should be listened from
  6389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6390. */
  6391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6392. /**
  6393. * Detach the current controls from the specified dom element.
  6394. * @param element Defines the element to stop listening the inputs from
  6395. */
  6396. detachControl(element: Nullable<HTMLElement>): void;
  6397. /**
  6398. * Update the current camera state depending on the inputs that have been used this frame.
  6399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6400. */
  6401. checkInputs?: () => void;
  6402. }
  6403. /**
  6404. * Represents a map of input types to input instance or input index to input instance.
  6405. */
  6406. export interface CameraInputsMap<TCamera extends Camera> {
  6407. /**
  6408. * Accessor to the input by input type.
  6409. */
  6410. [name: string]: ICameraInput<TCamera>;
  6411. /**
  6412. * Accessor to the input by input index.
  6413. */
  6414. [idx: number]: ICameraInput<TCamera>;
  6415. }
  6416. /**
  6417. * This represents the input manager used within a camera.
  6418. * It helps dealing with all the different kind of input attached to a camera.
  6419. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6420. */
  6421. export class CameraInputsManager<TCamera extends Camera> {
  6422. /**
  6423. * Defines the list of inputs attahed to the camera.
  6424. */
  6425. attached: CameraInputsMap<TCamera>;
  6426. /**
  6427. * Defines the dom element the camera is collecting inputs from.
  6428. * This is null if the controls have not been attached.
  6429. */
  6430. attachedElement: Nullable<HTMLElement>;
  6431. /**
  6432. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6433. */
  6434. noPreventDefault: boolean;
  6435. /**
  6436. * Defined the camera the input manager belongs to.
  6437. */
  6438. camera: TCamera;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs: () => void;
  6444. /**
  6445. * Instantiate a new Camera Input Manager.
  6446. * @param camera Defines the camera the input manager blongs to
  6447. */
  6448. constructor(camera: TCamera);
  6449. /**
  6450. * Add an input method to a camera
  6451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6452. * @param input camera input method
  6453. */
  6454. add(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Remove a specific input method from a camera
  6457. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6458. * @param inputToRemove camera input method
  6459. */
  6460. remove(inputToRemove: ICameraInput<TCamera>): void;
  6461. /**
  6462. * Remove a specific input type from a camera
  6463. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6464. * @param inputType the type of the input to remove
  6465. */
  6466. removeByType(inputType: string): void;
  6467. private _addCheckInputs;
  6468. /**
  6469. * Attach the input controls to the currently attached dom element to listen the events from.
  6470. * @param input Defines the input to attach
  6471. */
  6472. attachInput(input: ICameraInput<TCamera>): void;
  6473. /**
  6474. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6475. * @param element Defines the dom element to collect the events from
  6476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6477. */
  6478. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6479. /**
  6480. * Detach the current manager inputs controls from a specific dom element.
  6481. * @param element Defines the dom element to collect the events from
  6482. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6483. */
  6484. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6485. /**
  6486. * Rebuild the dynamic inputCheck function from the current list of
  6487. * defined inputs in the manager.
  6488. */
  6489. rebuildInputCheck(): void;
  6490. /**
  6491. * Remove all attached input methods from a camera
  6492. */
  6493. clear(): void;
  6494. /**
  6495. * Serialize the current input manager attached to a camera.
  6496. * This ensures than once parsed,
  6497. * the input associated to the camera will be identical to the current ones
  6498. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6499. */
  6500. serialize(serializedCamera: any): void;
  6501. /**
  6502. * Parses an input manager serialized JSON to restore the previous list of inputs
  6503. * and states associated to a camera.
  6504. * @param parsedCamera Defines the JSON to parse
  6505. */
  6506. parse(parsedCamera: any): void;
  6507. }
  6508. }
  6509. declare module BABYLON {
  6510. /**
  6511. * Class used to store data that will be store in GPU memory
  6512. */
  6513. export class Buffer {
  6514. private _engine;
  6515. private _buffer;
  6516. /** @hidden */
  6517. _data: Nullable<DataArray>;
  6518. private _updatable;
  6519. private _instanced;
  6520. private _divisor;
  6521. /**
  6522. * Gets the byte stride.
  6523. */
  6524. readonly byteStride: number;
  6525. /**
  6526. * Constructor
  6527. * @param engine the engine
  6528. * @param data the data to use for this buffer
  6529. * @param updatable whether the data is updatable
  6530. * @param stride the stride (optional)
  6531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6532. * @param instanced whether the buffer is instanced (optional)
  6533. * @param useBytes set to true if the stride in in bytes (optional)
  6534. * @param divisor sets an optional divisor for instances (1 by default)
  6535. */
  6536. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6537. /**
  6538. * Create a new VertexBuffer based on the current buffer
  6539. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6540. * @param offset defines offset in the buffer (0 by default)
  6541. * @param size defines the size in floats of attributes (position is 3 for instance)
  6542. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6543. * @param instanced defines if the vertex buffer contains indexed data
  6544. * @param useBytes defines if the offset and stride are in bytes *
  6545. * @param divisor sets an optional divisor for instances (1 by default)
  6546. * @returns the new vertex buffer
  6547. */
  6548. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6549. /**
  6550. * Gets a boolean indicating if the Buffer is updatable?
  6551. * @returns true if the buffer is updatable
  6552. */
  6553. isUpdatable(): boolean;
  6554. /**
  6555. * Gets current buffer's data
  6556. * @returns a DataArray or null
  6557. */
  6558. getData(): Nullable<DataArray>;
  6559. /**
  6560. * Gets underlying native buffer
  6561. * @returns underlying native buffer
  6562. */
  6563. getBuffer(): Nullable<DataBuffer>;
  6564. /**
  6565. * Gets the stride in float32 units (i.e. byte stride / 4).
  6566. * May not be an integer if the byte stride is not divisible by 4.
  6567. * @returns the stride in float32 units
  6568. * @deprecated Please use byteStride instead.
  6569. */
  6570. getStrideSize(): number;
  6571. /**
  6572. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6573. * @param data defines the data to store
  6574. */
  6575. create(data?: Nullable<DataArray>): void;
  6576. /** @hidden */
  6577. _rebuild(): void;
  6578. /**
  6579. * Update current buffer data
  6580. * @param data defines the data to store
  6581. */
  6582. update(data: DataArray): void;
  6583. /**
  6584. * Updates the data directly.
  6585. * @param data the new data
  6586. * @param offset the new offset
  6587. * @param vertexCount the vertex count (optional)
  6588. * @param useBytes set to true if the offset is in bytes
  6589. */
  6590. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6591. /**
  6592. * Release all resources
  6593. */
  6594. dispose(): void;
  6595. }
  6596. /**
  6597. * Specialized buffer used to store vertex data
  6598. */
  6599. export class VertexBuffer {
  6600. /** @hidden */
  6601. _buffer: Buffer;
  6602. private _kind;
  6603. private _size;
  6604. private _ownsBuffer;
  6605. private _instanced;
  6606. private _instanceDivisor;
  6607. /**
  6608. * The byte type.
  6609. */
  6610. static readonly BYTE: number;
  6611. /**
  6612. * The unsigned byte type.
  6613. */
  6614. static readonly UNSIGNED_BYTE: number;
  6615. /**
  6616. * The short type.
  6617. */
  6618. static readonly SHORT: number;
  6619. /**
  6620. * The unsigned short type.
  6621. */
  6622. static readonly UNSIGNED_SHORT: number;
  6623. /**
  6624. * The integer type.
  6625. */
  6626. static readonly INT: number;
  6627. /**
  6628. * The unsigned integer type.
  6629. */
  6630. static readonly UNSIGNED_INT: number;
  6631. /**
  6632. * The float type.
  6633. */
  6634. static readonly FLOAT: number;
  6635. /**
  6636. * Gets or sets the instance divisor when in instanced mode
  6637. */
  6638. get instanceDivisor(): number;
  6639. set instanceDivisor(value: number);
  6640. /**
  6641. * Gets the byte stride.
  6642. */
  6643. readonly byteStride: number;
  6644. /**
  6645. * Gets the byte offset.
  6646. */
  6647. readonly byteOffset: number;
  6648. /**
  6649. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6650. */
  6651. readonly normalized: boolean;
  6652. /**
  6653. * Gets the data type of each component in the array.
  6654. */
  6655. readonly type: number;
  6656. /**
  6657. * Constructor
  6658. * @param engine the engine
  6659. * @param data the data to use for this vertex buffer
  6660. * @param kind the vertex buffer kind
  6661. * @param updatable whether the data is updatable
  6662. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6663. * @param stride the stride (optional)
  6664. * @param instanced whether the buffer is instanced (optional)
  6665. * @param offset the offset of the data (optional)
  6666. * @param size the number of components (optional)
  6667. * @param type the type of the component (optional)
  6668. * @param normalized whether the data contains normalized data (optional)
  6669. * @param useBytes set to true if stride and offset are in bytes (optional)
  6670. * @param divisor defines the instance divisor to use (1 by default)
  6671. */
  6672. 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);
  6673. /** @hidden */
  6674. _rebuild(): void;
  6675. /**
  6676. * Returns the kind of the VertexBuffer (string)
  6677. * @returns a string
  6678. */
  6679. getKind(): string;
  6680. /**
  6681. * Gets a boolean indicating if the VertexBuffer is updatable?
  6682. * @returns true if the buffer is updatable
  6683. */
  6684. isUpdatable(): boolean;
  6685. /**
  6686. * Gets current buffer's data
  6687. * @returns a DataArray or null
  6688. */
  6689. getData(): Nullable<DataArray>;
  6690. /**
  6691. * Gets underlying native buffer
  6692. * @returns underlying native buffer
  6693. */
  6694. getBuffer(): Nullable<DataBuffer>;
  6695. /**
  6696. * Gets the stride in float32 units (i.e. byte stride / 4).
  6697. * May not be an integer if the byte stride is not divisible by 4.
  6698. * @returns the stride in float32 units
  6699. * @deprecated Please use byteStride instead.
  6700. */
  6701. getStrideSize(): number;
  6702. /**
  6703. * Returns the offset as a multiple of the type byte length.
  6704. * @returns the offset in bytes
  6705. * @deprecated Please use byteOffset instead.
  6706. */
  6707. getOffset(): number;
  6708. /**
  6709. * Returns the number of components per vertex attribute (integer)
  6710. * @returns the size in float
  6711. */
  6712. getSize(): number;
  6713. /**
  6714. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6715. * @returns true if this buffer is instanced
  6716. */
  6717. getIsInstanced(): boolean;
  6718. /**
  6719. * Returns the instancing divisor, zero for non-instanced (integer).
  6720. * @returns a number
  6721. */
  6722. getInstanceDivisor(): number;
  6723. /**
  6724. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6725. * @param data defines the data to store
  6726. */
  6727. create(data?: DataArray): void;
  6728. /**
  6729. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6730. * This function will create a new buffer if the current one is not updatable
  6731. * @param data defines the data to store
  6732. */
  6733. update(data: DataArray): void;
  6734. /**
  6735. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6736. * Returns the directly updated WebGLBuffer.
  6737. * @param data the new data
  6738. * @param offset the new offset
  6739. * @param useBytes set to true if the offset is in bytes
  6740. */
  6741. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6742. /**
  6743. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6744. */
  6745. dispose(): void;
  6746. /**
  6747. * Enumerates each value of this vertex buffer as numbers.
  6748. * @param count the number of values to enumerate
  6749. * @param callback the callback function called for each value
  6750. */
  6751. forEach(count: number, callback: (value: number, index: number) => void): void;
  6752. /**
  6753. * Positions
  6754. */
  6755. static readonly PositionKind: string;
  6756. /**
  6757. * Normals
  6758. */
  6759. static readonly NormalKind: string;
  6760. /**
  6761. * Tangents
  6762. */
  6763. static readonly TangentKind: string;
  6764. /**
  6765. * Texture coordinates
  6766. */
  6767. static readonly UVKind: string;
  6768. /**
  6769. * Texture coordinates 2
  6770. */
  6771. static readonly UV2Kind: string;
  6772. /**
  6773. * Texture coordinates 3
  6774. */
  6775. static readonly UV3Kind: string;
  6776. /**
  6777. * Texture coordinates 4
  6778. */
  6779. static readonly UV4Kind: string;
  6780. /**
  6781. * Texture coordinates 5
  6782. */
  6783. static readonly UV5Kind: string;
  6784. /**
  6785. * Texture coordinates 6
  6786. */
  6787. static readonly UV6Kind: string;
  6788. /**
  6789. * Colors
  6790. */
  6791. static readonly ColorKind: string;
  6792. /**
  6793. * Matrix indices (for bones)
  6794. */
  6795. static readonly MatricesIndicesKind: string;
  6796. /**
  6797. * Matrix weights (for bones)
  6798. */
  6799. static readonly MatricesWeightsKind: string;
  6800. /**
  6801. * Additional matrix indices (for bones)
  6802. */
  6803. static readonly MatricesIndicesExtraKind: string;
  6804. /**
  6805. * Additional matrix weights (for bones)
  6806. */
  6807. static readonly MatricesWeightsExtraKind: string;
  6808. /**
  6809. * Deduces the stride given a kind.
  6810. * @param kind The kind string to deduce
  6811. * @returns The deduced stride
  6812. */
  6813. static DeduceStride(kind: string): number;
  6814. /**
  6815. * Gets the byte length of the given type.
  6816. * @param type the type
  6817. * @returns the number of bytes
  6818. */
  6819. static GetTypeByteLength(type: number): number;
  6820. /**
  6821. * Enumerates each value of the given parameters as numbers.
  6822. * @param data the data to enumerate
  6823. * @param byteOffset the byte offset of the data
  6824. * @param byteStride the byte stride of the data
  6825. * @param componentCount the number of components per element
  6826. * @param componentType the type of the component
  6827. * @param count the number of values to enumerate
  6828. * @param normalized whether the data is normalized
  6829. * @param callback the callback function called for each value
  6830. */
  6831. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6832. private static _GetFloatValue;
  6833. }
  6834. }
  6835. declare module BABYLON {
  6836. /**
  6837. * The options Interface for creating a Capsule Mesh
  6838. */
  6839. export interface ICreateCapsuleOptions {
  6840. /** The Orientation of the capsule. Default : Vector3.Up() */
  6841. orientation?: Vector3;
  6842. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6843. subdivisions: number;
  6844. /** Number of cylindrical segments on the capsule. */
  6845. tessellation: number;
  6846. /** Height or Length of the capsule. */
  6847. height: number;
  6848. /** Radius of the capsule. */
  6849. radius: number;
  6850. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6851. capSubdivisions: number;
  6852. /** Overwrite for the top radius. */
  6853. radiusTop?: number;
  6854. /** Overwrite for the bottom radius. */
  6855. radiusBottom?: number;
  6856. /** Overwrite for the top capSubdivisions. */
  6857. topCapSubdivisions?: number;
  6858. /** Overwrite for the bottom capSubdivisions. */
  6859. bottomCapSubdivisions?: number;
  6860. }
  6861. /**
  6862. * Class containing static functions to help procedurally build meshes
  6863. */
  6864. export class CapsuleBuilder {
  6865. /**
  6866. * Creates a capsule or a pill mesh
  6867. * @param name defines the name of the mesh
  6868. * @param options The constructors options.
  6869. * @param scene The scene the mesh is scoped to.
  6870. * @returns Capsule Mesh
  6871. */
  6872. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6873. }
  6874. }
  6875. declare module BABYLON {
  6876. /**
  6877. * @hidden
  6878. */
  6879. export class IntersectionInfo {
  6880. bu: Nullable<number>;
  6881. bv: Nullable<number>;
  6882. distance: number;
  6883. faceId: number;
  6884. subMeshId: number;
  6885. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6886. }
  6887. }
  6888. declare module BABYLON {
  6889. /**
  6890. * Class used to store bounding sphere information
  6891. */
  6892. export class BoundingSphere {
  6893. /**
  6894. * Gets the center of the bounding sphere in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Radius of the bounding sphere in local space
  6899. */
  6900. radius: number;
  6901. /**
  6902. * Gets the center of the bounding sphere in world space
  6903. */
  6904. readonly centerWorld: Vector3;
  6905. /**
  6906. * Radius of the bounding sphere in world space
  6907. */
  6908. radiusWorld: number;
  6909. /**
  6910. * Gets the minimum vector in local space
  6911. */
  6912. readonly minimum: Vector3;
  6913. /**
  6914. * Gets the maximum vector in local space
  6915. */
  6916. readonly maximum: Vector3;
  6917. private _worldMatrix;
  6918. private static readonly TmpVector3;
  6919. /**
  6920. * Creates a new bounding sphere
  6921. * @param min defines the minimum vector (in local space)
  6922. * @param max defines the maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6926. /**
  6927. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6928. * @param min defines the new minimum vector (in local space)
  6929. * @param max defines the new maximum vector (in local space)
  6930. * @param worldMatrix defines the new world matrix
  6931. */
  6932. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Scale the current bounding sphere by applying a scale factor
  6935. * @param factor defines the scale factor to apply
  6936. * @returns the current bounding box
  6937. */
  6938. scale(factor: number): BoundingSphere;
  6939. /**
  6940. * Gets the world matrix of the bounding box
  6941. * @returns a matrix
  6942. */
  6943. getWorldMatrix(): DeepImmutable<Matrix>;
  6944. /** @hidden */
  6945. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Tests if the bounding sphere is intersecting the frustum planes
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if the bounding sphere center is in between the frustum planes.
  6954. * Used for optimistic fast inclusion.
  6955. * @param frustumPlanes defines the frustum planes to test
  6956. * @returns true if the sphere center is in between the frustum planes
  6957. */
  6958. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6959. /**
  6960. * Tests if a point is inside the bounding sphere
  6961. * @param point defines the point to test
  6962. * @returns true if the point is inside the bounding sphere
  6963. */
  6964. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6965. /**
  6966. * Checks if two sphere intersct
  6967. * @param sphere0 sphere 0
  6968. * @param sphere1 sphere 1
  6969. * @returns true if the speres intersect
  6970. */
  6971. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6972. }
  6973. }
  6974. declare module BABYLON {
  6975. /**
  6976. * Class used to store bounding box information
  6977. */
  6978. export class BoundingBox implements ICullable {
  6979. /**
  6980. * Gets the 8 vectors representing the bounding box in local space
  6981. */
  6982. readonly vectors: Vector3[];
  6983. /**
  6984. * Gets the center of the bounding box in local space
  6985. */
  6986. readonly center: Vector3;
  6987. /**
  6988. * Gets the center of the bounding box in world space
  6989. */
  6990. readonly centerWorld: Vector3;
  6991. /**
  6992. * Gets the extend size in local space
  6993. */
  6994. readonly extendSize: Vector3;
  6995. /**
  6996. * Gets the extend size in world space
  6997. */
  6998. readonly extendSizeWorld: Vector3;
  6999. /**
  7000. * Gets the OBB (object bounding box) directions
  7001. */
  7002. readonly directions: Vector3[];
  7003. /**
  7004. * Gets the 8 vectors representing the bounding box in world space
  7005. */
  7006. readonly vectorsWorld: Vector3[];
  7007. /**
  7008. * Gets the minimum vector in world space
  7009. */
  7010. readonly minimumWorld: Vector3;
  7011. /**
  7012. * Gets the maximum vector in world space
  7013. */
  7014. readonly maximumWorld: Vector3;
  7015. /**
  7016. * Gets the minimum vector in local space
  7017. */
  7018. readonly minimum: Vector3;
  7019. /**
  7020. * Gets the maximum vector in local space
  7021. */
  7022. readonly maximum: Vector3;
  7023. private _worldMatrix;
  7024. private static readonly TmpVector3;
  7025. /**
  7026. * @hidden
  7027. */
  7028. _tag: number;
  7029. /**
  7030. * Creates a new bounding box
  7031. * @param min defines the minimum vector (in local space)
  7032. * @param max defines the maximum vector (in local space)
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Scale the current bounding box by applying a scale factor
  7045. * @param factor defines the scale factor to apply
  7046. * @returns the current bounding box
  7047. */
  7048. scale(factor: number): BoundingBox;
  7049. /**
  7050. * Gets the world matrix of the bounding box
  7051. * @returns a matrix
  7052. */
  7053. getWorldMatrix(): DeepImmutable<Matrix>;
  7054. /** @hidden */
  7055. _update(world: DeepImmutable<Matrix>): void;
  7056. /**
  7057. * Tests if the bounding box is intersecting the frustum planes
  7058. * @param frustumPlanes defines the frustum planes to test
  7059. * @returns true if there is an intersection
  7060. */
  7061. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /**
  7063. * Tests if the bounding box is entirely inside the frustum planes
  7064. * @param frustumPlanes defines the frustum planes to test
  7065. * @returns true if there is an inclusion
  7066. */
  7067. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7068. /**
  7069. * Tests if a point is inside the bounding box
  7070. * @param point defines the point to test
  7071. * @returns true if the point is inside the bounding box
  7072. */
  7073. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if the bounding box intersects with a bounding sphere
  7076. * @param sphere defines the sphere to test
  7077. * @returns true if there is an intersection
  7078. */
  7079. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7080. /**
  7081. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7082. * @param min defines the min vector to use
  7083. * @param max defines the max vector to use
  7084. * @returns true if there is an intersection
  7085. */
  7086. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7087. /**
  7088. * Tests if two bounding boxes are intersections
  7089. * @param box0 defines the first box to test
  7090. * @param box1 defines the second box to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7094. /**
  7095. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7096. * @param minPoint defines the minimum vector of the bounding box
  7097. * @param maxPoint defines the maximum vector of the bounding box
  7098. * @param sphereCenter defines the sphere center
  7099. * @param sphereRadius defines the sphere radius
  7100. * @returns true if there is an intersection
  7101. */
  7102. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7103. /**
  7104. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7105. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7106. * @param frustumPlanes defines the frustum planes to test
  7107. * @return true if there is an inclusion
  7108. */
  7109. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7110. /**
  7111. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7112. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @return true if there is an intersection
  7115. */
  7116. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. }
  7118. }
  7119. declare module BABYLON {
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. get collisionMask(): number;
  7163. set collisionMask(mask: number);
  7164. /**
  7165. * Gets the plane normal used to compute the sliding response (in local space)
  7166. */
  7167. get slidePlaneNormal(): Vector3;
  7168. /** @hidden */
  7169. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7170. /** @hidden */
  7171. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7172. /** @hidden */
  7173. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7174. /** @hidden */
  7175. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7176. /** @hidden */
  7177. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _getResponse(pos: Vector3, vel: Vector3): void;
  7180. }
  7181. }
  7182. declare module BABYLON {
  7183. /**
  7184. * Interface for cullable objects
  7185. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7186. */
  7187. export interface ICullable {
  7188. /**
  7189. * Checks if the object or part of the object is in the frustum
  7190. * @param frustumPlanes Camera near/planes
  7191. * @returns true if the object is in frustum otherwise false
  7192. */
  7193. isInFrustum(frustumPlanes: Plane[]): boolean;
  7194. /**
  7195. * Checks if a cullable object (mesh...) is in the camera frustum
  7196. * Unlike isInFrustum this cheks the full bounding box
  7197. * @param frustumPlanes Camera near/planes
  7198. * @returns true if the object is in frustum otherwise false
  7199. */
  7200. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7201. }
  7202. /**
  7203. * Info for a bounding data of a mesh
  7204. */
  7205. export class BoundingInfo implements ICullable {
  7206. /**
  7207. * Bounding box for the mesh
  7208. */
  7209. readonly boundingBox: BoundingBox;
  7210. /**
  7211. * Bounding sphere for the mesh
  7212. */
  7213. readonly boundingSphere: BoundingSphere;
  7214. private _isLocked;
  7215. private static readonly TmpVector3;
  7216. /**
  7217. * Constructs bounding info
  7218. * @param minimum min vector of the bounding box/sphere
  7219. * @param maximum max vector of the bounding box/sphere
  7220. * @param worldMatrix defines the new world matrix
  7221. */
  7222. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7223. /**
  7224. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7225. * @param min defines the new minimum vector (in local space)
  7226. * @param max defines the new maximum vector (in local space)
  7227. * @param worldMatrix defines the new world matrix
  7228. */
  7229. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7230. /**
  7231. * min vector of the bounding box/sphere
  7232. */
  7233. get minimum(): Vector3;
  7234. /**
  7235. * max vector of the bounding box/sphere
  7236. */
  7237. get maximum(): Vector3;
  7238. /**
  7239. * If the info is locked and won't be updated to avoid perf overhead
  7240. */
  7241. get isLocked(): boolean;
  7242. set isLocked(value: boolean);
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. get diagonalLength(): number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. /**
  7300. * Extracts minimum and maximum values from a list of indexed positions
  7301. * @param positions defines the positions to use
  7302. * @param indices defines the indices to the positions
  7303. * @param indexStart defines the start index
  7304. * @param indexCount defines the end index
  7305. * @param bias defines bias value to add to the result
  7306. * @return minimum and maximum values
  7307. */
  7308. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7309. minimum: Vector3;
  7310. maximum: Vector3;
  7311. };
  7312. /**
  7313. * Extracts minimum and maximum values from a list of positions
  7314. * @param positions defines the positions to use
  7315. * @param start defines the start index in the positions array
  7316. * @param count defines the number of positions to handle
  7317. * @param bias defines bias value to add to the result
  7318. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7319. * @return minimum and maximum values
  7320. */
  7321. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7322. minimum: Vector3;
  7323. maximum: Vector3;
  7324. };
  7325. }
  7326. declare module BABYLON {
  7327. /** @hidden */
  7328. export class WebGLDataBuffer extends DataBuffer {
  7329. private _buffer;
  7330. constructor(resource: WebGLBuffer);
  7331. get underlyingResource(): any;
  7332. }
  7333. }
  7334. declare module BABYLON {
  7335. /** @hidden */
  7336. export class WebGLPipelineContext implements IPipelineContext {
  7337. engine: ThinEngine;
  7338. program: Nullable<WebGLProgram>;
  7339. context?: WebGLRenderingContext;
  7340. vertexShader?: WebGLShader;
  7341. fragmentShader?: WebGLShader;
  7342. isParallelCompiled: boolean;
  7343. onCompiled?: () => void;
  7344. transformFeedback?: WebGLTransformFeedback | null;
  7345. vertexCompilationError: Nullable<string>;
  7346. fragmentCompilationError: Nullable<string>;
  7347. programLinkError: Nullable<string>;
  7348. programValidationError: Nullable<string>;
  7349. get isAsync(): boolean;
  7350. get isReady(): boolean;
  7351. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7352. _getVertexShaderCode(): string | null;
  7353. _getFragmentShaderCode(): string | null;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. interface ThinEngine {
  7358. /**
  7359. * Create an uniform buffer
  7360. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7361. * @param elements defines the content of the uniform buffer
  7362. * @returns the webGL uniform buffer
  7363. */
  7364. createUniformBuffer(elements: FloatArray): DataBuffer;
  7365. /**
  7366. * Create a dynamic uniform buffer
  7367. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7368. * @param elements defines the content of the uniform buffer
  7369. * @returns the webGL uniform buffer
  7370. */
  7371. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7372. /**
  7373. * Update an existing uniform buffer
  7374. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7375. * @param uniformBuffer defines the target uniform buffer
  7376. * @param elements defines the content to update
  7377. * @param offset defines the offset in the uniform buffer where update should start
  7378. * @param count defines the size of the data to update
  7379. */
  7380. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7381. /**
  7382. * Bind an uniform buffer to the current webGL context
  7383. * @param buffer defines the buffer to bind
  7384. */
  7385. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7386. /**
  7387. * Bind a buffer to the current webGL context at a given location
  7388. * @param buffer defines the buffer to bind
  7389. * @param location defines the index where to bind the buffer
  7390. */
  7391. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7392. /**
  7393. * Bind a specific block at a given index in a specific shader program
  7394. * @param pipelineContext defines the pipeline context to use
  7395. * @param blockName defines the block name
  7396. * @param index defines the index where to bind the block
  7397. */
  7398. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7399. }
  7400. }
  7401. declare module BABYLON {
  7402. /**
  7403. * Uniform buffer objects.
  7404. *
  7405. * Handles blocks of uniform on the GPU.
  7406. *
  7407. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7408. *
  7409. * For more information, please refer to :
  7410. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7411. */
  7412. export class UniformBuffer {
  7413. private _engine;
  7414. private _buffer;
  7415. private _data;
  7416. private _bufferData;
  7417. private _dynamic?;
  7418. private _uniformLocations;
  7419. private _uniformSizes;
  7420. private _uniformLocationPointer;
  7421. private _needSync;
  7422. private _noUBO;
  7423. private _currentEffect;
  7424. /** @hidden */
  7425. _alreadyBound: boolean;
  7426. private static _MAX_UNIFORM_SIZE;
  7427. private static _tempBuffer;
  7428. /**
  7429. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7434. /**
  7435. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7436. * This is dynamic to allow compat with webgl 1 and 2.
  7437. * You will need to pass the name of the uniform as well as the value.
  7438. */
  7439. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7440. /**
  7441. * Lambda to Update a single float in a uniform buffer.
  7442. * This is dynamic to allow compat with webgl 1 and 2.
  7443. * You will need to pass the name of the uniform as well as the value.
  7444. */
  7445. updateFloat: (name: string, x: number) => void;
  7446. /**
  7447. * Lambda to Update a vec2 of float in a uniform buffer.
  7448. * This is dynamic to allow compat with webgl 1 and 2.
  7449. * You will need to pass the name of the uniform as well as the value.
  7450. */
  7451. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7452. /**
  7453. * Lambda to Update a vec3 of float in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7458. /**
  7459. * Lambda to Update a vec4 of float in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7464. /**
  7465. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateMatrix: (name: string, mat: Matrix) => void;
  7470. /**
  7471. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateVector3: (name: string, vector: Vector3) => void;
  7476. /**
  7477. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateVector4: (name: string, vector: Vector4) => void;
  7482. /**
  7483. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7494. /**
  7495. * Instantiates a new Uniform buffer objects.
  7496. *
  7497. * Handles blocks of uniform on the GPU.
  7498. *
  7499. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7500. *
  7501. * For more information, please refer to :
  7502. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7503. * @param engine Define the engine the buffer is associated with
  7504. * @param data Define the data contained in the buffer
  7505. * @param dynamic Define if the buffer is updatable
  7506. */
  7507. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7508. /**
  7509. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7510. * or just falling back on setUniformXXX calls.
  7511. */
  7512. get useUbo(): boolean;
  7513. /**
  7514. * Indicates if the WebGL underlying uniform buffer is in sync
  7515. * with the javascript cache data.
  7516. */
  7517. get isSync(): boolean;
  7518. /**
  7519. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7520. * Also, a dynamic UniformBuffer will disable cache verification and always
  7521. * update the underlying WebGL uniform buffer to the GPU.
  7522. * @returns if Dynamic, otherwise false
  7523. */
  7524. isDynamic(): boolean;
  7525. /**
  7526. * The data cache on JS side.
  7527. * @returns the underlying data as a float array
  7528. */
  7529. getData(): Float32Array;
  7530. /**
  7531. * The underlying WebGL Uniform buffer.
  7532. * @returns the webgl buffer
  7533. */
  7534. getBuffer(): Nullable<DataBuffer>;
  7535. /**
  7536. * std140 layout specifies how to align data within an UBO structure.
  7537. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7538. * for specs.
  7539. */
  7540. private _fillAlignment;
  7541. /**
  7542. * Adds an uniform in the buffer.
  7543. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7544. * for the layout to be correct !
  7545. * @param name Name of the uniform, as used in the uniform block in the shader.
  7546. * @param size Data size, or data directly.
  7547. */
  7548. addUniform(name: string, size: number | number[]): void;
  7549. /**
  7550. * Adds a Matrix 4x4 to the uniform buffer.
  7551. * @param name Name of the uniform, as used in the uniform block in the shader.
  7552. * @param mat A 4x4 matrix.
  7553. */
  7554. addMatrix(name: string, mat: Matrix): void;
  7555. /**
  7556. * Adds a vec2 to the uniform buffer.
  7557. * @param name Name of the uniform, as used in the uniform block in the shader.
  7558. * @param x Define the x component value of the vec2
  7559. * @param y Define the y component value of the vec2
  7560. */
  7561. addFloat2(name: string, x: number, y: number): void;
  7562. /**
  7563. * Adds a vec3 to the uniform buffer.
  7564. * @param name Name of the uniform, as used in the uniform block in the shader.
  7565. * @param x Define the x component value of the vec3
  7566. * @param y Define the y component value of the vec3
  7567. * @param z Define the z component value of the vec3
  7568. */
  7569. addFloat3(name: string, x: number, y: number, z: number): void;
  7570. /**
  7571. * Adds a vec3 to the uniform buffer.
  7572. * @param name Name of the uniform, as used in the uniform block in the shader.
  7573. * @param color Define the vec3 from a Color
  7574. */
  7575. addColor3(name: string, color: Color3): void;
  7576. /**
  7577. * Adds a vec4 to the uniform buffer.
  7578. * @param name Name of the uniform, as used in the uniform block in the shader.
  7579. * @param color Define the rgb components from a Color
  7580. * @param alpha Define the a component of the vec4
  7581. */
  7582. addColor4(name: string, color: Color3, alpha: number): void;
  7583. /**
  7584. * Adds a vec3 to the uniform buffer.
  7585. * @param name Name of the uniform, as used in the uniform block in the shader.
  7586. * @param vector Define the vec3 components from a Vector
  7587. */
  7588. addVector3(name: string, vector: Vector3): void;
  7589. /**
  7590. * Adds a Matrix 3x3 to the uniform buffer.
  7591. * @param name Name of the uniform, as used in the uniform block in the shader.
  7592. */
  7593. addMatrix3x3(name: string): void;
  7594. /**
  7595. * Adds a Matrix 2x2 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. */
  7598. addMatrix2x2(name: string): void;
  7599. /**
  7600. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7601. */
  7602. create(): void;
  7603. /** @hidden */
  7604. _rebuild(): void;
  7605. /**
  7606. * Updates the WebGL Uniform Buffer on the GPU.
  7607. * If the `dynamic` flag is set to true, no cache comparison is done.
  7608. * Otherwise, the buffer will be updated only if the cache differs.
  7609. */
  7610. update(): void;
  7611. /**
  7612. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7613. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7614. * @param data Define the flattened data
  7615. * @param size Define the size of the data.
  7616. */
  7617. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7618. private _valueCache;
  7619. private _cacheMatrix;
  7620. private _updateMatrix3x3ForUniform;
  7621. private _updateMatrix3x3ForEffect;
  7622. private _updateMatrix2x2ForEffect;
  7623. private _updateMatrix2x2ForUniform;
  7624. private _updateFloatForEffect;
  7625. private _updateFloatForUniform;
  7626. private _updateFloat2ForEffect;
  7627. private _updateFloat2ForUniform;
  7628. private _updateFloat3ForEffect;
  7629. private _updateFloat3ForUniform;
  7630. private _updateFloat4ForEffect;
  7631. private _updateFloat4ForUniform;
  7632. private _updateMatrixForEffect;
  7633. private _updateMatrixForUniform;
  7634. private _updateVector3ForEffect;
  7635. private _updateVector3ForUniform;
  7636. private _updateVector4ForEffect;
  7637. private _updateVector4ForUniform;
  7638. private _updateColor3ForEffect;
  7639. private _updateColor3ForUniform;
  7640. private _updateColor4ForEffect;
  7641. private _updateColor4ForUniform;
  7642. /**
  7643. * Sets a sampler uniform on the effect.
  7644. * @param name Define the name of the sampler.
  7645. * @param texture Define the texture to set in the sampler
  7646. */
  7647. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7648. /**
  7649. * Directly updates the value of the uniform in the cache AND on the GPU.
  7650. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7651. * @param data Define the flattened data
  7652. */
  7653. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7654. /**
  7655. * Binds this uniform buffer to an effect.
  7656. * @param effect Define the effect to bind the buffer to
  7657. * @param name Name of the uniform block in the shader.
  7658. */
  7659. bindToEffect(effect: Effect, name: string): void;
  7660. /**
  7661. * Disposes the uniform buffer.
  7662. */
  7663. dispose(): void;
  7664. }
  7665. }
  7666. declare module BABYLON {
  7667. /**
  7668. * Enum that determines the text-wrapping mode to use.
  7669. */
  7670. export enum InspectableType {
  7671. /**
  7672. * Checkbox for booleans
  7673. */
  7674. Checkbox = 0,
  7675. /**
  7676. * Sliders for numbers
  7677. */
  7678. Slider = 1,
  7679. /**
  7680. * Vector3
  7681. */
  7682. Vector3 = 2,
  7683. /**
  7684. * Quaternions
  7685. */
  7686. Quaternion = 3,
  7687. /**
  7688. * Color3
  7689. */
  7690. Color3 = 4,
  7691. /**
  7692. * String
  7693. */
  7694. String = 5
  7695. }
  7696. /**
  7697. * Interface used to define custom inspectable properties.
  7698. * This interface is used by the inspector to display custom property grids
  7699. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7700. */
  7701. export interface IInspectable {
  7702. /**
  7703. * Gets the label to display
  7704. */
  7705. label: string;
  7706. /**
  7707. * Gets the name of the property to edit
  7708. */
  7709. propertyName: string;
  7710. /**
  7711. * Gets the type of the editor to use
  7712. */
  7713. type: InspectableType;
  7714. /**
  7715. * Gets the minimum value of the property when using in "slider" mode
  7716. */
  7717. min?: number;
  7718. /**
  7719. * Gets the maximum value of the property when using in "slider" mode
  7720. */
  7721. max?: number;
  7722. /**
  7723. * Gets the setp to use when using in "slider" mode
  7724. */
  7725. step?: number;
  7726. }
  7727. }
  7728. declare module BABYLON {
  7729. /**
  7730. * Class used to provide helper for timing
  7731. */
  7732. export class TimingTools {
  7733. /**
  7734. * Polyfill for setImmediate
  7735. * @param action defines the action to execute after the current execution block
  7736. */
  7737. static SetImmediate(action: () => void): void;
  7738. }
  7739. }
  7740. declare module BABYLON {
  7741. /**
  7742. * Class used to enable instatition of objects by class name
  7743. */
  7744. export class InstantiationTools {
  7745. /**
  7746. * Use this object to register external classes like custom textures or material
  7747. * to allow the laoders to instantiate them
  7748. */
  7749. static RegisteredExternalClasses: {
  7750. [key: string]: Object;
  7751. };
  7752. /**
  7753. * Tries to instantiate a new object from a given class name
  7754. * @param className defines the class name to instantiate
  7755. * @returns the new object or null if the system was not able to do the instantiation
  7756. */
  7757. static Instantiate(className: string): any;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Define options used to create a depth texture
  7763. */
  7764. export class DepthTextureCreationOptions {
  7765. /** Specifies whether or not a stencil should be allocated in the texture */
  7766. generateStencil?: boolean;
  7767. /** Specifies whether or not bilinear filtering is enable on the texture */
  7768. bilinearFiltering?: boolean;
  7769. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7770. comparisonFunction?: number;
  7771. /** Specifies if the created texture is a cube texture */
  7772. isCube?: boolean;
  7773. }
  7774. }
  7775. declare module BABYLON {
  7776. interface ThinEngine {
  7777. /**
  7778. * Creates a depth stencil cube texture.
  7779. * This is only available in WebGL 2.
  7780. * @param size The size of face edge in the cube texture.
  7781. * @param options The options defining the cube texture.
  7782. * @returns The cube texture
  7783. */
  7784. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7785. /**
  7786. * Creates a cube texture
  7787. * @param rootUrl defines the url where the files to load is located
  7788. * @param scene defines the current scene
  7789. * @param files defines the list of files to load (1 per face)
  7790. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7791. * @param onLoad defines an optional callback raised when the texture is loaded
  7792. * @param onError defines an optional callback raised if there is an issue to load the texture
  7793. * @param format defines the format of the data
  7794. * @param forcedExtension defines the extension to use to pick the right loader
  7795. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7796. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7797. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7798. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7799. * @returns the cube texture as an InternalTexture
  7800. */
  7801. 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;
  7802. /**
  7803. * Creates a cube texture
  7804. * @param rootUrl defines the url where the files to load is located
  7805. * @param scene defines the current scene
  7806. * @param files defines the list of files to load (1 per face)
  7807. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7808. * @param onLoad defines an optional callback raised when the texture is loaded
  7809. * @param onError defines an optional callback raised if there is an issue to load the texture
  7810. * @param format defines the format of the data
  7811. * @param forcedExtension defines the extension to use to pick the right loader
  7812. * @returns the cube texture as an InternalTexture
  7813. */
  7814. 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;
  7815. /**
  7816. * Creates a cube texture
  7817. * @param rootUrl defines the url where the files to load is located
  7818. * @param scene defines the current scene
  7819. * @param files defines the list of files to load (1 per face)
  7820. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7821. * @param onLoad defines an optional callback raised when the texture is loaded
  7822. * @param onError defines an optional callback raised if there is an issue to load the texture
  7823. * @param format defines the format of the data
  7824. * @param forcedExtension defines the extension to use to pick the right loader
  7825. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7826. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7827. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. 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;
  7831. /** @hidden */
  7832. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7833. /** @hidden */
  7834. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7835. /** @hidden */
  7836. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7837. /** @hidden */
  7838. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7839. /**
  7840. * @hidden
  7841. */
  7842. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7843. }
  7844. }
  7845. declare module BABYLON {
  7846. /**
  7847. * Class for creating a cube texture
  7848. */
  7849. export class CubeTexture extends BaseTexture {
  7850. private _delayedOnLoad;
  7851. /**
  7852. * Observable triggered once the texture has been loaded.
  7853. */
  7854. onLoadObservable: Observable<CubeTexture>;
  7855. /**
  7856. * The url of the texture
  7857. */
  7858. url: string;
  7859. /**
  7860. * Gets or sets the center of the bounding box associated with the cube texture.
  7861. * It must define where the camera used to render the texture was set
  7862. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7863. */
  7864. boundingBoxPosition: Vector3;
  7865. private _boundingBoxSize;
  7866. /**
  7867. * Gets or sets the size of the bounding box associated with the cube texture
  7868. * When defined, the cubemap will switch to local mode
  7869. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7870. * @example https://www.babylonjs-playground.com/#RNASML
  7871. */
  7872. set boundingBoxSize(value: Vector3);
  7873. /**
  7874. * Returns the bounding box size
  7875. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7876. */
  7877. get boundingBoxSize(): Vector3;
  7878. protected _rotationY: number;
  7879. /**
  7880. * Sets texture matrix rotation angle around Y axis in radians.
  7881. */
  7882. set rotationY(value: number);
  7883. /**
  7884. * Gets texture matrix rotation angle around Y axis radians.
  7885. */
  7886. get rotationY(): number;
  7887. /**
  7888. * Are mip maps generated for this texture or not.
  7889. */
  7890. get noMipmap(): boolean;
  7891. private _noMipmap;
  7892. private _files;
  7893. protected _forcedExtension: Nullable<string>;
  7894. private _extensions;
  7895. private _textureMatrix;
  7896. private _format;
  7897. private _createPolynomials;
  7898. /**
  7899. * Creates a cube texture from an array of image urls
  7900. * @param files defines an array of image urls
  7901. * @param scene defines the hosting scene
  7902. * @param noMipmap specifies if mip maps are not used
  7903. * @returns a cube texture
  7904. */
  7905. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7906. /**
  7907. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7908. * @param url defines the url of the prefiltered texture
  7909. * @param scene defines the scene the texture is attached to
  7910. * @param forcedExtension defines the extension of the file if different from the url
  7911. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7912. * @return the prefiltered texture
  7913. */
  7914. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7915. /**
  7916. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7917. * as prefiltered data.
  7918. * @param rootUrl defines the url of the texture or the root name of the six images
  7919. * @param null defines the scene or engine the texture is attached to
  7920. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7921. * @param noMipmap defines if mipmaps should be created or not
  7922. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7923. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7924. * @param onError defines a callback triggered in case of error during load
  7925. * @param format defines the internal format to use for the texture once loaded
  7926. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7927. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7928. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7929. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7930. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7931. * @return the cube texture
  7932. */
  7933. 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);
  7934. /**
  7935. * Get the current class name of the texture useful for serialization or dynamic coding.
  7936. * @returns "CubeTexture"
  7937. */
  7938. getClassName(): string;
  7939. /**
  7940. * Update the url (and optional buffer) of this texture if url was null during construction.
  7941. * @param url the url of the texture
  7942. * @param forcedExtension defines the extension to use
  7943. * @param onLoad callback called when the texture is loaded (defaults to null)
  7944. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7945. */
  7946. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7947. /**
  7948. * Delays loading of the cube texture
  7949. * @param forcedExtension defines the extension to use
  7950. */
  7951. delayLoad(forcedExtension?: string): void;
  7952. /**
  7953. * Returns the reflection texture matrix
  7954. * @returns the reflection texture matrix
  7955. */
  7956. getReflectionTextureMatrix(): Matrix;
  7957. /**
  7958. * Sets the reflection texture matrix
  7959. * @param value Reflection texture matrix
  7960. */
  7961. setReflectionTextureMatrix(value: Matrix): void;
  7962. /**
  7963. * Parses text to create a cube texture
  7964. * @param parsedTexture define the serialized text to read from
  7965. * @param scene defines the hosting scene
  7966. * @param rootUrl defines the root url of the cube texture
  7967. * @returns a cube texture
  7968. */
  7969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7970. /**
  7971. * Makes a clone, or deep copy, of the cube texture
  7972. * @returns a new cube texture
  7973. */
  7974. clone(): CubeTexture;
  7975. }
  7976. }
  7977. declare module BABYLON {
  7978. /**
  7979. * Manages the defines for the Material
  7980. */
  7981. export class MaterialDefines {
  7982. /** @hidden */
  7983. protected _keys: string[];
  7984. private _isDirty;
  7985. /** @hidden */
  7986. _renderId: number;
  7987. /** @hidden */
  7988. _areLightsDirty: boolean;
  7989. /** @hidden */
  7990. _areLightsDisposed: boolean;
  7991. /** @hidden */
  7992. _areAttributesDirty: boolean;
  7993. /** @hidden */
  7994. _areTexturesDirty: boolean;
  7995. /** @hidden */
  7996. _areFresnelDirty: boolean;
  7997. /** @hidden */
  7998. _areMiscDirty: boolean;
  7999. /** @hidden */
  8000. _areImageProcessingDirty: boolean;
  8001. /** @hidden */
  8002. _normals: boolean;
  8003. /** @hidden */
  8004. _uvs: boolean;
  8005. /** @hidden */
  8006. _needNormals: boolean;
  8007. /** @hidden */
  8008. _needUVs: boolean;
  8009. [id: string]: any;
  8010. /**
  8011. * Specifies if the material needs to be re-calculated
  8012. */
  8013. get isDirty(): boolean;
  8014. /**
  8015. * Marks the material to indicate that it has been re-calculated
  8016. */
  8017. markAsProcessed(): void;
  8018. /**
  8019. * Marks the material to indicate that it needs to be re-calculated
  8020. */
  8021. markAsUnprocessed(): void;
  8022. /**
  8023. * Marks the material to indicate all of its defines need to be re-calculated
  8024. */
  8025. markAllAsDirty(): void;
  8026. /**
  8027. * Marks the material to indicate that image processing needs to be re-calculated
  8028. */
  8029. markAsImageProcessingDirty(): void;
  8030. /**
  8031. * Marks the material to indicate the lights need to be re-calculated
  8032. * @param disposed Defines whether the light is dirty due to dispose or not
  8033. */
  8034. markAsLightDirty(disposed?: boolean): void;
  8035. /**
  8036. * Marks the attribute state as changed
  8037. */
  8038. markAsAttributesDirty(): void;
  8039. /**
  8040. * Marks the texture state as changed
  8041. */
  8042. markAsTexturesDirty(): void;
  8043. /**
  8044. * Marks the fresnel state as changed
  8045. */
  8046. markAsFresnelDirty(): void;
  8047. /**
  8048. * Marks the misc state as changed
  8049. */
  8050. markAsMiscDirty(): void;
  8051. /**
  8052. * Rebuilds the material defines
  8053. */
  8054. rebuild(): void;
  8055. /**
  8056. * Specifies if two material defines are equal
  8057. * @param other - A material define instance to compare to
  8058. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8059. */
  8060. isEqual(other: MaterialDefines): boolean;
  8061. /**
  8062. * Clones this instance's defines to another instance
  8063. * @param other - material defines to clone values to
  8064. */
  8065. cloneTo(other: MaterialDefines): void;
  8066. /**
  8067. * Resets the material define values
  8068. */
  8069. reset(): void;
  8070. /**
  8071. * Converts the material define values to a string
  8072. * @returns - String of material define information
  8073. */
  8074. toString(): string;
  8075. }
  8076. }
  8077. declare module BABYLON {
  8078. /**
  8079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8081. * 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;
  8082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8083. */
  8084. export class ColorCurves {
  8085. private _dirty;
  8086. private _tempColor;
  8087. private _globalCurve;
  8088. private _highlightsCurve;
  8089. private _midtonesCurve;
  8090. private _shadowsCurve;
  8091. private _positiveCurve;
  8092. private _negativeCurve;
  8093. private _globalHue;
  8094. private _globalDensity;
  8095. private _globalSaturation;
  8096. private _globalExposure;
  8097. /**
  8098. * Gets the global Hue value.
  8099. * 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).
  8100. */
  8101. get globalHue(): number;
  8102. /**
  8103. * Sets the global Hue value.
  8104. * 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).
  8105. */
  8106. set globalHue(value: number);
  8107. /**
  8108. * Gets the global Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get globalDensity(): number;
  8113. /**
  8114. * Sets the global Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set globalDensity(value: number);
  8119. /**
  8120. * Gets the global Saturation value.
  8121. * 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.
  8122. */
  8123. get globalSaturation(): number;
  8124. /**
  8125. * Sets the global Saturation value.
  8126. * 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.
  8127. */
  8128. set globalSaturation(value: number);
  8129. /**
  8130. * Gets the global Exposure value.
  8131. * 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.
  8132. */
  8133. get globalExposure(): number;
  8134. /**
  8135. * Sets the global Exposure value.
  8136. * 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.
  8137. */
  8138. set globalExposure(value: number);
  8139. private _highlightsHue;
  8140. private _highlightsDensity;
  8141. private _highlightsSaturation;
  8142. private _highlightsExposure;
  8143. /**
  8144. * Gets the highlights Hue value.
  8145. * 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).
  8146. */
  8147. get highlightsHue(): number;
  8148. /**
  8149. * Sets the highlights Hue value.
  8150. * 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).
  8151. */
  8152. set highlightsHue(value: number);
  8153. /**
  8154. * Gets the highlights Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get highlightsDensity(): number;
  8159. /**
  8160. * Sets the highlights Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set highlightsDensity(value: number);
  8165. /**
  8166. * Gets the highlights Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. get highlightsSaturation(): number;
  8170. /**
  8171. * Sets the highlights Saturation value.
  8172. * 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.
  8173. */
  8174. set highlightsSaturation(value: number);
  8175. /**
  8176. * Gets the highlights Exposure value.
  8177. * 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.
  8178. */
  8179. get highlightsExposure(): number;
  8180. /**
  8181. * Sets the highlights Exposure value.
  8182. * 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.
  8183. */
  8184. set highlightsExposure(value: number);
  8185. private _midtonesHue;
  8186. private _midtonesDensity;
  8187. private _midtonesSaturation;
  8188. private _midtonesExposure;
  8189. /**
  8190. * Gets the midtones Hue value.
  8191. * 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).
  8192. */
  8193. get midtonesHue(): number;
  8194. /**
  8195. * Sets the midtones Hue value.
  8196. * 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).
  8197. */
  8198. set midtonesHue(value: number);
  8199. /**
  8200. * Gets the midtones Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get midtonesDensity(): number;
  8205. /**
  8206. * Sets the midtones Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set midtonesDensity(value: number);
  8211. /**
  8212. * Gets the midtones Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get midtonesSaturation(): number;
  8216. /**
  8217. * Sets the midtones Saturation value.
  8218. * 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.
  8219. */
  8220. set midtonesSaturation(value: number);
  8221. /**
  8222. * Gets the midtones Exposure value.
  8223. * 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.
  8224. */
  8225. get midtonesExposure(): number;
  8226. /**
  8227. * Sets the midtones Exposure value.
  8228. * 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.
  8229. */
  8230. set midtonesExposure(value: number);
  8231. private _shadowsHue;
  8232. private _shadowsDensity;
  8233. private _shadowsSaturation;
  8234. private _shadowsExposure;
  8235. /**
  8236. * Gets the shadows Hue value.
  8237. * 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).
  8238. */
  8239. get shadowsHue(): number;
  8240. /**
  8241. * Sets the shadows Hue value.
  8242. * 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).
  8243. */
  8244. set shadowsHue(value: number);
  8245. /**
  8246. * Gets the shadows Density value.
  8247. * 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.
  8248. * Values less than zero provide a filter of opposite hue.
  8249. */
  8250. get shadowsDensity(): number;
  8251. /**
  8252. * Sets the shadows Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. set shadowsDensity(value: number);
  8257. /**
  8258. * Gets the shadows Saturation value.
  8259. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8260. */
  8261. get shadowsSaturation(): number;
  8262. /**
  8263. * Sets the shadows Saturation value.
  8264. * 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.
  8265. */
  8266. set shadowsSaturation(value: number);
  8267. /**
  8268. * Gets the shadows Exposure value.
  8269. * 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.
  8270. */
  8271. get shadowsExposure(): number;
  8272. /**
  8273. * Sets the shadows Exposure value.
  8274. * 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.
  8275. */
  8276. set shadowsExposure(value: number);
  8277. /**
  8278. * Returns the class name
  8279. * @returns The class name
  8280. */
  8281. getClassName(): string;
  8282. /**
  8283. * Binds the color curves to the shader.
  8284. * @param colorCurves The color curve to bind
  8285. * @param effect The effect to bind to
  8286. * @param positiveUniform The positive uniform shader parameter
  8287. * @param neutralUniform The neutral uniform shader parameter
  8288. * @param negativeUniform The negative uniform shader parameter
  8289. */
  8290. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8291. /**
  8292. * Prepare the list of uniforms associated with the ColorCurves effects.
  8293. * @param uniformsList The list of uniforms used in the effect
  8294. */
  8295. static PrepareUniforms(uniformsList: string[]): void;
  8296. /**
  8297. * Returns color grading data based on a hue, density, saturation and exposure value.
  8298. * @param filterHue The hue of the color filter.
  8299. * @param filterDensity The density of the color filter.
  8300. * @param saturation The saturation.
  8301. * @param exposure The exposure.
  8302. * @param result The result data container.
  8303. */
  8304. private getColorGradingDataToRef;
  8305. /**
  8306. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8307. * @param value The input slider value in range [-100,100].
  8308. * @returns Adjusted value.
  8309. */
  8310. private static applyColorGradingSliderNonlinear;
  8311. /**
  8312. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8313. * @param hue The hue (H) input.
  8314. * @param saturation The saturation (S) input.
  8315. * @param brightness The brightness (B) input.
  8316. * @result An RGBA color represented as Vector4.
  8317. */
  8318. private static fromHSBToRef;
  8319. /**
  8320. * Returns a value clamped between min and max
  8321. * @param value The value to clamp
  8322. * @param min The minimum of value
  8323. * @param max The maximum of value
  8324. * @returns The clamped value.
  8325. */
  8326. private static clamp;
  8327. /**
  8328. * Clones the current color curve instance.
  8329. * @return The cloned curves
  8330. */
  8331. clone(): ColorCurves;
  8332. /**
  8333. * Serializes the current color curve instance to a json representation.
  8334. * @return a JSON representation
  8335. */
  8336. serialize(): any;
  8337. /**
  8338. * Parses the color curve from a json representation.
  8339. * @param source the JSON source to parse
  8340. * @return The parsed curves
  8341. */
  8342. static Parse(source: any): ColorCurves;
  8343. }
  8344. }
  8345. declare module BABYLON {
  8346. /**
  8347. * Interface to follow in your material defines to integrate easily the
  8348. * Image proccessing functions.
  8349. * @hidden
  8350. */
  8351. export interface IImageProcessingConfigurationDefines {
  8352. IMAGEPROCESSING: boolean;
  8353. VIGNETTE: boolean;
  8354. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8355. VIGNETTEBLENDMODEOPAQUE: boolean;
  8356. TONEMAPPING: boolean;
  8357. TONEMAPPING_ACES: boolean;
  8358. CONTRAST: boolean;
  8359. EXPOSURE: boolean;
  8360. COLORCURVES: boolean;
  8361. COLORGRADING: boolean;
  8362. COLORGRADING3D: boolean;
  8363. SAMPLER3DGREENDEPTH: boolean;
  8364. SAMPLER3DBGRMAP: boolean;
  8365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8366. }
  8367. /**
  8368. * @hidden
  8369. */
  8370. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8371. IMAGEPROCESSING: boolean;
  8372. VIGNETTE: boolean;
  8373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8374. VIGNETTEBLENDMODEOPAQUE: boolean;
  8375. TONEMAPPING: boolean;
  8376. TONEMAPPING_ACES: boolean;
  8377. CONTRAST: boolean;
  8378. COLORCURVES: boolean;
  8379. COLORGRADING: boolean;
  8380. COLORGRADING3D: boolean;
  8381. SAMPLER3DGREENDEPTH: boolean;
  8382. SAMPLER3DBGRMAP: boolean;
  8383. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8384. EXPOSURE: boolean;
  8385. constructor();
  8386. }
  8387. /**
  8388. * This groups together the common properties used for image processing either in direct forward pass
  8389. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8390. * or not.
  8391. */
  8392. export class ImageProcessingConfiguration {
  8393. /**
  8394. * Default tone mapping applied in BabylonJS.
  8395. */
  8396. static readonly TONEMAPPING_STANDARD: number;
  8397. /**
  8398. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8399. * to other engines rendering to increase portability.
  8400. */
  8401. static readonly TONEMAPPING_ACES: number;
  8402. /**
  8403. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8404. */
  8405. colorCurves: Nullable<ColorCurves>;
  8406. private _colorCurvesEnabled;
  8407. /**
  8408. * Gets wether the color curves effect is enabled.
  8409. */
  8410. get colorCurvesEnabled(): boolean;
  8411. /**
  8412. * Sets wether the color curves effect is enabled.
  8413. */
  8414. set colorCurvesEnabled(value: boolean);
  8415. private _colorGradingTexture;
  8416. /**
  8417. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8418. */
  8419. get colorGradingTexture(): Nullable<BaseTexture>;
  8420. /**
  8421. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8422. */
  8423. set colorGradingTexture(value: Nullable<BaseTexture>);
  8424. private _colorGradingEnabled;
  8425. /**
  8426. * Gets wether the color grading effect is enabled.
  8427. */
  8428. get colorGradingEnabled(): boolean;
  8429. /**
  8430. * Sets wether the color grading effect is enabled.
  8431. */
  8432. set colorGradingEnabled(value: boolean);
  8433. private _colorGradingWithGreenDepth;
  8434. /**
  8435. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8436. */
  8437. get colorGradingWithGreenDepth(): boolean;
  8438. /**
  8439. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8440. */
  8441. set colorGradingWithGreenDepth(value: boolean);
  8442. private _colorGradingBGR;
  8443. /**
  8444. * Gets wether the color grading texture contains BGR values.
  8445. */
  8446. get colorGradingBGR(): boolean;
  8447. /**
  8448. * Sets wether the color grading texture contains BGR values.
  8449. */
  8450. set colorGradingBGR(value: boolean);
  8451. /** @hidden */
  8452. _exposure: number;
  8453. /**
  8454. * Gets the Exposure used in the effect.
  8455. */
  8456. get exposure(): number;
  8457. /**
  8458. * Sets the Exposure used in the effect.
  8459. */
  8460. set exposure(value: number);
  8461. private _toneMappingEnabled;
  8462. /**
  8463. * Gets wether the tone mapping effect is enabled.
  8464. */
  8465. get toneMappingEnabled(): boolean;
  8466. /**
  8467. * Sets wether the tone mapping effect is enabled.
  8468. */
  8469. set toneMappingEnabled(value: boolean);
  8470. private _toneMappingType;
  8471. /**
  8472. * Gets the type of tone mapping effect.
  8473. */
  8474. get toneMappingType(): number;
  8475. /**
  8476. * Sets the type of tone mapping effect used in BabylonJS.
  8477. */
  8478. set toneMappingType(value: number);
  8479. protected _contrast: number;
  8480. /**
  8481. * Gets the contrast used in the effect.
  8482. */
  8483. get contrast(): number;
  8484. /**
  8485. * Sets the contrast used in the effect.
  8486. */
  8487. set contrast(value: number);
  8488. /**
  8489. * Vignette stretch size.
  8490. */
  8491. vignetteStretch: number;
  8492. /**
  8493. * Vignette centre X Offset.
  8494. */
  8495. vignetteCentreX: number;
  8496. /**
  8497. * Vignette centre Y Offset.
  8498. */
  8499. vignetteCentreY: number;
  8500. /**
  8501. * Vignette weight or intensity of the vignette effect.
  8502. */
  8503. vignetteWeight: number;
  8504. /**
  8505. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8506. * if vignetteEnabled is set to true.
  8507. */
  8508. vignetteColor: Color4;
  8509. /**
  8510. * Camera field of view used by the Vignette effect.
  8511. */
  8512. vignetteCameraFov: number;
  8513. private _vignetteBlendMode;
  8514. /**
  8515. * Gets the vignette blend mode allowing different kind of effect.
  8516. */
  8517. get vignetteBlendMode(): number;
  8518. /**
  8519. * Sets the vignette blend mode allowing different kind of effect.
  8520. */
  8521. set vignetteBlendMode(value: number);
  8522. private _vignetteEnabled;
  8523. /**
  8524. * Gets wether the vignette effect is enabled.
  8525. */
  8526. get vignetteEnabled(): boolean;
  8527. /**
  8528. * Sets wether the vignette effect is enabled.
  8529. */
  8530. set vignetteEnabled(value: boolean);
  8531. private _applyByPostProcess;
  8532. /**
  8533. * Gets wether the image processing is applied through a post process or not.
  8534. */
  8535. get applyByPostProcess(): boolean;
  8536. /**
  8537. * Sets wether the image processing is applied through a post process or not.
  8538. */
  8539. set applyByPostProcess(value: boolean);
  8540. private _isEnabled;
  8541. /**
  8542. * Gets wether the image processing is enabled or not.
  8543. */
  8544. get isEnabled(): boolean;
  8545. /**
  8546. * Sets wether the image processing is enabled or not.
  8547. */
  8548. set isEnabled(value: boolean);
  8549. /**
  8550. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8551. */
  8552. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8553. /**
  8554. * Method called each time the image processing information changes requires to recompile the effect.
  8555. */
  8556. protected _updateParameters(): void;
  8557. /**
  8558. * Gets the current class name.
  8559. * @return "ImageProcessingConfiguration"
  8560. */
  8561. getClassName(): string;
  8562. /**
  8563. * Prepare the list of uniforms associated with the Image Processing effects.
  8564. * @param uniforms The list of uniforms used in the effect
  8565. * @param defines the list of defines currently in use
  8566. */
  8567. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8568. /**
  8569. * Prepare the list of samplers associated with the Image Processing effects.
  8570. * @param samplersList The list of uniforms used in the effect
  8571. * @param defines the list of defines currently in use
  8572. */
  8573. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8574. /**
  8575. * Prepare the list of defines associated to the shader.
  8576. * @param defines the list of defines to complete
  8577. * @param forPostProcess Define if we are currently in post process mode or not
  8578. */
  8579. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8580. /**
  8581. * Returns true if all the image processing information are ready.
  8582. * @returns True if ready, otherwise, false
  8583. */
  8584. isReady(): boolean;
  8585. /**
  8586. * Binds the image processing to the shader.
  8587. * @param effect The effect to bind to
  8588. * @param overrideAspectRatio Override the aspect ratio of the effect
  8589. */
  8590. bind(effect: Effect, overrideAspectRatio?: number): void;
  8591. /**
  8592. * Clones the current image processing instance.
  8593. * @return The cloned image processing
  8594. */
  8595. clone(): ImageProcessingConfiguration;
  8596. /**
  8597. * Serializes the current image processing instance to a json representation.
  8598. * @return a JSON representation
  8599. */
  8600. serialize(): any;
  8601. /**
  8602. * Parses the image processing from a json representation.
  8603. * @param source the JSON source to parse
  8604. * @return The parsed image processing
  8605. */
  8606. static Parse(source: any): ImageProcessingConfiguration;
  8607. private static _VIGNETTEMODE_MULTIPLY;
  8608. private static _VIGNETTEMODE_OPAQUE;
  8609. /**
  8610. * Used to apply the vignette as a mix with the pixel color.
  8611. */
  8612. static get VIGNETTEMODE_MULTIPLY(): number;
  8613. /**
  8614. * Used to apply the vignette as a replacement of the pixel color.
  8615. */
  8616. static get VIGNETTEMODE_OPAQUE(): number;
  8617. }
  8618. }
  8619. declare module BABYLON {
  8620. /** @hidden */
  8621. export var postprocessVertexShader: {
  8622. name: string;
  8623. shader: string;
  8624. };
  8625. }
  8626. declare module BABYLON {
  8627. /**
  8628. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8629. */
  8630. export type RenderTargetTextureSize = number | {
  8631. width: number;
  8632. height: number;
  8633. layers?: number;
  8634. };
  8635. interface ThinEngine {
  8636. /**
  8637. * Creates a new render target texture
  8638. * @param size defines the size of the texture
  8639. * @param options defines the options used to create the texture
  8640. * @returns a new render target texture stored in an InternalTexture
  8641. */
  8642. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8643. /**
  8644. * Creates a depth stencil texture.
  8645. * This is only available in WebGL 2 or with the depth texture extension available.
  8646. * @param size The size of face edge in the texture.
  8647. * @param options The options defining the texture.
  8648. * @returns The texture
  8649. */
  8650. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8651. /** @hidden */
  8652. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * Defines the kind of connection point for node based material
  8658. */
  8659. export enum NodeMaterialBlockConnectionPointTypes {
  8660. /** Float */
  8661. Float = 1,
  8662. /** Int */
  8663. Int = 2,
  8664. /** Vector2 */
  8665. Vector2 = 4,
  8666. /** Vector3 */
  8667. Vector3 = 8,
  8668. /** Vector4 */
  8669. Vector4 = 16,
  8670. /** Color3 */
  8671. Color3 = 32,
  8672. /** Color4 */
  8673. Color4 = 64,
  8674. /** Matrix */
  8675. Matrix = 128,
  8676. /** Custom object */
  8677. Object = 256,
  8678. /** Detect type based on connection */
  8679. AutoDetect = 1024,
  8680. /** Output type that will be defined by input type */
  8681. BasedOnInput = 2048
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Enum used to define the target of a block
  8687. */
  8688. export enum NodeMaterialBlockTargets {
  8689. /** Vertex shader */
  8690. Vertex = 1,
  8691. /** Fragment shader */
  8692. Fragment = 2,
  8693. /** Neutral */
  8694. Neutral = 4,
  8695. /** Vertex and Fragment */
  8696. VertexAndFragment = 3
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointMode {
  8704. /** Value is an uniform */
  8705. Uniform = 0,
  8706. /** Value is a mesh attribute */
  8707. Attribute = 1,
  8708. /** Value is a varying between vertex and fragment shaders */
  8709. Varying = 2,
  8710. /** Mode is undefined */
  8711. Undefined = 3
  8712. }
  8713. }
  8714. declare module BABYLON {
  8715. /**
  8716. * Enum used to define system values e.g. values automatically provided by the system
  8717. */
  8718. export enum NodeMaterialSystemValues {
  8719. /** World */
  8720. World = 1,
  8721. /** View */
  8722. View = 2,
  8723. /** Projection */
  8724. Projection = 3,
  8725. /** ViewProjection */
  8726. ViewProjection = 4,
  8727. /** WorldView */
  8728. WorldView = 5,
  8729. /** WorldViewProjection */
  8730. WorldViewProjection = 6,
  8731. /** CameraPosition */
  8732. CameraPosition = 7,
  8733. /** Fog Color */
  8734. FogColor = 8,
  8735. /** Delta time */
  8736. DeltaTime = 9
  8737. }
  8738. }
  8739. declare module BABYLON {
  8740. /** Defines supported spaces */
  8741. export enum Space {
  8742. /** Local (object) space */
  8743. LOCAL = 0,
  8744. /** World space */
  8745. WORLD = 1,
  8746. /** Bone space */
  8747. BONE = 2
  8748. }
  8749. /** Defines the 3 main axes */
  8750. export class Axis {
  8751. /** X axis */
  8752. static X: Vector3;
  8753. /** Y axis */
  8754. static Y: Vector3;
  8755. /** Z axis */
  8756. static Z: Vector3;
  8757. }
  8758. }
  8759. declare module BABYLON {
  8760. /**
  8761. * Represents a camera frustum
  8762. */
  8763. export class Frustum {
  8764. /**
  8765. * Gets the planes representing the frustum
  8766. * @param transform matrix to be applied to the returned planes
  8767. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8768. */
  8769. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8770. /**
  8771. * Gets the near frustum plane transformed by the transform matrix
  8772. * @param transform transformation matrix to be applied to the resulting frustum plane
  8773. * @param frustumPlane the resuling frustum plane
  8774. */
  8775. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8776. /**
  8777. * Gets the far frustum plane transformed by the transform matrix
  8778. * @param transform transformation matrix to be applied to the resulting frustum plane
  8779. * @param frustumPlane the resuling frustum plane
  8780. */
  8781. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8782. /**
  8783. * Gets the left frustum plane transformed by the transform matrix
  8784. * @param transform transformation matrix to be applied to the resulting frustum plane
  8785. * @param frustumPlane the resuling frustum plane
  8786. */
  8787. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8788. /**
  8789. * Gets the right frustum plane transformed by the transform matrix
  8790. * @param transform transformation matrix to be applied to the resulting frustum plane
  8791. * @param frustumPlane the resuling frustum plane
  8792. */
  8793. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8794. /**
  8795. * Gets the top frustum plane transformed by the transform matrix
  8796. * @param transform transformation matrix to be applied to the resulting frustum plane
  8797. * @param frustumPlane the resuling frustum plane
  8798. */
  8799. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8800. /**
  8801. * Gets the bottom frustum plane transformed by the transform matrix
  8802. * @param transform transformation matrix to be applied to the resulting frustum plane
  8803. * @param frustumPlane the resuling frustum plane
  8804. */
  8805. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8806. /**
  8807. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8808. * @param transform transformation matrix to be applied to the resulting frustum planes
  8809. * @param frustumPlanes the resuling frustum planes
  8810. */
  8811. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Interface for the size containing width and height
  8817. */
  8818. export interface ISize {
  8819. /**
  8820. * Width
  8821. */
  8822. width: number;
  8823. /**
  8824. * Heighht
  8825. */
  8826. height: number;
  8827. }
  8828. /**
  8829. * Size containing widht and height
  8830. */
  8831. export class Size implements ISize {
  8832. /**
  8833. * Width
  8834. */
  8835. width: number;
  8836. /**
  8837. * Height
  8838. */
  8839. height: number;
  8840. /**
  8841. * Creates a Size object from the given width and height (floats).
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. */
  8845. constructor(width: number, height: number);
  8846. /**
  8847. * Returns a string with the Size width and height
  8848. * @returns a string with the Size width and height
  8849. */
  8850. toString(): string;
  8851. /**
  8852. * "Size"
  8853. * @returns the string "Size"
  8854. */
  8855. getClassName(): string;
  8856. /**
  8857. * Returns the Size hash code.
  8858. * @returns a hash code for a unique width and height
  8859. */
  8860. getHashCode(): number;
  8861. /**
  8862. * Updates the current size from the given one.
  8863. * @param src the given size
  8864. */
  8865. copyFrom(src: Size): void;
  8866. /**
  8867. * Updates in place the current Size from the given floats.
  8868. * @param width width of the new size
  8869. * @param height height of the new size
  8870. * @returns the updated Size.
  8871. */
  8872. copyFromFloats(width: number, height: number): Size;
  8873. /**
  8874. * Updates in place the current Size from the given floats.
  8875. * @param width width to set
  8876. * @param height height to set
  8877. * @returns the updated Size.
  8878. */
  8879. set(width: number, height: number): Size;
  8880. /**
  8881. * Multiplies the width and height by numbers
  8882. * @param w factor to multiple the width by
  8883. * @param h factor to multiple the height by
  8884. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8885. */
  8886. multiplyByFloats(w: number, h: number): Size;
  8887. /**
  8888. * Clones the size
  8889. * @returns a new Size copied from the given one.
  8890. */
  8891. clone(): Size;
  8892. /**
  8893. * True if the current Size and the given one width and height are strictly equal.
  8894. * @param other the other size to compare against
  8895. * @returns True if the current Size and the given one width and height are strictly equal.
  8896. */
  8897. equals(other: Size): boolean;
  8898. /**
  8899. * The surface of the Size : width * height (float).
  8900. */
  8901. get surface(): number;
  8902. /**
  8903. * Create a new size of zero
  8904. * @returns a new Size set to (0.0, 0.0)
  8905. */
  8906. static Zero(): Size;
  8907. /**
  8908. * Sums the width and height of two sizes
  8909. * @param otherSize size to add to this size
  8910. * @returns a new Size set as the addition result of the current Size and the given one.
  8911. */
  8912. add(otherSize: Size): Size;
  8913. /**
  8914. * Subtracts the width and height of two
  8915. * @param otherSize size to subtract to this size
  8916. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8917. */
  8918. subtract(otherSize: Size): Size;
  8919. /**
  8920. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8921. * @param start starting size to lerp between
  8922. * @param end end size to lerp between
  8923. * @param amount amount to lerp between the start and end values
  8924. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8925. */
  8926. static Lerp(start: Size, end: Size, amount: number): Size;
  8927. }
  8928. }
  8929. declare module BABYLON {
  8930. /**
  8931. * Contains position and normal vectors for a vertex
  8932. */
  8933. export class PositionNormalVertex {
  8934. /** the position of the vertex (defaut: 0,0,0) */
  8935. position: Vector3;
  8936. /** the normal of the vertex (defaut: 0,1,0) */
  8937. normal: Vector3;
  8938. /**
  8939. * Creates a PositionNormalVertex
  8940. * @param position the position of the vertex (defaut: 0,0,0)
  8941. * @param normal the normal of the vertex (defaut: 0,1,0)
  8942. */
  8943. constructor(
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position?: Vector3,
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal?: Vector3);
  8948. /**
  8949. * Clones the PositionNormalVertex
  8950. * @returns the cloned PositionNormalVertex
  8951. */
  8952. clone(): PositionNormalVertex;
  8953. }
  8954. /**
  8955. * Contains position, normal and uv vectors for a vertex
  8956. */
  8957. export class PositionNormalTextureVertex {
  8958. /** the position of the vertex (defaut: 0,0,0) */
  8959. position: Vector3;
  8960. /** the normal of the vertex (defaut: 0,1,0) */
  8961. normal: Vector3;
  8962. /** the uv of the vertex (default: 0,0) */
  8963. uv: Vector2;
  8964. /**
  8965. * Creates a PositionNormalTextureVertex
  8966. * @param position the position of the vertex (defaut: 0,0,0)
  8967. * @param normal the normal of the vertex (defaut: 0,1,0)
  8968. * @param uv the uv of the vertex (default: 0,0)
  8969. */
  8970. constructor(
  8971. /** the position of the vertex (defaut: 0,0,0) */
  8972. position?: Vector3,
  8973. /** the normal of the vertex (defaut: 0,1,0) */
  8974. normal?: Vector3,
  8975. /** the uv of the vertex (default: 0,0) */
  8976. uv?: Vector2);
  8977. /**
  8978. * Clones the PositionNormalTextureVertex
  8979. * @returns the cloned PositionNormalTextureVertex
  8980. */
  8981. clone(): PositionNormalTextureVertex;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Enum defining the type of animations supported by InputBlock
  8987. */
  8988. export enum AnimatedInputBlockTypes {
  8989. /** No animation */
  8990. None = 0,
  8991. /** Time based animation. Will only work for floats */
  8992. Time = 1
  8993. }
  8994. }
  8995. declare module BABYLON {
  8996. /**
  8997. * Interface describing all the common properties and methods a shadow light needs to implement.
  8998. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8999. * as well as binding the different shadow properties to the effects.
  9000. */
  9001. export interface IShadowLight extends Light {
  9002. /**
  9003. * The light id in the scene (used in scene.findLighById for instance)
  9004. */
  9005. id: string;
  9006. /**
  9007. * The position the shdow will be casted from.
  9008. */
  9009. position: Vector3;
  9010. /**
  9011. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9012. */
  9013. direction: Vector3;
  9014. /**
  9015. * The transformed position. Position of the light in world space taking parenting in account.
  9016. */
  9017. transformedPosition: Vector3;
  9018. /**
  9019. * The transformed direction. Direction of the light in world space taking parenting in account.
  9020. */
  9021. transformedDirection: Vector3;
  9022. /**
  9023. * The friendly name of the light in the scene.
  9024. */
  9025. name: string;
  9026. /**
  9027. * Defines the shadow projection clipping minimum z value.
  9028. */
  9029. shadowMinZ: number;
  9030. /**
  9031. * Defines the shadow projection clipping maximum z value.
  9032. */
  9033. shadowMaxZ: number;
  9034. /**
  9035. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9036. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9037. */
  9038. computeTransformedInformation(): boolean;
  9039. /**
  9040. * Gets the scene the light belongs to.
  9041. * @returns The scene
  9042. */
  9043. getScene(): Scene;
  9044. /**
  9045. * Callback defining a custom Projection Matrix Builder.
  9046. * This can be used to override the default projection matrix computation.
  9047. */
  9048. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9049. /**
  9050. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9051. * @param matrix The materix to updated with the projection information
  9052. * @param viewMatrix The transform matrix of the light
  9053. * @param renderList The list of mesh to render in the map
  9054. * @returns The current light
  9055. */
  9056. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9057. /**
  9058. * Gets the current depth scale used in ESM.
  9059. * @returns The scale
  9060. */
  9061. getDepthScale(): number;
  9062. /**
  9063. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9064. * @returns true if a cube texture needs to be use
  9065. */
  9066. needCube(): boolean;
  9067. /**
  9068. * Detects if the projection matrix requires to be recomputed this frame.
  9069. * @returns true if it requires to be recomputed otherwise, false.
  9070. */
  9071. needProjectionMatrixCompute(): boolean;
  9072. /**
  9073. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9074. */
  9075. forceProjectionMatrixCompute(): void;
  9076. /**
  9077. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9078. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9079. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9080. */
  9081. getShadowDirection(faceIndex?: number): Vector3;
  9082. /**
  9083. * Gets the minZ used for shadow according to both the scene and the light.
  9084. * @param activeCamera The camera we are returning the min for
  9085. * @returns the depth min z
  9086. */
  9087. getDepthMinZ(activeCamera: Camera): number;
  9088. /**
  9089. * Gets the maxZ used for shadow according to both the scene and the light.
  9090. * @param activeCamera The camera we are returning the max for
  9091. * @returns the depth max z
  9092. */
  9093. getDepthMaxZ(activeCamera: Camera): number;
  9094. }
  9095. /**
  9096. * Base implementation IShadowLight
  9097. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9098. */
  9099. export abstract class ShadowLight extends Light implements IShadowLight {
  9100. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9101. protected _position: Vector3;
  9102. protected _setPosition(value: Vector3): void;
  9103. /**
  9104. * Sets the position the shadow will be casted from. Also use as the light position for both
  9105. * point and spot lights.
  9106. */
  9107. get position(): Vector3;
  9108. /**
  9109. * Sets the position the shadow will be casted from. Also use as the light position for both
  9110. * point and spot lights.
  9111. */
  9112. set position(value: Vector3);
  9113. protected _direction: Vector3;
  9114. protected _setDirection(value: Vector3): void;
  9115. /**
  9116. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9117. * Also use as the light direction on spot and directional lights.
  9118. */
  9119. get direction(): Vector3;
  9120. /**
  9121. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9122. * Also use as the light direction on spot and directional lights.
  9123. */
  9124. set direction(value: Vector3);
  9125. protected _shadowMinZ: number;
  9126. /**
  9127. * Gets the shadow projection clipping minimum z value.
  9128. */
  9129. get shadowMinZ(): number;
  9130. /**
  9131. * Sets the shadow projection clipping minimum z value.
  9132. */
  9133. set shadowMinZ(value: number);
  9134. protected _shadowMaxZ: number;
  9135. /**
  9136. * Sets the shadow projection clipping maximum z value.
  9137. */
  9138. get shadowMaxZ(): number;
  9139. /**
  9140. * Gets the shadow projection clipping maximum z value.
  9141. */
  9142. set shadowMaxZ(value: number);
  9143. /**
  9144. * Callback defining a custom Projection Matrix Builder.
  9145. * This can be used to override the default projection matrix computation.
  9146. */
  9147. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9148. /**
  9149. * The transformed position. Position of the light in world space taking parenting in account.
  9150. */
  9151. transformedPosition: Vector3;
  9152. /**
  9153. * The transformed direction. Direction of the light in world space taking parenting in account.
  9154. */
  9155. transformedDirection: Vector3;
  9156. private _needProjectionMatrixCompute;
  9157. /**
  9158. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9159. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9160. */
  9161. computeTransformedInformation(): boolean;
  9162. /**
  9163. * Return the depth scale used for the shadow map.
  9164. * @returns the depth scale.
  9165. */
  9166. getDepthScale(): number;
  9167. /**
  9168. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9169. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9170. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9171. */
  9172. getShadowDirection(faceIndex?: number): Vector3;
  9173. /**
  9174. * Returns the ShadowLight absolute position in the World.
  9175. * @returns the position vector in world space
  9176. */
  9177. getAbsolutePosition(): Vector3;
  9178. /**
  9179. * Sets the ShadowLight direction toward the passed target.
  9180. * @param target The point to target in local space
  9181. * @returns the updated ShadowLight direction
  9182. */
  9183. setDirectionToTarget(target: Vector3): Vector3;
  9184. /**
  9185. * Returns the light rotation in euler definition.
  9186. * @returns the x y z rotation in local space.
  9187. */
  9188. getRotation(): Vector3;
  9189. /**
  9190. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9191. * @returns true if a cube texture needs to be use
  9192. */
  9193. needCube(): boolean;
  9194. /**
  9195. * Detects if the projection matrix requires to be recomputed this frame.
  9196. * @returns true if it requires to be recomputed otherwise, false.
  9197. */
  9198. needProjectionMatrixCompute(): boolean;
  9199. /**
  9200. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9201. */
  9202. forceProjectionMatrixCompute(): void;
  9203. /** @hidden */
  9204. _initCache(): void;
  9205. /** @hidden */
  9206. _isSynchronized(): boolean;
  9207. /**
  9208. * Computes the world matrix of the node
  9209. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9210. * @returns the world matrix
  9211. */
  9212. computeWorldMatrix(force?: boolean): Matrix;
  9213. /**
  9214. * Gets the minZ used for shadow according to both the scene and the light.
  9215. * @param activeCamera The camera we are returning the min for
  9216. * @returns the depth min z
  9217. */
  9218. getDepthMinZ(activeCamera: Camera): number;
  9219. /**
  9220. * Gets the maxZ used for shadow according to both the scene and the light.
  9221. * @param activeCamera The camera we are returning the max for
  9222. * @returns the depth max z
  9223. */
  9224. getDepthMaxZ(activeCamera: Camera): number;
  9225. /**
  9226. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9227. * @param matrix The materix to updated with the projection information
  9228. * @param viewMatrix The transform matrix of the light
  9229. * @param renderList The list of mesh to render in the map
  9230. * @returns The current light
  9231. */
  9232. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9233. }
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. export var packingFunctions: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module BABYLON {
  9243. /** @hidden */
  9244. export var bayerDitherFunctions: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module BABYLON {
  9250. /** @hidden */
  9251. export var shadowMapFragmentDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module BABYLON {
  9257. /** @hidden */
  9258. export var clipPlaneFragmentDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var clipPlaneFragment: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var shadowMapFragment: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var shadowMapPixelShader: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var bonesDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var morphTargetsVertexGlobalDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var morphTargetsVertexDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var instancesDeclaration: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var helperFunctions: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var shadowMapVertexDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var clipPlaneVertexDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertex: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesVertex: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var bonesVertex: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var shadowMapVertexNormalBias: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapVertexMetric: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var clipPlaneVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapVertexShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var depthBoxBlurPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapFragmentSoftTransparentShadow: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /**
  9398. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9399. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9400. */
  9401. export class EffectFallbacks implements IEffectFallbacks {
  9402. private _defines;
  9403. private _currentRank;
  9404. private _maxRank;
  9405. private _mesh;
  9406. /**
  9407. * Removes the fallback from the bound mesh.
  9408. */
  9409. unBindMesh(): void;
  9410. /**
  9411. * Adds a fallback on the specified property.
  9412. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9413. * @param define The name of the define in the shader
  9414. */
  9415. addFallback(rank: number, define: string): void;
  9416. /**
  9417. * Sets the mesh to use CPU skinning when needing to fallback.
  9418. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9419. * @param mesh The mesh to use the fallbacks.
  9420. */
  9421. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9422. /**
  9423. * Checks to see if more fallbacks are still availible.
  9424. */
  9425. get hasMoreFallbacks(): boolean;
  9426. /**
  9427. * Removes the defines that should be removed when falling back.
  9428. * @param currentDefines defines the current define statements for the shader.
  9429. * @param effect defines the current effect we try to compile
  9430. * @returns The resulting defines with defines of the current rank removed.
  9431. */
  9432. reduce(currentDefines: string, effect: Effect): string;
  9433. }
  9434. }
  9435. declare module BABYLON {
  9436. /**
  9437. * Interface used to define Action
  9438. */
  9439. export interface IAction {
  9440. /**
  9441. * Trigger for the action
  9442. */
  9443. trigger: number;
  9444. /** Options of the trigger */
  9445. triggerOptions: any;
  9446. /**
  9447. * Gets the trigger parameters
  9448. * @returns the trigger parameters
  9449. */
  9450. getTriggerParameter(): any;
  9451. /**
  9452. * Internal only - executes current action event
  9453. * @hidden
  9454. */
  9455. _executeCurrent(evt?: ActionEvent): void;
  9456. /**
  9457. * Serialize placeholder for child classes
  9458. * @param parent of child
  9459. * @returns the serialized object
  9460. */
  9461. serialize(parent: any): any;
  9462. /**
  9463. * Internal only
  9464. * @hidden
  9465. */
  9466. _prepare(): void;
  9467. /**
  9468. * Internal only - manager for action
  9469. * @hidden
  9470. */
  9471. _actionManager: Nullable<AbstractActionManager>;
  9472. /**
  9473. * Adds action to chain of actions, may be a DoNothingAction
  9474. * @param action defines the next action to execute
  9475. * @returns The action passed in
  9476. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9477. */
  9478. then(action: IAction): IAction;
  9479. }
  9480. /**
  9481. * The action to be carried out following a trigger
  9482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9483. */
  9484. export class Action implements IAction {
  9485. /** the trigger, with or without parameters, for the action */
  9486. triggerOptions: any;
  9487. /**
  9488. * Trigger for the action
  9489. */
  9490. trigger: number;
  9491. /**
  9492. * Internal only - manager for action
  9493. * @hidden
  9494. */
  9495. _actionManager: ActionManager;
  9496. private _nextActiveAction;
  9497. private _child;
  9498. private _condition?;
  9499. private _triggerParameter;
  9500. /**
  9501. * An event triggered prior to action being executed.
  9502. */
  9503. onBeforeExecuteObservable: Observable<Action>;
  9504. /**
  9505. * Creates a new Action
  9506. * @param triggerOptions the trigger, with or without parameters, for the action
  9507. * @param condition an optional determinant of action
  9508. */
  9509. constructor(
  9510. /** the trigger, with or without parameters, for the action */
  9511. triggerOptions: any, condition?: Condition);
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. _prepare(): void;
  9517. /**
  9518. * Gets the trigger parameters
  9519. * @returns the trigger parameters
  9520. */
  9521. getTriggerParameter(): any;
  9522. /**
  9523. * Internal only - executes current action event
  9524. * @hidden
  9525. */
  9526. _executeCurrent(evt?: ActionEvent): void;
  9527. /**
  9528. * Execute placeholder for child classes
  9529. * @param evt optional action event
  9530. */
  9531. execute(evt?: ActionEvent): void;
  9532. /**
  9533. * Skips to next active action
  9534. */
  9535. skipToNextActiveAction(): void;
  9536. /**
  9537. * Adds action to chain of actions, may be a DoNothingAction
  9538. * @param action defines the next action to execute
  9539. * @returns The action passed in
  9540. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9541. */
  9542. then(action: Action): Action;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. _getProperty(propertyPath: string): string;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. _getEffectiveTarget(target: any, propertyPath: string): any;
  9553. /**
  9554. * Serialize placeholder for child classes
  9555. * @param parent of child
  9556. * @returns the serialized object
  9557. */
  9558. serialize(parent: any): any;
  9559. /**
  9560. * Internal only called by serialize
  9561. * @hidden
  9562. */
  9563. protected _serialize(serializedAction: any, parent?: any): any;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. static _SerializeValueAsString: (value: any) => string;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. static _GetTargetProperty: (target: Scene | Node) => {
  9574. name: string;
  9575. targetType: string;
  9576. value: string;
  9577. };
  9578. }
  9579. }
  9580. declare module BABYLON {
  9581. /**
  9582. * A Condition applied to an Action
  9583. */
  9584. export class Condition {
  9585. /**
  9586. * Internal only - manager for action
  9587. * @hidden
  9588. */
  9589. _actionManager: ActionManager;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. _evaluationId: number;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. _currentResult: boolean;
  9600. /**
  9601. * Creates a new Condition
  9602. * @param actionManager the manager of the action the condition is applied to
  9603. */
  9604. constructor(actionManager: ActionManager);
  9605. /**
  9606. * Check if the current condition is valid
  9607. * @returns a boolean
  9608. */
  9609. isValid(): boolean;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _getProperty(propertyPath: string): string;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _getEffectiveTarget(target: any, propertyPath: string): any;
  9620. /**
  9621. * Serialize placeholder for child classes
  9622. * @returns the serialized object
  9623. */
  9624. serialize(): any;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. protected _serialize(serializedCondition: any): any;
  9630. }
  9631. /**
  9632. * Defines specific conditional operators as extensions of Condition
  9633. */
  9634. export class ValueCondition extends Condition {
  9635. /** path to specify the property of the target the conditional operator uses */
  9636. propertyPath: string;
  9637. /** the value compared by the conditional operator against the current value of the property */
  9638. value: any;
  9639. /** the conditional operator, default ValueCondition.IsEqual */
  9640. operator: number;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. private static _IsEqual;
  9646. /**
  9647. * Internal only
  9648. * @hidden
  9649. */
  9650. private static _IsDifferent;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. private static _IsGreater;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. private static _IsLesser;
  9661. /**
  9662. * returns the number for IsEqual
  9663. */
  9664. static get IsEqual(): number;
  9665. /**
  9666. * Returns the number for IsDifferent
  9667. */
  9668. static get IsDifferent(): number;
  9669. /**
  9670. * Returns the number for IsGreater
  9671. */
  9672. static get IsGreater(): number;
  9673. /**
  9674. * Returns the number for IsLesser
  9675. */
  9676. static get IsLesser(): number;
  9677. /**
  9678. * Internal only The action manager for the condition
  9679. * @hidden
  9680. */
  9681. _actionManager: ActionManager;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private _target;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. private _effectiveTarget;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. private _property;
  9697. /**
  9698. * Creates a new ValueCondition
  9699. * @param actionManager manager for the action the condition applies to
  9700. * @param target for the action
  9701. * @param propertyPath path to specify the property of the target the conditional operator uses
  9702. * @param value the value compared by the conditional operator against the current value of the property
  9703. * @param operator the conditional operator, default ValueCondition.IsEqual
  9704. */
  9705. constructor(actionManager: ActionManager, target: any,
  9706. /** path to specify the property of the target the conditional operator uses */
  9707. propertyPath: string,
  9708. /** the value compared by the conditional operator against the current value of the property */
  9709. value: any,
  9710. /** the conditional operator, default ValueCondition.IsEqual */
  9711. operator?: number);
  9712. /**
  9713. * Compares the given value with the property value for the specified conditional operator
  9714. * @returns the result of the comparison
  9715. */
  9716. isValid(): boolean;
  9717. /**
  9718. * Serialize the ValueCondition into a JSON compatible object
  9719. * @returns serialization object
  9720. */
  9721. serialize(): any;
  9722. /**
  9723. * Gets the name of the conditional operator for the ValueCondition
  9724. * @param operator the conditional operator
  9725. * @returns the name
  9726. */
  9727. static GetOperatorName(operator: number): string;
  9728. }
  9729. /**
  9730. * Defines a predicate condition as an extension of Condition
  9731. */
  9732. export class PredicateCondition extends Condition {
  9733. /** defines the predicate function used to validate the condition */
  9734. predicate: () => boolean;
  9735. /**
  9736. * Internal only - manager for action
  9737. * @hidden
  9738. */
  9739. _actionManager: ActionManager;
  9740. /**
  9741. * Creates a new PredicateCondition
  9742. * @param actionManager manager for the action the condition applies to
  9743. * @param predicate defines the predicate function used to validate the condition
  9744. */
  9745. constructor(actionManager: ActionManager,
  9746. /** defines the predicate function used to validate the condition */
  9747. predicate: () => boolean);
  9748. /**
  9749. * @returns the validity of the predicate condition
  9750. */
  9751. isValid(): boolean;
  9752. }
  9753. /**
  9754. * Defines a state condition as an extension of Condition
  9755. */
  9756. export class StateCondition extends Condition {
  9757. /** Value to compare with target state */
  9758. value: string;
  9759. /**
  9760. * Internal only - manager for action
  9761. * @hidden
  9762. */
  9763. _actionManager: ActionManager;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. private _target;
  9769. /**
  9770. * Creates a new StateCondition
  9771. * @param actionManager manager for the action the condition applies to
  9772. * @param target of the condition
  9773. * @param value to compare with target state
  9774. */
  9775. constructor(actionManager: ActionManager, target: any,
  9776. /** Value to compare with target state */
  9777. value: string);
  9778. /**
  9779. * Gets a boolean indicating if the current condition is met
  9780. * @returns the validity of the state
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Serialize the StateCondition into a JSON compatible object
  9785. * @returns serialization object
  9786. */
  9787. serialize(): any;
  9788. }
  9789. }
  9790. declare module BABYLON {
  9791. /**
  9792. * This defines an action responsible to toggle a boolean once triggered.
  9793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9794. */
  9795. export class SwitchBooleanAction extends Action {
  9796. /**
  9797. * The path to the boolean property in the target object
  9798. */
  9799. propertyPath: string;
  9800. private _target;
  9801. private _effectiveTarget;
  9802. private _property;
  9803. /**
  9804. * Instantiate the action
  9805. * @param triggerOptions defines the trigger options
  9806. * @param target defines the object containing the boolean
  9807. * @param propertyPath defines the path to the boolean property in the target object
  9808. * @param condition defines the trigger related conditions
  9809. */
  9810. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9811. /** @hidden */
  9812. _prepare(): void;
  9813. /**
  9814. * Execute the action toggle the boolean value.
  9815. */
  9816. execute(): void;
  9817. /**
  9818. * Serializes the actions and its related information.
  9819. * @param parent defines the object to serialize in
  9820. * @returns the serialized object
  9821. */
  9822. serialize(parent: any): any;
  9823. }
  9824. /**
  9825. * This defines an action responsible to set a the state field of the target
  9826. * to a desired value once triggered.
  9827. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9828. */
  9829. export class SetStateAction extends Action {
  9830. /**
  9831. * The value to store in the state field.
  9832. */
  9833. value: string;
  9834. private _target;
  9835. /**
  9836. * Instantiate the action
  9837. * @param triggerOptions defines the trigger options
  9838. * @param target defines the object containing the state property
  9839. * @param value defines the value to store in the state field
  9840. * @param condition defines the trigger related conditions
  9841. */
  9842. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9843. /**
  9844. * Execute the action and store the value on the target state property.
  9845. */
  9846. execute(): void;
  9847. /**
  9848. * Serializes the actions and its related information.
  9849. * @param parent defines the object to serialize in
  9850. * @returns the serialized object
  9851. */
  9852. serialize(parent: any): any;
  9853. }
  9854. /**
  9855. * This defines an action responsible to set a property of the target
  9856. * to a desired value once triggered.
  9857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9858. */
  9859. export class SetValueAction extends Action {
  9860. /**
  9861. * The path of the property to set in the target.
  9862. */
  9863. propertyPath: string;
  9864. /**
  9865. * The value to set in the property
  9866. */
  9867. value: any;
  9868. private _target;
  9869. private _effectiveTarget;
  9870. private _property;
  9871. /**
  9872. * Instantiate the action
  9873. * @param triggerOptions defines the trigger options
  9874. * @param target defines the object containing the property
  9875. * @param propertyPath defines the path of the property to set in the target
  9876. * @param value defines the value to set in the property
  9877. * @param condition defines the trigger related conditions
  9878. */
  9879. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9880. /** @hidden */
  9881. _prepare(): void;
  9882. /**
  9883. * Execute the action and set the targetted property to the desired value.
  9884. */
  9885. execute(): void;
  9886. /**
  9887. * Serializes the actions and its related information.
  9888. * @param parent defines the object to serialize in
  9889. * @returns the serialized object
  9890. */
  9891. serialize(parent: any): any;
  9892. }
  9893. /**
  9894. * This defines an action responsible to increment the target value
  9895. * to a desired value once triggered.
  9896. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9897. */
  9898. export class IncrementValueAction extends Action {
  9899. /**
  9900. * The path of the property to increment in the target.
  9901. */
  9902. propertyPath: string;
  9903. /**
  9904. * The value we should increment the property by.
  9905. */
  9906. value: any;
  9907. private _target;
  9908. private _effectiveTarget;
  9909. private _property;
  9910. /**
  9911. * Instantiate the action
  9912. * @param triggerOptions defines the trigger options
  9913. * @param target defines the object containing the property
  9914. * @param propertyPath defines the path of the property to increment in the target
  9915. * @param value defines the value value we should increment the property by
  9916. * @param condition defines the trigger related conditions
  9917. */
  9918. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9919. /** @hidden */
  9920. _prepare(): void;
  9921. /**
  9922. * Execute the action and increment the target of the value amount.
  9923. */
  9924. execute(): void;
  9925. /**
  9926. * Serializes the actions and its related information.
  9927. * @param parent defines the object to serialize in
  9928. * @returns the serialized object
  9929. */
  9930. serialize(parent: any): any;
  9931. }
  9932. /**
  9933. * This defines an action responsible to start an animation once triggered.
  9934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class PlayAnimationAction extends Action {
  9937. /**
  9938. * Where the animation should start (animation frame)
  9939. */
  9940. from: number;
  9941. /**
  9942. * Where the animation should stop (animation frame)
  9943. */
  9944. to: number;
  9945. /**
  9946. * Define if the animation should loop or stop after the first play.
  9947. */
  9948. loop?: boolean;
  9949. private _target;
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param target defines the target animation or animation name
  9954. * @param from defines from where the animation should start (animation frame)
  9955. * @param end defines where the animation should stop (animation frame)
  9956. * @param loop defines if the animation should loop or stop after the first play
  9957. * @param condition defines the trigger related conditions
  9958. */
  9959. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9960. /** @hidden */
  9961. _prepare(): void;
  9962. /**
  9963. * Execute the action and play the animation.
  9964. */
  9965. execute(): void;
  9966. /**
  9967. * Serializes the actions and its related information.
  9968. * @param parent defines the object to serialize in
  9969. * @returns the serialized object
  9970. */
  9971. serialize(parent: any): any;
  9972. }
  9973. /**
  9974. * This defines an action responsible to stop an animation once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class StopAnimationAction extends Action {
  9978. private _target;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the target animation or animation name
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and stop the animation.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible that does nothing once triggered.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class DoNothingAction extends Action {
  10004. /**
  10005. * Instantiate the action
  10006. * @param triggerOptions defines the trigger options
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions?: any, condition?: Condition);
  10010. /**
  10011. * Execute the action and do nothing.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to trigger several actions once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class CombineAction extends Action {
  10026. /**
  10027. * The list of aggregated animations to run.
  10028. */
  10029. children: Action[];
  10030. /**
  10031. * Instantiate the action
  10032. * @param triggerOptions defines the trigger options
  10033. * @param children defines the list of aggregated animations to run
  10034. * @param condition defines the trigger related conditions
  10035. */
  10036. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10037. /** @hidden */
  10038. _prepare(): void;
  10039. /**
  10040. * Execute the action and executes all the aggregated actions.
  10041. */
  10042. execute(evt: ActionEvent): void;
  10043. /**
  10044. * Serializes the actions and its related information.
  10045. * @param parent defines the object to serialize in
  10046. * @returns the serialized object
  10047. */
  10048. serialize(parent: any): any;
  10049. }
  10050. /**
  10051. * This defines an action responsible to run code (external event) once triggered.
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10053. */
  10054. export class ExecuteCodeAction extends Action {
  10055. /**
  10056. * The callback function to run.
  10057. */
  10058. func: (evt: ActionEvent) => void;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param func defines the callback function to run
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10066. /**
  10067. * Execute the action and run the attached code.
  10068. */
  10069. execute(evt: ActionEvent): void;
  10070. }
  10071. /**
  10072. * This defines an action responsible to set the parent property of the target once triggered.
  10073. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10074. */
  10075. export class SetParentAction extends Action {
  10076. private _parent;
  10077. private _target;
  10078. /**
  10079. * Instantiate the action
  10080. * @param triggerOptions defines the trigger options
  10081. * @param target defines the target containing the parent property
  10082. * @param parent defines from where the animation should start (animation frame)
  10083. * @param condition defines the trigger related conditions
  10084. */
  10085. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10086. /** @hidden */
  10087. _prepare(): void;
  10088. /**
  10089. * Execute the action and set the parent property.
  10090. */
  10091. execute(): void;
  10092. /**
  10093. * Serializes the actions and its related information.
  10094. * @param parent defines the object to serialize in
  10095. * @returns the serialized object
  10096. */
  10097. serialize(parent: any): any;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /**
  10102. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10103. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10105. */
  10106. export class ActionManager extends AbstractActionManager {
  10107. /**
  10108. * Nothing
  10109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10110. */
  10111. static readonly NothingTrigger: number;
  10112. /**
  10113. * On pick
  10114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10115. */
  10116. static readonly OnPickTrigger: number;
  10117. /**
  10118. * On left pick
  10119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10120. */
  10121. static readonly OnLeftPickTrigger: number;
  10122. /**
  10123. * On right pick
  10124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10125. */
  10126. static readonly OnRightPickTrigger: number;
  10127. /**
  10128. * On center pick
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10130. */
  10131. static readonly OnCenterPickTrigger: number;
  10132. /**
  10133. * On pick down
  10134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10135. */
  10136. static readonly OnPickDownTrigger: number;
  10137. /**
  10138. * On double pick
  10139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10140. */
  10141. static readonly OnDoublePickTrigger: number;
  10142. /**
  10143. * On pick up
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10145. */
  10146. static readonly OnPickUpTrigger: number;
  10147. /**
  10148. * On pick out.
  10149. * This trigger will only be raised if you also declared a OnPickDown
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnPickOutTrigger: number;
  10153. /**
  10154. * On long press
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnLongPressTrigger: number;
  10158. /**
  10159. * On pointer over
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPointerOverTrigger: number;
  10163. /**
  10164. * On pointer out
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPointerOutTrigger: number;
  10168. /**
  10169. * On every frame
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnEveryFrameTrigger: number;
  10173. /**
  10174. * On intersection enter
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnIntersectionEnterTrigger: number;
  10178. /**
  10179. * On intersection exit
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnIntersectionExitTrigger: number;
  10183. /**
  10184. * On key down
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnKeyDownTrigger: number;
  10188. /**
  10189. * On key up
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnKeyUpTrigger: number;
  10193. private _scene;
  10194. /**
  10195. * Creates a new action manager
  10196. * @param scene defines the hosting scene
  10197. */
  10198. constructor(scene: Scene);
  10199. /**
  10200. * Releases all associated resources
  10201. */
  10202. dispose(): void;
  10203. /**
  10204. * Gets hosting scene
  10205. * @returns the hosting scene
  10206. */
  10207. getScene(): Scene;
  10208. /**
  10209. * Does this action manager handles actions of any of the given triggers
  10210. * @param triggers defines the triggers to be tested
  10211. * @return a boolean indicating whether one (or more) of the triggers is handled
  10212. */
  10213. hasSpecificTriggers(triggers: number[]): boolean;
  10214. /**
  10215. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10216. * speed.
  10217. * @param triggerA defines the trigger to be tested
  10218. * @param triggerB defines the trigger to be tested
  10219. * @return a boolean indicating whether one (or more) of the triggers is handled
  10220. */
  10221. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10222. /**
  10223. * Does this action manager handles actions of a given trigger
  10224. * @param trigger defines the trigger to be tested
  10225. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10226. * @return whether the trigger is handled
  10227. */
  10228. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10229. /**
  10230. * Does this action manager has pointer triggers
  10231. */
  10232. get hasPointerTriggers(): boolean;
  10233. /**
  10234. * Does this action manager has pick triggers
  10235. */
  10236. get hasPickTriggers(): boolean;
  10237. /**
  10238. * Registers an action to this action manager
  10239. * @param action defines the action to be registered
  10240. * @return the action amended (prepared) after registration
  10241. */
  10242. registerAction(action: IAction): Nullable<IAction>;
  10243. /**
  10244. * Unregisters an action to this action manager
  10245. * @param action defines the action to be unregistered
  10246. * @return a boolean indicating whether the action has been unregistered
  10247. */
  10248. unregisterAction(action: IAction): Boolean;
  10249. /**
  10250. * Process a specific trigger
  10251. * @param trigger defines the trigger to process
  10252. * @param evt defines the event details to be processed
  10253. */
  10254. processTrigger(trigger: number, evt?: IActionEvent): void;
  10255. /** @hidden */
  10256. _getEffectiveTarget(target: any, propertyPath: string): any;
  10257. /** @hidden */
  10258. _getProperty(propertyPath: string): string;
  10259. /**
  10260. * Serialize this manager to a JSON object
  10261. * @param name defines the property name to store this manager
  10262. * @returns a JSON representation of this manager
  10263. */
  10264. serialize(name: string): any;
  10265. /**
  10266. * Creates a new ActionManager from a JSON data
  10267. * @param parsedActions defines the JSON data to read from
  10268. * @param object defines the hosting mesh
  10269. * @param scene defines the hosting scene
  10270. */
  10271. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10272. /**
  10273. * Get a trigger name by index
  10274. * @param trigger defines the trigger index
  10275. * @returns a trigger name
  10276. */
  10277. static GetTriggerName(trigger: number): string;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Class used to represent a sprite
  10283. * @see https://doc.babylonjs.com/babylon101/sprites
  10284. */
  10285. export class Sprite implements IAnimatable {
  10286. /** defines the name */
  10287. name: string;
  10288. /** Gets or sets the current world position */
  10289. position: Vector3;
  10290. /** Gets or sets the main color */
  10291. color: Color4;
  10292. /** Gets or sets the width */
  10293. width: number;
  10294. /** Gets or sets the height */
  10295. height: number;
  10296. /** Gets or sets rotation angle */
  10297. angle: number;
  10298. /** Gets or sets the cell index in the sprite sheet */
  10299. cellIndex: number;
  10300. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10301. cellRef: string;
  10302. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10303. invertU: boolean;
  10304. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10305. invertV: boolean;
  10306. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10307. disposeWhenFinishedAnimating: boolean;
  10308. /** Gets the list of attached animations */
  10309. animations: Nullable<Array<Animation>>;
  10310. /** Gets or sets a boolean indicating if the sprite can be picked */
  10311. isPickable: boolean;
  10312. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10313. useAlphaForPicking: boolean;
  10314. /** @hidden */
  10315. _xOffset: number;
  10316. /** @hidden */
  10317. _yOffset: number;
  10318. /** @hidden */
  10319. _xSize: number;
  10320. /** @hidden */
  10321. _ySize: number;
  10322. /**
  10323. * Gets or sets the associated action manager
  10324. */
  10325. actionManager: Nullable<ActionManager>;
  10326. /**
  10327. * An event triggered when the control has been disposed
  10328. */
  10329. onDisposeObservable: Observable<Sprite>;
  10330. private _animationStarted;
  10331. private _loopAnimation;
  10332. private _fromIndex;
  10333. private _toIndex;
  10334. private _delay;
  10335. private _direction;
  10336. private _manager;
  10337. private _time;
  10338. private _onAnimationEnd;
  10339. /**
  10340. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10341. */
  10342. isVisible: boolean;
  10343. /**
  10344. * Gets or sets the sprite size
  10345. */
  10346. get size(): number;
  10347. set size(value: number);
  10348. /**
  10349. * Returns a boolean indicating if the animation is started
  10350. */
  10351. get animationStarted(): boolean;
  10352. /**
  10353. * Gets or sets the unique id of the sprite
  10354. */
  10355. uniqueId: number;
  10356. /**
  10357. * Gets the manager of this sprite
  10358. */
  10359. get manager(): ISpriteManager;
  10360. /**
  10361. * Creates a new Sprite
  10362. * @param name defines the name
  10363. * @param manager defines the manager
  10364. */
  10365. constructor(
  10366. /** defines the name */
  10367. name: string, manager: ISpriteManager);
  10368. /**
  10369. * Returns the string "Sprite"
  10370. * @returns "Sprite"
  10371. */
  10372. getClassName(): string;
  10373. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10374. get fromIndex(): number;
  10375. set fromIndex(value: number);
  10376. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10377. get toIndex(): number;
  10378. set toIndex(value: number);
  10379. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10380. get loopAnimation(): boolean;
  10381. set loopAnimation(value: boolean);
  10382. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10383. get delay(): number;
  10384. set delay(value: number);
  10385. /**
  10386. * Starts an animation
  10387. * @param from defines the initial key
  10388. * @param to defines the end key
  10389. * @param loop defines if the animation must loop
  10390. * @param delay defines the start delay (in ms)
  10391. * @param onAnimationEnd defines a callback to call when animation ends
  10392. */
  10393. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10394. /** Stops current animation (if any) */
  10395. stopAnimation(): void;
  10396. /** @hidden */
  10397. _animate(deltaTime: number): void;
  10398. /** Release associated resources */
  10399. dispose(): void;
  10400. /**
  10401. * Serializes the sprite to a JSON object
  10402. * @returns the JSON object
  10403. */
  10404. serialize(): any;
  10405. /**
  10406. * Parses a JSON object to create a new sprite
  10407. * @param parsedSprite The JSON object to parse
  10408. * @param manager defines the hosting manager
  10409. * @returns the new sprite
  10410. */
  10411. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10412. }
  10413. }
  10414. declare module BABYLON {
  10415. /**
  10416. * Information about the result of picking within a scene
  10417. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10418. */
  10419. export class PickingInfo {
  10420. /** @hidden */
  10421. _pickingUnavailable: boolean;
  10422. /**
  10423. * If the pick collided with an object
  10424. */
  10425. hit: boolean;
  10426. /**
  10427. * Distance away where the pick collided
  10428. */
  10429. distance: number;
  10430. /**
  10431. * The location of pick collision
  10432. */
  10433. pickedPoint: Nullable<Vector3>;
  10434. /**
  10435. * The mesh corresponding the the pick collision
  10436. */
  10437. pickedMesh: Nullable<AbstractMesh>;
  10438. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10439. bu: number;
  10440. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10441. bv: number;
  10442. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10443. faceId: number;
  10444. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10445. subMeshFaceId: number;
  10446. /** Id of the the submesh that was picked */
  10447. subMeshId: number;
  10448. /** If a sprite was picked, this will be the sprite the pick collided with */
  10449. pickedSprite: Nullable<Sprite>;
  10450. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10451. thinInstanceIndex: number;
  10452. /**
  10453. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10454. */
  10455. originMesh: Nullable<AbstractMesh>;
  10456. /**
  10457. * The ray that was used to perform the picking.
  10458. */
  10459. ray: Nullable<Ray>;
  10460. /**
  10461. * Gets the normal correspodning to the face the pick collided with
  10462. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10463. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10464. * @returns The normal correspodning to the face the pick collided with
  10465. */
  10466. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10467. /**
  10468. * Gets the texture coordinates of where the pick occured
  10469. * @returns the vector containing the coordnates of the texture
  10470. */
  10471. getTextureCoordinates(): Nullable<Vector2>;
  10472. }
  10473. }
  10474. declare module BABYLON {
  10475. /**
  10476. * Class representing a ray with position and direction
  10477. */
  10478. export class Ray {
  10479. /** origin point */
  10480. origin: Vector3;
  10481. /** direction */
  10482. direction: Vector3;
  10483. /** length of the ray */
  10484. length: number;
  10485. private static readonly _TmpVector3;
  10486. private _tmpRay;
  10487. /**
  10488. * Creates a new ray
  10489. * @param origin origin point
  10490. * @param direction direction
  10491. * @param length length of the ray
  10492. */
  10493. constructor(
  10494. /** origin point */
  10495. origin: Vector3,
  10496. /** direction */
  10497. direction: Vector3,
  10498. /** length of the ray */
  10499. length?: number);
  10500. /**
  10501. * Checks if the ray intersects a box
  10502. * This does not account for the ray lenght by design to improve perfs.
  10503. * @param minimum bound of the box
  10504. * @param maximum bound of the box
  10505. * @param intersectionTreshold extra extend to be added to the box in all direction
  10506. * @returns if the box was hit
  10507. */
  10508. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10509. /**
  10510. * Checks if the ray intersects a box
  10511. * This does not account for the ray lenght by design to improve perfs.
  10512. * @param box the bounding box to check
  10513. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10514. * @returns if the box was hit
  10515. */
  10516. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10517. /**
  10518. * If the ray hits a sphere
  10519. * @param sphere the bounding sphere to check
  10520. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10521. * @returns true if it hits the sphere
  10522. */
  10523. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10524. /**
  10525. * If the ray hits a triange
  10526. * @param vertex0 triangle vertex
  10527. * @param vertex1 triangle vertex
  10528. * @param vertex2 triangle vertex
  10529. * @returns intersection information if hit
  10530. */
  10531. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10532. /**
  10533. * Checks if ray intersects a plane
  10534. * @param plane the plane to check
  10535. * @returns the distance away it was hit
  10536. */
  10537. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10538. /**
  10539. * Calculate the intercept of a ray on a given axis
  10540. * @param axis to check 'x' | 'y' | 'z'
  10541. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10542. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10543. */
  10544. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10545. /**
  10546. * Checks if ray intersects a mesh
  10547. * @param mesh the mesh to check
  10548. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10549. * @returns picking info of the intersecton
  10550. */
  10551. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10552. /**
  10553. * Checks if ray intersects a mesh
  10554. * @param meshes the meshes to check
  10555. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10556. * @param results array to store result in
  10557. * @returns Array of picking infos
  10558. */
  10559. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10560. private _comparePickingInfo;
  10561. private static smallnum;
  10562. private static rayl;
  10563. /**
  10564. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10565. * @param sega the first point of the segment to test the intersection against
  10566. * @param segb the second point of the segment to test the intersection against
  10567. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10568. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10569. */
  10570. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10571. /**
  10572. * Update the ray from viewport position
  10573. * @param x position
  10574. * @param y y position
  10575. * @param viewportWidth viewport width
  10576. * @param viewportHeight viewport height
  10577. * @param world world matrix
  10578. * @param view view matrix
  10579. * @param projection projection matrix
  10580. * @returns this ray updated
  10581. */
  10582. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10583. /**
  10584. * Creates a ray with origin and direction of 0,0,0
  10585. * @returns the new ray
  10586. */
  10587. static Zero(): Ray;
  10588. /**
  10589. * Creates a new ray from screen space and viewport
  10590. * @param x position
  10591. * @param y y position
  10592. * @param viewportWidth viewport width
  10593. * @param viewportHeight viewport height
  10594. * @param world world matrix
  10595. * @param view view matrix
  10596. * @param projection projection matrix
  10597. * @returns new ray
  10598. */
  10599. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10600. /**
  10601. * 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
  10602. * transformed to the given world matrix.
  10603. * @param origin The origin point
  10604. * @param end The end point
  10605. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10606. * @returns the new ray
  10607. */
  10608. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10609. /**
  10610. * Transforms a ray by a matrix
  10611. * @param ray ray to transform
  10612. * @param matrix matrix to apply
  10613. * @returns the resulting new ray
  10614. */
  10615. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10616. /**
  10617. * Transforms a ray by a matrix
  10618. * @param ray ray to transform
  10619. * @param matrix matrix to apply
  10620. * @param result ray to store result in
  10621. */
  10622. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10623. /**
  10624. * Unproject a ray from screen space to object space
  10625. * @param sourceX defines the screen space x coordinate to use
  10626. * @param sourceY defines the screen space y coordinate to use
  10627. * @param viewportWidth defines the current width of the viewport
  10628. * @param viewportHeight defines the current height of the viewport
  10629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10630. * @param view defines the view matrix to use
  10631. * @param projection defines the projection matrix to use
  10632. */
  10633. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10634. }
  10635. /**
  10636. * Type used to define predicate used to select faces when a mesh intersection is detected
  10637. */
  10638. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10639. interface Scene {
  10640. /** @hidden */
  10641. _tempPickingRay: Nullable<Ray>;
  10642. /** @hidden */
  10643. _cachedRayForTransform: Ray;
  10644. /** @hidden */
  10645. _pickWithRayInverseMatrix: Matrix;
  10646. /** @hidden */
  10647. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10648. /** @hidden */
  10649. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10650. /** @hidden */
  10651. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10652. }
  10653. }
  10654. declare module BABYLON {
  10655. /**
  10656. * Groups all the scene component constants in one place to ease maintenance.
  10657. * @hidden
  10658. */
  10659. export class SceneComponentConstants {
  10660. static readonly NAME_EFFECTLAYER: string;
  10661. static readonly NAME_LAYER: string;
  10662. static readonly NAME_LENSFLARESYSTEM: string;
  10663. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10664. static readonly NAME_PARTICLESYSTEM: string;
  10665. static readonly NAME_GAMEPAD: string;
  10666. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10667. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10668. static readonly NAME_PREPASSRENDERER: string;
  10669. static readonly NAME_DEPTHRENDERER: string;
  10670. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10671. static readonly NAME_SPRITE: string;
  10672. static readonly NAME_SUBSURFACE: string;
  10673. static readonly NAME_OUTLINERENDERER: string;
  10674. static readonly NAME_PROCEDURALTEXTURE: string;
  10675. static readonly NAME_SHADOWGENERATOR: string;
  10676. static readonly NAME_OCTREE: string;
  10677. static readonly NAME_PHYSICSENGINE: string;
  10678. static readonly NAME_AUDIO: string;
  10679. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10680. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10681. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10682. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10683. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10684. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10685. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10686. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10687. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10688. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10689. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10690. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10691. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10692. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10693. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10694. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10695. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10696. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10697. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10698. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10699. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10700. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10701. static readonly STEP_AFTERRENDER_AUDIO: number;
  10702. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10703. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10704. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10705. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10706. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10707. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10708. static readonly STEP_POINTERMOVE_SPRITE: number;
  10709. static readonly STEP_POINTERDOWN_SPRITE: number;
  10710. static readonly STEP_POINTERUP_SPRITE: number;
  10711. }
  10712. /**
  10713. * This represents a scene component.
  10714. *
  10715. * This is used to decouple the dependency the scene is having on the different workloads like
  10716. * layers, post processes...
  10717. */
  10718. export interface ISceneComponent {
  10719. /**
  10720. * The name of the component. Each component must have a unique name.
  10721. */
  10722. name: string;
  10723. /**
  10724. * The scene the component belongs to.
  10725. */
  10726. scene: Scene;
  10727. /**
  10728. * Register the component to one instance of a scene.
  10729. */
  10730. register(): void;
  10731. /**
  10732. * Rebuilds the elements related to this component in case of
  10733. * context lost for instance.
  10734. */
  10735. rebuild(): void;
  10736. /**
  10737. * Disposes the component and the associated ressources.
  10738. */
  10739. dispose(): void;
  10740. }
  10741. /**
  10742. * This represents a SERIALIZABLE scene component.
  10743. *
  10744. * This extends Scene Component to add Serialization methods on top.
  10745. */
  10746. export interface ISceneSerializableComponent extends ISceneComponent {
  10747. /**
  10748. * Adds all the elements from the container to the scene
  10749. * @param container the container holding the elements
  10750. */
  10751. addFromContainer(container: AbstractScene): void;
  10752. /**
  10753. * Removes all the elements in the container from the scene
  10754. * @param container contains the elements to remove
  10755. * @param dispose if the removed element should be disposed (default: false)
  10756. */
  10757. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10758. /**
  10759. * Serializes the component data to the specified json object
  10760. * @param serializationObject The object to serialize to
  10761. */
  10762. serialize(serializationObject: any): void;
  10763. }
  10764. /**
  10765. * Strong typing of a Mesh related stage step action
  10766. */
  10767. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10768. /**
  10769. * Strong typing of a Evaluate Sub Mesh related stage step action
  10770. */
  10771. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10772. /**
  10773. * Strong typing of a Active Mesh related stage step action
  10774. */
  10775. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10776. /**
  10777. * Strong typing of a Camera related stage step action
  10778. */
  10779. export type CameraStageAction = (camera: Camera) => void;
  10780. /**
  10781. * Strong typing of a Camera Frame buffer related stage step action
  10782. */
  10783. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10784. /**
  10785. * Strong typing of a Render Target related stage step action
  10786. */
  10787. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10788. /**
  10789. * Strong typing of a RenderingGroup related stage step action
  10790. */
  10791. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10792. /**
  10793. * Strong typing of a Mesh Render related stage step action
  10794. */
  10795. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10796. /**
  10797. * Strong typing of a simple stage step action
  10798. */
  10799. export type SimpleStageAction = () => void;
  10800. /**
  10801. * Strong typing of a render target action.
  10802. */
  10803. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10804. /**
  10805. * Strong typing of a pointer move action.
  10806. */
  10807. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10808. /**
  10809. * Strong typing of a pointer up/down action.
  10810. */
  10811. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10812. /**
  10813. * Representation of a stage in the scene (Basically a list of ordered steps)
  10814. * @hidden
  10815. */
  10816. export class Stage<T extends Function> extends Array<{
  10817. index: number;
  10818. component: ISceneComponent;
  10819. action: T;
  10820. }> {
  10821. /**
  10822. * Hide ctor from the rest of the world.
  10823. * @param items The items to add.
  10824. */
  10825. private constructor();
  10826. /**
  10827. * Creates a new Stage.
  10828. * @returns A new instance of a Stage
  10829. */
  10830. static Create<T extends Function>(): Stage<T>;
  10831. /**
  10832. * Registers a step in an ordered way in the targeted stage.
  10833. * @param index Defines the position to register the step in
  10834. * @param component Defines the component attached to the step
  10835. * @param action Defines the action to launch during the step
  10836. */
  10837. registerStep(index: number, component: ISceneComponent, action: T): void;
  10838. /**
  10839. * Clears all the steps from the stage.
  10840. */
  10841. clear(): void;
  10842. }
  10843. }
  10844. declare module BABYLON {
  10845. interface Scene {
  10846. /** @hidden */
  10847. _pointerOverSprite: Nullable<Sprite>;
  10848. /** @hidden */
  10849. _pickedDownSprite: Nullable<Sprite>;
  10850. /** @hidden */
  10851. _tempSpritePickingRay: Nullable<Ray>;
  10852. /**
  10853. * All of the sprite managers added to this scene
  10854. * @see https://doc.babylonjs.com/babylon101/sprites
  10855. */
  10856. spriteManagers: Array<ISpriteManager>;
  10857. /**
  10858. * An event triggered when sprites rendering is about to start
  10859. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10860. */
  10861. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10862. /**
  10863. * An event triggered when sprites rendering is done
  10864. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10865. */
  10866. onAfterSpritesRenderingObservable: Observable<Scene>;
  10867. /** @hidden */
  10868. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10869. /** Launch a ray to try to pick a sprite in the scene
  10870. * @param x position on screen
  10871. * @param y position on screen
  10872. * @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
  10873. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10874. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10875. * @returns a PickingInfo
  10876. */
  10877. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10878. /** Use the given ray to pick a sprite in the scene
  10879. * @param ray The ray (in world space) to use to pick meshes
  10880. * @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
  10881. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10882. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10883. * @returns a PickingInfo
  10884. */
  10885. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10886. /** @hidden */
  10887. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10888. /** Launch a ray to try to pick sprites in the scene
  10889. * @param x position on screen
  10890. * @param y position on screen
  10891. * @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
  10892. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10893. * @returns a PickingInfo array
  10894. */
  10895. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10896. /** Use the given ray to pick sprites in the scene
  10897. * @param ray The ray (in world space) to use to pick meshes
  10898. * @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
  10899. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10900. * @returns a PickingInfo array
  10901. */
  10902. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10903. /**
  10904. * Force the sprite under the pointer
  10905. * @param sprite defines the sprite to use
  10906. */
  10907. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10908. /**
  10909. * Gets the sprite under the pointer
  10910. * @returns a Sprite or null if no sprite is under the pointer
  10911. */
  10912. getPointerOverSprite(): Nullable<Sprite>;
  10913. }
  10914. /**
  10915. * Defines the sprite scene component responsible to manage sprites
  10916. * in a given scene.
  10917. */
  10918. export class SpriteSceneComponent implements ISceneComponent {
  10919. /**
  10920. * The component name helpfull to identify the component in the list of scene components.
  10921. */
  10922. readonly name: string;
  10923. /**
  10924. * The scene the component belongs to.
  10925. */
  10926. scene: Scene;
  10927. /** @hidden */
  10928. private _spritePredicate;
  10929. /**
  10930. * Creates a new instance of the component for the given scene
  10931. * @param scene Defines the scene to register the component in
  10932. */
  10933. constructor(scene: Scene);
  10934. /**
  10935. * Registers the component in a given scene
  10936. */
  10937. register(): void;
  10938. /**
  10939. * Rebuilds the elements related to this component in case of
  10940. * context lost for instance.
  10941. */
  10942. rebuild(): void;
  10943. /**
  10944. * Disposes the component and the associated ressources.
  10945. */
  10946. dispose(): void;
  10947. private _pickSpriteButKeepRay;
  10948. private _pointerMove;
  10949. private _pointerDown;
  10950. private _pointerUp;
  10951. }
  10952. }
  10953. declare module BABYLON {
  10954. /** @hidden */
  10955. export var fogFragmentDeclaration: {
  10956. name: string;
  10957. shader: string;
  10958. };
  10959. }
  10960. declare module BABYLON {
  10961. /** @hidden */
  10962. export var fogFragment: {
  10963. name: string;
  10964. shader: string;
  10965. };
  10966. }
  10967. declare module BABYLON {
  10968. /** @hidden */
  10969. export var spritesPixelShader: {
  10970. name: string;
  10971. shader: string;
  10972. };
  10973. }
  10974. declare module BABYLON {
  10975. /** @hidden */
  10976. export var fogVertexDeclaration: {
  10977. name: string;
  10978. shader: string;
  10979. };
  10980. }
  10981. declare module BABYLON {
  10982. /** @hidden */
  10983. export var spritesVertexShader: {
  10984. name: string;
  10985. shader: string;
  10986. };
  10987. }
  10988. declare module BABYLON {
  10989. /**
  10990. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10991. */
  10992. export interface ISpriteManager extends IDisposable {
  10993. /**
  10994. * Gets manager's name
  10995. */
  10996. name: string;
  10997. /**
  10998. * Restricts the camera to viewing objects with the same layerMask.
  10999. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11000. */
  11001. layerMask: number;
  11002. /**
  11003. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11004. */
  11005. isPickable: boolean;
  11006. /**
  11007. * Gets the hosting scene
  11008. */
  11009. scene: Scene;
  11010. /**
  11011. * Specifies the rendering group id for this mesh (0 by default)
  11012. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11013. */
  11014. renderingGroupId: number;
  11015. /**
  11016. * Defines the list of sprites managed by the manager.
  11017. */
  11018. sprites: Array<Sprite>;
  11019. /**
  11020. * Gets or sets the spritesheet texture
  11021. */
  11022. texture: Texture;
  11023. /** Defines the default width of a cell in the spritesheet */
  11024. cellWidth: number;
  11025. /** Defines the default height of a cell in the spritesheet */
  11026. cellHeight: number;
  11027. /**
  11028. * Tests the intersection of a sprite with a specific ray.
  11029. * @param ray The ray we are sending to test the collision
  11030. * @param camera The camera space we are sending rays in
  11031. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11032. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11033. * @returns picking info or null.
  11034. */
  11035. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11036. /**
  11037. * Intersects the sprites with a ray
  11038. * @param ray defines the ray to intersect with
  11039. * @param camera defines the current active camera
  11040. * @param predicate defines a predicate used to select candidate sprites
  11041. * @returns null if no hit or a PickingInfo array
  11042. */
  11043. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11044. /**
  11045. * Renders the list of sprites on screen.
  11046. */
  11047. render(): void;
  11048. }
  11049. /**
  11050. * Class used to manage multiple sprites on the same spritesheet
  11051. * @see https://doc.babylonjs.com/babylon101/sprites
  11052. */
  11053. export class SpriteManager implements ISpriteManager {
  11054. /** defines the manager's name */
  11055. name: string;
  11056. /** Define the Url to load snippets */
  11057. static SnippetUrl: string;
  11058. /** Snippet ID if the manager was created from the snippet server */
  11059. snippetId: string;
  11060. /** Gets the list of sprites */
  11061. sprites: Sprite[];
  11062. /** Gets or sets the rendering group id (0 by default) */
  11063. renderingGroupId: number;
  11064. /** Gets or sets camera layer mask */
  11065. layerMask: number;
  11066. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11067. fogEnabled: boolean;
  11068. /** Gets or sets a boolean indicating if the sprites are pickable */
  11069. isPickable: boolean;
  11070. /** Defines the default width of a cell in the spritesheet */
  11071. cellWidth: number;
  11072. /** Defines the default height of a cell in the spritesheet */
  11073. cellHeight: number;
  11074. /** Associative array from JSON sprite data file */
  11075. private _cellData;
  11076. /** Array of sprite names from JSON sprite data file */
  11077. private _spriteMap;
  11078. /** True when packed cell data from JSON file is ready*/
  11079. private _packedAndReady;
  11080. private _textureContent;
  11081. private _useInstancing;
  11082. /**
  11083. * An event triggered when the manager is disposed.
  11084. */
  11085. onDisposeObservable: Observable<SpriteManager>;
  11086. private _onDisposeObserver;
  11087. /**
  11088. * Callback called when the manager is disposed
  11089. */
  11090. set onDispose(callback: () => void);
  11091. private _capacity;
  11092. private _fromPacked;
  11093. private _spriteTexture;
  11094. private _epsilon;
  11095. private _scene;
  11096. private _vertexData;
  11097. private _buffer;
  11098. private _vertexBuffers;
  11099. private _spriteBuffer;
  11100. private _indexBuffer;
  11101. private _effectBase;
  11102. private _effectFog;
  11103. private _vertexBufferSize;
  11104. /**
  11105. * Gets or sets the unique id of the sprite
  11106. */
  11107. uniqueId: number;
  11108. /**
  11109. * Gets the array of sprites
  11110. */
  11111. get children(): Sprite[];
  11112. /**
  11113. * Gets the hosting scene
  11114. */
  11115. get scene(): Scene;
  11116. /**
  11117. * Gets the capacity of the manager
  11118. */
  11119. get capacity(): number;
  11120. /**
  11121. * Gets or sets the spritesheet texture
  11122. */
  11123. get texture(): Texture;
  11124. set texture(value: Texture);
  11125. private _blendMode;
  11126. /**
  11127. * Blend mode use to render the particle, it can be any of
  11128. * the static Constants.ALPHA_x properties provided in this class.
  11129. * Default value is Constants.ALPHA_COMBINE
  11130. */
  11131. get blendMode(): number;
  11132. set blendMode(blendMode: number);
  11133. /** Disables writing to the depth buffer when rendering the sprites.
  11134. * It can be handy to disable depth writing when using textures without alpha channel
  11135. * and setting some specific blend modes.
  11136. */
  11137. disableDepthWrite: boolean;
  11138. /**
  11139. * Creates a new sprite manager
  11140. * @param name defines the manager's name
  11141. * @param imgUrl defines the sprite sheet url
  11142. * @param capacity defines the maximum allowed number of sprites
  11143. * @param cellSize defines the size of a sprite cell
  11144. * @param scene defines the hosting scene
  11145. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11146. * @param samplingMode defines the smapling mode to use with spritesheet
  11147. * @param fromPacked set to false; do not alter
  11148. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11149. */
  11150. constructor(
  11151. /** defines the manager's name */
  11152. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11153. /**
  11154. * Returns the string "SpriteManager"
  11155. * @returns "SpriteManager"
  11156. */
  11157. getClassName(): string;
  11158. private _makePacked;
  11159. private _appendSpriteVertex;
  11160. private _checkTextureAlpha;
  11161. /**
  11162. * Intersects the sprites with a ray
  11163. * @param ray defines the ray to intersect with
  11164. * @param camera defines the current active camera
  11165. * @param predicate defines a predicate used to select candidate sprites
  11166. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11167. * @returns null if no hit or a PickingInfo
  11168. */
  11169. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11170. /**
  11171. * Intersects the sprites with a ray
  11172. * @param ray defines the ray to intersect with
  11173. * @param camera defines the current active camera
  11174. * @param predicate defines a predicate used to select candidate sprites
  11175. * @returns null if no hit or a PickingInfo array
  11176. */
  11177. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11178. /**
  11179. * Render all child sprites
  11180. */
  11181. render(): void;
  11182. /**
  11183. * Release associated resources
  11184. */
  11185. dispose(): void;
  11186. /**
  11187. * Serializes the sprite manager to a JSON object
  11188. * @param serializeTexture defines if the texture must be serialized as well
  11189. * @returns the JSON object
  11190. */
  11191. serialize(serializeTexture?: boolean): any;
  11192. /**
  11193. * Parses a JSON object to create a new sprite manager.
  11194. * @param parsedManager The JSON object to parse
  11195. * @param scene The scene to create the sprite managerin
  11196. * @param rootUrl The root url to use to load external dependencies like texture
  11197. * @returns the new sprite manager
  11198. */
  11199. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11200. /**
  11201. * Creates a sprite manager from a snippet saved in a remote file
  11202. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11203. * @param url defines the url to load from
  11204. * @param scene defines the hosting scene
  11205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11206. * @returns a promise that will resolve to the new sprite manager
  11207. */
  11208. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11209. /**
  11210. * Creates a sprite manager from a snippet saved by the sprite editor
  11211. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11212. * @param scene defines the hosting scene
  11213. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11214. * @returns a promise that will resolve to the new sprite manager
  11215. */
  11216. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11217. }
  11218. }
  11219. declare module BABYLON {
  11220. /** Interface used by value gradients (color, factor, ...) */
  11221. export interface IValueGradient {
  11222. /**
  11223. * Gets or sets the gradient value (between 0 and 1)
  11224. */
  11225. gradient: number;
  11226. }
  11227. /** Class used to store color4 gradient */
  11228. export class ColorGradient implements IValueGradient {
  11229. /**
  11230. * Gets or sets the gradient value (between 0 and 1)
  11231. */
  11232. gradient: number;
  11233. /**
  11234. * Gets or sets first associated color
  11235. */
  11236. color1: Color4;
  11237. /**
  11238. * Gets or sets second associated color
  11239. */
  11240. color2?: Color4 | undefined;
  11241. /**
  11242. * Creates a new color4 gradient
  11243. * @param gradient gets or sets the gradient value (between 0 and 1)
  11244. * @param color1 gets or sets first associated color
  11245. * @param color2 gets or sets first second color
  11246. */
  11247. constructor(
  11248. /**
  11249. * Gets or sets the gradient value (between 0 and 1)
  11250. */
  11251. gradient: number,
  11252. /**
  11253. * Gets or sets first associated color
  11254. */
  11255. color1: Color4,
  11256. /**
  11257. * Gets or sets second associated color
  11258. */
  11259. color2?: Color4 | undefined);
  11260. /**
  11261. * Will get a color picked randomly between color1 and color2.
  11262. * If color2 is undefined then color1 will be used
  11263. * @param result defines the target Color4 to store the result in
  11264. */
  11265. getColorToRef(result: Color4): void;
  11266. }
  11267. /** Class used to store color 3 gradient */
  11268. export class Color3Gradient implements IValueGradient {
  11269. /**
  11270. * Gets or sets the gradient value (between 0 and 1)
  11271. */
  11272. gradient: number;
  11273. /**
  11274. * Gets or sets the associated color
  11275. */
  11276. color: Color3;
  11277. /**
  11278. * Creates a new color3 gradient
  11279. * @param gradient gets or sets the gradient value (between 0 and 1)
  11280. * @param color gets or sets associated color
  11281. */
  11282. constructor(
  11283. /**
  11284. * Gets or sets the gradient value (between 0 and 1)
  11285. */
  11286. gradient: number,
  11287. /**
  11288. * Gets or sets the associated color
  11289. */
  11290. color: Color3);
  11291. }
  11292. /** Class used to store factor gradient */
  11293. export class FactorGradient implements IValueGradient {
  11294. /**
  11295. * Gets or sets the gradient value (between 0 and 1)
  11296. */
  11297. gradient: number;
  11298. /**
  11299. * Gets or sets first associated factor
  11300. */
  11301. factor1: number;
  11302. /**
  11303. * Gets or sets second associated factor
  11304. */
  11305. factor2?: number | undefined;
  11306. /**
  11307. * Creates a new factor gradient
  11308. * @param gradient gets or sets the gradient value (between 0 and 1)
  11309. * @param factor1 gets or sets first associated factor
  11310. * @param factor2 gets or sets second associated factor
  11311. */
  11312. constructor(
  11313. /**
  11314. * Gets or sets the gradient value (between 0 and 1)
  11315. */
  11316. gradient: number,
  11317. /**
  11318. * Gets or sets first associated factor
  11319. */
  11320. factor1: number,
  11321. /**
  11322. * Gets or sets second associated factor
  11323. */
  11324. factor2?: number | undefined);
  11325. /**
  11326. * Will get a number picked randomly between factor1 and factor2.
  11327. * If factor2 is undefined then factor1 will be used
  11328. * @returns the picked number
  11329. */
  11330. getFactor(): number;
  11331. }
  11332. /**
  11333. * Helper used to simplify some generic gradient tasks
  11334. */
  11335. export class GradientHelper {
  11336. /**
  11337. * Gets the current gradient from an array of IValueGradient
  11338. * @param ratio defines the current ratio to get
  11339. * @param gradients defines the array of IValueGradient
  11340. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11341. */
  11342. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11343. }
  11344. }
  11345. declare module BABYLON {
  11346. interface ThinEngine {
  11347. /**
  11348. * Creates a raw texture
  11349. * @param data defines the data to store in the texture
  11350. * @param width defines the width of the texture
  11351. * @param height defines the height of the texture
  11352. * @param format defines the format of the data
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11356. * @param compression defines the compression used (null by default)
  11357. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11358. * @returns the raw texture inside an InternalTexture
  11359. */
  11360. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11361. /**
  11362. * Update a raw texture
  11363. * @param texture defines the texture to update
  11364. * @param data defines the data to store in the texture
  11365. * @param format defines the format of the data
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw texture
  11371. * @param texture defines the texture to update
  11372. * @param data defines the data to store in the texture
  11373. * @param format defines the format of the data
  11374. * @param invertY defines if data must be stored with Y axis inverted
  11375. * @param compression defines the compression used (null by default)
  11376. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11377. */
  11378. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11379. /**
  11380. * Creates a new raw cube texture
  11381. * @param data defines the array of data to use to create each face
  11382. * @param size defines the size of the textures
  11383. * @param format defines the format of the data
  11384. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11385. * @param generateMipMaps defines if the engine should generate the mip levels
  11386. * @param invertY defines if data must be stored with Y axis inverted
  11387. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11388. * @param compression defines the compression used (null by default)
  11389. * @returns the cube texture as an InternalTexture
  11390. */
  11391. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11392. /**
  11393. * Update a raw cube texture
  11394. * @param texture defines the texture to udpdate
  11395. * @param data defines the data to store
  11396. * @param format defines the data format
  11397. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11398. * @param invertY defines if data must be stored with Y axis inverted
  11399. */
  11400. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11401. /**
  11402. * Update a raw cube texture
  11403. * @param texture defines the texture to udpdate
  11404. * @param data defines the data to store
  11405. * @param format defines the data format
  11406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param compression defines the compression used (null by default)
  11409. */
  11410. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11411. /**
  11412. * Update a raw cube texture
  11413. * @param texture defines the texture to udpdate
  11414. * @param data defines the data to store
  11415. * @param format defines the data format
  11416. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11417. * @param invertY defines if data must be stored with Y axis inverted
  11418. * @param compression defines the compression used (null by default)
  11419. * @param level defines which level of the texture to update
  11420. */
  11421. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11422. /**
  11423. * Creates a new raw cube texture from a specified url
  11424. * @param url defines the url where the data is located
  11425. * @param scene defines the current scene
  11426. * @param size defines the size of the textures
  11427. * @param format defines the format of the data
  11428. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11429. * @param noMipmap defines if the engine should avoid generating the mip levels
  11430. * @param callback defines a callback used to extract texture data from loaded data
  11431. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11432. * @param onLoad defines a callback called when texture is loaded
  11433. * @param onError defines a callback called if there is an error
  11434. * @returns the cube texture as an InternalTexture
  11435. */
  11436. 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;
  11437. /**
  11438. * Creates a new raw cube texture from a specified url
  11439. * @param url defines the url where the data is located
  11440. * @param scene defines the current scene
  11441. * @param size defines the size of the textures
  11442. * @param format defines the format of the data
  11443. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11444. * @param noMipmap defines if the engine should avoid generating the mip levels
  11445. * @param callback defines a callback used to extract texture data from loaded data
  11446. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11447. * @param onLoad defines a callback called when texture is loaded
  11448. * @param onError defines a callback called if there is an error
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. 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;
  11454. /**
  11455. * Creates a new raw 3D texture
  11456. * @param data defines the data used to create the texture
  11457. * @param width defines the width of the texture
  11458. * @param height defines the height of the texture
  11459. * @param depth defines the depth of the texture
  11460. * @param format defines the format of the texture
  11461. * @param generateMipMaps defines if the engine must generate mip levels
  11462. * @param invertY defines if data must be stored with Y axis inverted
  11463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11464. * @param compression defines the compressed used (can be null)
  11465. * @param textureType defines the compressed used (can be null)
  11466. * @returns a new raw 3D texture (stored in an InternalTexture)
  11467. */
  11468. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11469. /**
  11470. * Update a raw 3D texture
  11471. * @param texture defines the texture to update
  11472. * @param data defines the data to store
  11473. * @param format defines the data format
  11474. * @param invertY defines if data must be stored with Y axis inverted
  11475. */
  11476. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11477. /**
  11478. * Update a raw 3D texture
  11479. * @param texture defines the texture to update
  11480. * @param data defines the data to store
  11481. * @param format defines the data format
  11482. * @param invertY defines if data must be stored with Y axis inverted
  11483. * @param compression defines the used compression (can be null)
  11484. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11485. */
  11486. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11487. /**
  11488. * Creates a new raw 2D array texture
  11489. * @param data defines the data used to create the texture
  11490. * @param width defines the width of the texture
  11491. * @param height defines the height of the texture
  11492. * @param depth defines the number of layers of the texture
  11493. * @param format defines the format of the texture
  11494. * @param generateMipMaps defines if the engine must generate mip levels
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param compression defines the compressed used (can be null)
  11498. * @param textureType defines the compressed used (can be null)
  11499. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11500. */
  11501. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11502. /**
  11503. * Update a raw 2D array texture
  11504. * @param texture defines the texture to update
  11505. * @param data defines the data to store
  11506. * @param format defines the data format
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. */
  11509. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11510. /**
  11511. * Update a raw 2D array texture
  11512. * @param texture defines the texture to update
  11513. * @param data defines the data to store
  11514. * @param format defines the data format
  11515. * @param invertY defines if data must be stored with Y axis inverted
  11516. * @param compression defines the used compression (can be null)
  11517. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11518. */
  11519. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11520. }
  11521. }
  11522. declare module BABYLON {
  11523. /**
  11524. * Raw texture can help creating a texture directly from an array of data.
  11525. * This can be super useful if you either get the data from an uncompressed source or
  11526. * if you wish to create your texture pixel by pixel.
  11527. */
  11528. export class RawTexture extends Texture {
  11529. /**
  11530. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11531. */
  11532. format: number;
  11533. /**
  11534. * Instantiates a new RawTexture.
  11535. * Raw texture can help creating a texture directly from an array of data.
  11536. * This can be super useful if you either get the data from an uncompressed source or
  11537. * if you wish to create your texture pixel by pixel.
  11538. * @param data define the array of data to use to create the texture
  11539. * @param width define the width of the texture
  11540. * @param height define the height of the texture
  11541. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11542. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11543. * @param generateMipMaps define whether mip maps should be generated or not
  11544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11546. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11547. */
  11548. constructor(data: ArrayBufferView, width: number, height: number,
  11549. /**
  11550. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11551. */
  11552. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11553. /**
  11554. * Updates the texture underlying data.
  11555. * @param data Define the new data of the texture
  11556. */
  11557. update(data: ArrayBufferView): void;
  11558. /**
  11559. * Creates a luminance texture from some data.
  11560. * @param data Define the texture data
  11561. * @param width Define the width of the texture
  11562. * @param height Define the height of the texture
  11563. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11567. * @returns the luminance texture
  11568. */
  11569. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11570. /**
  11571. * Creates a luminance alpha texture from some data.
  11572. * @param data Define the texture data
  11573. * @param width Define the width of the texture
  11574. * @param height Define the height of the texture
  11575. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11576. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11579. * @returns the luminance alpha texture
  11580. */
  11581. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11582. /**
  11583. * Creates an alpha texture from some data.
  11584. * @param data Define the texture data
  11585. * @param width Define the width of the texture
  11586. * @param height Define the height of the texture
  11587. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11588. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11589. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11590. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11591. * @returns the alpha texture
  11592. */
  11593. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11594. /**
  11595. * Creates a RGB texture from some data.
  11596. * @param data Define the texture data
  11597. * @param width Define the width of the texture
  11598. * @param height Define the height of the texture
  11599. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11603. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11604. * @returns the RGB alpha texture
  11605. */
  11606. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11607. /**
  11608. * Creates a RGBA texture from some data.
  11609. * @param data Define the texture data
  11610. * @param width Define the width of the texture
  11611. * @param height Define the height of the texture
  11612. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11613. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11614. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11615. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11616. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11617. * @returns the RGBA texture
  11618. */
  11619. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11620. /**
  11621. * Creates a R texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11630. * @returns the R texture
  11631. */
  11632. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11633. }
  11634. }
  11635. declare module BABYLON {
  11636. interface ThinEngine {
  11637. /**
  11638. * Update a dynamic index buffer
  11639. * @param indexBuffer defines the target index buffer
  11640. * @param indices defines the data to update
  11641. * @param offset defines the offset in the target index buffer where update should start
  11642. */
  11643. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11644. /**
  11645. * Updates a dynamic vertex buffer.
  11646. * @param vertexBuffer the vertex buffer to update
  11647. * @param data the data used to update the vertex buffer
  11648. * @param byteOffset the byte offset of the data
  11649. * @param byteLength the byte length of the data
  11650. */
  11651. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. interface AbstractScene {
  11656. /**
  11657. * The list of procedural textures added to the scene
  11658. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11659. */
  11660. proceduralTextures: Array<ProceduralTexture>;
  11661. }
  11662. /**
  11663. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11664. * in a given scene.
  11665. */
  11666. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11667. /**
  11668. * The component name helpfull to identify the component in the list of scene components.
  11669. */
  11670. readonly name: string;
  11671. /**
  11672. * The scene the component belongs to.
  11673. */
  11674. scene: Scene;
  11675. /**
  11676. * Creates a new instance of the component for the given scene
  11677. * @param scene Defines the scene to register the component in
  11678. */
  11679. constructor(scene: Scene);
  11680. /**
  11681. * Registers the component in a given scene
  11682. */
  11683. register(): void;
  11684. /**
  11685. * Rebuilds the elements related to this component in case of
  11686. * context lost for instance.
  11687. */
  11688. rebuild(): void;
  11689. /**
  11690. * Disposes the component and the associated ressources.
  11691. */
  11692. dispose(): void;
  11693. private _beforeClear;
  11694. }
  11695. }
  11696. declare module BABYLON {
  11697. interface ThinEngine {
  11698. /**
  11699. * Creates a new render target cube texture
  11700. * @param size defines the size of the texture
  11701. * @param options defines the options used to create the texture
  11702. * @returns a new render target cube texture stored in an InternalTexture
  11703. */
  11704. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11705. }
  11706. }
  11707. declare module BABYLON {
  11708. /** @hidden */
  11709. export var proceduralVertexShader: {
  11710. name: string;
  11711. shader: string;
  11712. };
  11713. }
  11714. declare module BABYLON {
  11715. /**
  11716. * 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.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. */
  11720. export class ProceduralTexture extends Texture {
  11721. /**
  11722. * Define if the texture is enabled or not (disabled texture will not render)
  11723. */
  11724. isEnabled: boolean;
  11725. /**
  11726. * Define if the texture must be cleared before rendering (default is true)
  11727. */
  11728. autoClear: boolean;
  11729. /**
  11730. * Callback called when the texture is generated
  11731. */
  11732. onGenerated: () => void;
  11733. /**
  11734. * Event raised when the texture is generated
  11735. */
  11736. onGeneratedObservable: Observable<ProceduralTexture>;
  11737. /**
  11738. * Event raised before the texture is generated
  11739. */
  11740. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11741. /**
  11742. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11743. */
  11744. nodeMaterialSource: Nullable<NodeMaterial>;
  11745. /** @hidden */
  11746. _generateMipMaps: boolean;
  11747. /** @hidden **/
  11748. _effect: Effect;
  11749. /** @hidden */
  11750. _textures: {
  11751. [key: string]: Texture;
  11752. };
  11753. /** @hidden */
  11754. protected _fallbackTexture: Nullable<Texture>;
  11755. private _size;
  11756. private _currentRefreshId;
  11757. private _frameId;
  11758. private _refreshRate;
  11759. private _vertexBuffers;
  11760. private _indexBuffer;
  11761. private _uniforms;
  11762. private _samplers;
  11763. private _fragment;
  11764. private _floats;
  11765. private _ints;
  11766. private _floatsArrays;
  11767. private _colors3;
  11768. private _colors4;
  11769. private _vectors2;
  11770. private _vectors3;
  11771. private _matrices;
  11772. private _fallbackTextureUsed;
  11773. private _fullEngine;
  11774. private _cachedDefines;
  11775. private _contentUpdateId;
  11776. private _contentData;
  11777. /**
  11778. * Instantiates a new procedural texture.
  11779. * 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.
  11780. * This is the base class of any Procedural texture and contains most of the shareable code.
  11781. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11782. * @param name Define the name of the texture
  11783. * @param size Define the size of the texture to create
  11784. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11785. * @param scene Define the scene the texture belongs to
  11786. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11787. * @param generateMipMaps Define if the texture should creates mip maps or not
  11788. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11789. */
  11790. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11791. /**
  11792. * The effect that is created when initializing the post process.
  11793. * @returns The created effect corresponding the the postprocess.
  11794. */
  11795. getEffect(): Effect;
  11796. /**
  11797. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11798. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11799. */
  11800. getContent(): Nullable<ArrayBufferView>;
  11801. private _createIndexBuffer;
  11802. /** @hidden */
  11803. _rebuild(): void;
  11804. /**
  11805. * Resets the texture in order to recreate its associated resources.
  11806. * This can be called in case of context loss
  11807. */
  11808. reset(): void;
  11809. protected _getDefines(): string;
  11810. /**
  11811. * Is the texture ready to be used ? (rendered at least once)
  11812. * @returns true if ready, otherwise, false.
  11813. */
  11814. isReady(): boolean;
  11815. /**
  11816. * Resets the refresh counter of the texture and start bak from scratch.
  11817. * Could be useful to regenerate the texture if it is setup to render only once.
  11818. */
  11819. resetRefreshCounter(): void;
  11820. /**
  11821. * Set the fragment shader to use in order to render the texture.
  11822. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11823. */
  11824. setFragment(fragment: any): void;
  11825. /**
  11826. * Define the refresh rate of the texture or the rendering frequency.
  11827. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11828. */
  11829. get refreshRate(): number;
  11830. set refreshRate(value: number);
  11831. /** @hidden */
  11832. _shouldRender(): boolean;
  11833. /**
  11834. * Get the size the texture is rendering at.
  11835. * @returns the size (on cube texture it is always squared)
  11836. */
  11837. getRenderSize(): RenderTargetTextureSize;
  11838. /**
  11839. * Resize the texture to new value.
  11840. * @param size Define the new size the texture should have
  11841. * @param generateMipMaps Define whether the new texture should create mip maps
  11842. */
  11843. resize(size: number, generateMipMaps: boolean): void;
  11844. private _checkUniform;
  11845. /**
  11846. * Set a texture in the shader program used to render.
  11847. * @param name Define the name of the uniform samplers as defined in the shader
  11848. * @param texture Define the texture to bind to this sampler
  11849. * @return the texture itself allowing "fluent" like uniform updates
  11850. */
  11851. setTexture(name: string, texture: Texture): ProceduralTexture;
  11852. /**
  11853. * Set a float in the shader.
  11854. * @param name Define the name of the uniform as defined in the shader
  11855. * @param value Define the value to give to the uniform
  11856. * @return the texture itself allowing "fluent" like uniform updates
  11857. */
  11858. setFloat(name: string, value: number): ProceduralTexture;
  11859. /**
  11860. * Set a int in the shader.
  11861. * @param name Define the name of the uniform as defined in the shader
  11862. * @param value Define the value to give to the uniform
  11863. * @return the texture itself allowing "fluent" like uniform updates
  11864. */
  11865. setInt(name: string, value: number): ProceduralTexture;
  11866. /**
  11867. * Set an array of floats in the shader.
  11868. * @param name Define the name of the uniform as defined in the shader
  11869. * @param value Define the value to give to the uniform
  11870. * @return the texture itself allowing "fluent" like uniform updates
  11871. */
  11872. setFloats(name: string, value: number[]): ProceduralTexture;
  11873. /**
  11874. * Set a vec3 in the shader from a Color3.
  11875. * @param name Define the name of the uniform as defined in the shader
  11876. * @param value Define the value to give to the uniform
  11877. * @return the texture itself allowing "fluent" like uniform updates
  11878. */
  11879. setColor3(name: string, value: Color3): ProceduralTexture;
  11880. /**
  11881. * Set a vec4 in the shader from a Color4.
  11882. * @param name Define the name of the uniform as defined in the shader
  11883. * @param value Define the value to give to the uniform
  11884. * @return the texture itself allowing "fluent" like uniform updates
  11885. */
  11886. setColor4(name: string, value: Color4): ProceduralTexture;
  11887. /**
  11888. * Set a vec2 in the shader from a Vector2.
  11889. * @param name Define the name of the uniform as defined in the shader
  11890. * @param value Define the value to give to the uniform
  11891. * @return the texture itself allowing "fluent" like uniform updates
  11892. */
  11893. setVector2(name: string, value: Vector2): ProceduralTexture;
  11894. /**
  11895. * Set a vec3 in the shader from a Vector3.
  11896. * @param name Define the name of the uniform as defined in the shader
  11897. * @param value Define the value to give to the uniform
  11898. * @return the texture itself allowing "fluent" like uniform updates
  11899. */
  11900. setVector3(name: string, value: Vector3): ProceduralTexture;
  11901. /**
  11902. * Set a mat4 in the shader from a MAtrix.
  11903. * @param name Define the name of the uniform as defined in the shader
  11904. * @param value Define the value to give to the uniform
  11905. * @return the texture itself allowing "fluent" like uniform updates
  11906. */
  11907. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11908. /**
  11909. * Render the texture to its associated render target.
  11910. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11911. */
  11912. render(useCameraPostProcess?: boolean): void;
  11913. /**
  11914. * Clone the texture.
  11915. * @returns the cloned texture
  11916. */
  11917. clone(): ProceduralTexture;
  11918. /**
  11919. * Dispose the texture and release its asoociated resources.
  11920. */
  11921. dispose(): void;
  11922. }
  11923. }
  11924. declare module BABYLON {
  11925. /**
  11926. * This represents the base class for particle system in Babylon.
  11927. * 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.
  11928. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11929. * @example https://doc.babylonjs.com/babylon101/particles
  11930. */
  11931. export class BaseParticleSystem {
  11932. /**
  11933. * Source color is added to the destination color without alpha affecting the result
  11934. */
  11935. static BLENDMODE_ONEONE: number;
  11936. /**
  11937. * Blend current color and particle color using particle’s alpha
  11938. */
  11939. static BLENDMODE_STANDARD: number;
  11940. /**
  11941. * Add current color and particle color multiplied by particle’s alpha
  11942. */
  11943. static BLENDMODE_ADD: number;
  11944. /**
  11945. * Multiply current color with particle color
  11946. */
  11947. static BLENDMODE_MULTIPLY: number;
  11948. /**
  11949. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11950. */
  11951. static BLENDMODE_MULTIPLYADD: number;
  11952. /**
  11953. * List of animations used by the particle system.
  11954. */
  11955. animations: Animation[];
  11956. /**
  11957. * Gets or sets the unique id of the particle system
  11958. */
  11959. uniqueId: number;
  11960. /**
  11961. * The id of the Particle system.
  11962. */
  11963. id: string;
  11964. /**
  11965. * The friendly name of the Particle system.
  11966. */
  11967. name: string;
  11968. /**
  11969. * Snippet ID if the particle system was created from the snippet server
  11970. */
  11971. snippetId: string;
  11972. /**
  11973. * The rendering group used by the Particle system to chose when to render.
  11974. */
  11975. renderingGroupId: number;
  11976. /**
  11977. * The emitter represents the Mesh or position we are attaching the particle system to.
  11978. */
  11979. emitter: Nullable<AbstractMesh | Vector3>;
  11980. /**
  11981. * The maximum number of particles to emit per frame
  11982. */
  11983. emitRate: number;
  11984. /**
  11985. * If you want to launch only a few particles at once, that can be done, as well.
  11986. */
  11987. manualEmitCount: number;
  11988. /**
  11989. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11990. */
  11991. updateSpeed: number;
  11992. /**
  11993. * The amount of time the particle system is running (depends of the overall update speed).
  11994. */
  11995. targetStopDuration: number;
  11996. /**
  11997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11998. */
  11999. disposeOnStop: boolean;
  12000. /**
  12001. * Minimum power of emitting particles.
  12002. */
  12003. minEmitPower: number;
  12004. /**
  12005. * Maximum power of emitting particles.
  12006. */
  12007. maxEmitPower: number;
  12008. /**
  12009. * Minimum life time of emitting particles.
  12010. */
  12011. minLifeTime: number;
  12012. /**
  12013. * Maximum life time of emitting particles.
  12014. */
  12015. maxLifeTime: number;
  12016. /**
  12017. * Minimum Size of emitting particles.
  12018. */
  12019. minSize: number;
  12020. /**
  12021. * Maximum Size of emitting particles.
  12022. */
  12023. maxSize: number;
  12024. /**
  12025. * Minimum scale of emitting particles on X axis.
  12026. */
  12027. minScaleX: number;
  12028. /**
  12029. * Maximum scale of emitting particles on X axis.
  12030. */
  12031. maxScaleX: number;
  12032. /**
  12033. * Minimum scale of emitting particles on Y axis.
  12034. */
  12035. minScaleY: number;
  12036. /**
  12037. * Maximum scale of emitting particles on Y axis.
  12038. */
  12039. maxScaleY: number;
  12040. /**
  12041. * Gets or sets the minimal initial rotation in radians.
  12042. */
  12043. minInitialRotation: number;
  12044. /**
  12045. * Gets or sets the maximal initial rotation in radians.
  12046. */
  12047. maxInitialRotation: number;
  12048. /**
  12049. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12050. */
  12051. minAngularSpeed: number;
  12052. /**
  12053. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12054. */
  12055. maxAngularSpeed: number;
  12056. /**
  12057. * The texture used to render each particle. (this can be a spritesheet)
  12058. */
  12059. particleTexture: Nullable<BaseTexture>;
  12060. /**
  12061. * The layer mask we are rendering the particles through.
  12062. */
  12063. layerMask: number;
  12064. /**
  12065. * This can help using your own shader to render the particle system.
  12066. * The according effect will be created
  12067. */
  12068. customShader: any;
  12069. /**
  12070. * By default particle system starts as soon as they are created. This prevents the
  12071. * automatic start to happen and let you decide when to start emitting particles.
  12072. */
  12073. preventAutoStart: boolean;
  12074. private _noiseTexture;
  12075. /**
  12076. * Gets or sets a texture used to add random noise to particle positions
  12077. */
  12078. get noiseTexture(): Nullable<ProceduralTexture>;
  12079. set noiseTexture(value: Nullable<ProceduralTexture>);
  12080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12081. noiseStrength: Vector3;
  12082. /**
  12083. * Callback triggered when the particle animation is ending.
  12084. */
  12085. onAnimationEnd: Nullable<() => void>;
  12086. /**
  12087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12088. */
  12089. blendMode: number;
  12090. /**
  12091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12092. * to override the particles.
  12093. */
  12094. forceDepthWrite: boolean;
  12095. /** 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 */
  12096. preWarmCycles: number;
  12097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12098. preWarmStepOffset: number;
  12099. /**
  12100. * 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)
  12101. */
  12102. spriteCellChangeSpeed: number;
  12103. /**
  12104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12105. */
  12106. startSpriteCellID: number;
  12107. /**
  12108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12109. */
  12110. endSpriteCellID: number;
  12111. /**
  12112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12113. */
  12114. spriteCellWidth: number;
  12115. /**
  12116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12117. */
  12118. spriteCellHeight: number;
  12119. /**
  12120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12121. */
  12122. spriteRandomStartCell: boolean;
  12123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12124. translationPivot: Vector2;
  12125. /** @hidden */
  12126. protected _isAnimationSheetEnabled: boolean;
  12127. /**
  12128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12129. */
  12130. beginAnimationOnStart: boolean;
  12131. /**
  12132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12133. */
  12134. beginAnimationFrom: number;
  12135. /**
  12136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12137. */
  12138. beginAnimationTo: number;
  12139. /**
  12140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12141. */
  12142. beginAnimationLoop: boolean;
  12143. /**
  12144. * Gets or sets a world offset applied to all particles
  12145. */
  12146. worldOffset: Vector3;
  12147. /**
  12148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12149. */
  12150. get isAnimationSheetEnabled(): boolean;
  12151. set isAnimationSheetEnabled(value: boolean);
  12152. /**
  12153. * Get hosting scene
  12154. * @returns the scene
  12155. */
  12156. getScene(): Nullable<Scene>;
  12157. /**
  12158. * You can use gravity if you want to give an orientation to your particles.
  12159. */
  12160. gravity: Vector3;
  12161. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12162. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12163. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12164. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12165. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12166. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12167. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12168. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12169. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12170. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12171. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12172. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12173. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12174. /**
  12175. * Defines the delay in milliseconds before starting the system (0 by default)
  12176. */
  12177. startDelay: number;
  12178. /**
  12179. * Gets the current list of drag gradients.
  12180. * You must use addDragGradient and removeDragGradient to udpate this list
  12181. * @returns the list of drag gradients
  12182. */
  12183. getDragGradients(): Nullable<Array<FactorGradient>>;
  12184. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12185. limitVelocityDamping: number;
  12186. /**
  12187. * Gets the current list of limit velocity gradients.
  12188. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12189. * @returns the list of limit velocity gradients
  12190. */
  12191. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12192. /**
  12193. * Gets the current list of color gradients.
  12194. * You must use addColorGradient and removeColorGradient to udpate this list
  12195. * @returns the list of color gradients
  12196. */
  12197. getColorGradients(): Nullable<Array<ColorGradient>>;
  12198. /**
  12199. * Gets the current list of size gradients.
  12200. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12201. * @returns the list of size gradients
  12202. */
  12203. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12204. /**
  12205. * Gets the current list of color remap gradients.
  12206. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12207. * @returns the list of color remap gradients
  12208. */
  12209. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12210. /**
  12211. * Gets the current list of alpha remap gradients.
  12212. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12213. * @returns the list of alpha remap gradients
  12214. */
  12215. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12216. /**
  12217. * Gets the current list of life time gradients.
  12218. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12219. * @returns the list of life time gradients
  12220. */
  12221. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12222. /**
  12223. * Gets the current list of angular speed gradients.
  12224. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12225. * @returns the list of angular speed gradients
  12226. */
  12227. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12228. /**
  12229. * Gets the current list of velocity gradients.
  12230. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12231. * @returns the list of velocity gradients
  12232. */
  12233. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12234. /**
  12235. * Gets the current list of start size gradients.
  12236. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12237. * @returns the list of start size gradients
  12238. */
  12239. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of emit rate gradients.
  12242. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12243. * @returns the list of emit rate gradients
  12244. */
  12245. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12246. /**
  12247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12248. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12249. */
  12250. get direction1(): Vector3;
  12251. set direction1(value: Vector3);
  12252. /**
  12253. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12254. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12255. */
  12256. get direction2(): Vector3;
  12257. set direction2(value: Vector3);
  12258. /**
  12259. * 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.
  12260. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12261. */
  12262. get minEmitBox(): Vector3;
  12263. set minEmitBox(value: Vector3);
  12264. /**
  12265. * 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.
  12266. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12267. */
  12268. get maxEmitBox(): Vector3;
  12269. set maxEmitBox(value: Vector3);
  12270. /**
  12271. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12272. */
  12273. color1: Color4;
  12274. /**
  12275. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12276. */
  12277. color2: Color4;
  12278. /**
  12279. * Color the particle will have at the end of its lifetime
  12280. */
  12281. colorDead: Color4;
  12282. /**
  12283. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12284. */
  12285. textureMask: Color4;
  12286. /**
  12287. * The particle emitter type defines the emitter used by the particle system.
  12288. * It can be for example box, sphere, or cone...
  12289. */
  12290. particleEmitterType: IParticleEmitterType;
  12291. /** @hidden */
  12292. _isSubEmitter: boolean;
  12293. /**
  12294. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12295. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12296. */
  12297. billboardMode: number;
  12298. protected _isBillboardBased: boolean;
  12299. /**
  12300. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12301. */
  12302. get isBillboardBased(): boolean;
  12303. set isBillboardBased(value: boolean);
  12304. /**
  12305. * The scene the particle system belongs to.
  12306. */
  12307. protected _scene: Nullable<Scene>;
  12308. /**
  12309. * The engine the particle system belongs to.
  12310. */
  12311. protected _engine: ThinEngine;
  12312. /**
  12313. * Local cache of defines for image processing.
  12314. */
  12315. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12316. /**
  12317. * Default configuration related to image processing available in the standard Material.
  12318. */
  12319. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12320. /**
  12321. * Gets the image processing configuration used either in this material.
  12322. */
  12323. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12324. /**
  12325. * Sets the Default image processing configuration used either in the this material.
  12326. *
  12327. * If sets to null, the scene one is in use.
  12328. */
  12329. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12330. /**
  12331. * Attaches a new image processing configuration to the Standard Material.
  12332. * @param configuration
  12333. */
  12334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12335. /** @hidden */
  12336. protected _reset(): void;
  12337. /** @hidden */
  12338. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12339. /**
  12340. * Instantiates a particle system.
  12341. * 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.
  12342. * @param name The name of the particle system
  12343. */
  12344. constructor(name: string);
  12345. /**
  12346. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12349. * @returns the emitter
  12350. */
  12351. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12352. /**
  12353. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12354. * @param radius The radius of the hemisphere to emit from
  12355. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12356. * @returns the emitter
  12357. */
  12358. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12359. /**
  12360. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12361. * @param radius The radius of the sphere to emit from
  12362. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12363. * @returns the emitter
  12364. */
  12365. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12366. /**
  12367. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12368. * @param radius The radius of the sphere to emit from
  12369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12371. * @returns the emitter
  12372. */
  12373. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12374. /**
  12375. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12376. * @param radius The radius of the emission cylinder
  12377. * @param height The height of the emission cylinder
  12378. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12379. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12380. * @returns the emitter
  12381. */
  12382. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12383. /**
  12384. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12385. * @param radius The radius of the cylinder to emit from
  12386. * @param height The height of the emission cylinder
  12387. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12388. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12389. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12390. * @returns the emitter
  12391. */
  12392. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12393. /**
  12394. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12395. * @param radius The radius of the cone to emit from
  12396. * @param angle The base angle of the cone
  12397. * @returns the emitter
  12398. */
  12399. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12400. /**
  12401. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12404. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12405. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12406. * @returns the emitter
  12407. */
  12408. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12409. }
  12410. }
  12411. declare module BABYLON {
  12412. /**
  12413. * Type of sub emitter
  12414. */
  12415. export enum SubEmitterType {
  12416. /**
  12417. * Attached to the particle over it's lifetime
  12418. */
  12419. ATTACHED = 0,
  12420. /**
  12421. * Created when the particle dies
  12422. */
  12423. END = 1
  12424. }
  12425. /**
  12426. * Sub emitter class used to emit particles from an existing particle
  12427. */
  12428. export class SubEmitter {
  12429. /**
  12430. * the particle system to be used by the sub emitter
  12431. */
  12432. particleSystem: ParticleSystem;
  12433. /**
  12434. * Type of the submitter (Default: END)
  12435. */
  12436. type: SubEmitterType;
  12437. /**
  12438. * 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)
  12439. * Note: This only is supported when using an emitter of type Mesh
  12440. */
  12441. inheritDirection: boolean;
  12442. /**
  12443. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12444. */
  12445. inheritedVelocityAmount: number;
  12446. /**
  12447. * Creates a sub emitter
  12448. * @param particleSystem the particle system to be used by the sub emitter
  12449. */
  12450. constructor(
  12451. /**
  12452. * the particle system to be used by the sub emitter
  12453. */
  12454. particleSystem: ParticleSystem);
  12455. /**
  12456. * Clones the sub emitter
  12457. * @returns the cloned sub emitter
  12458. */
  12459. clone(): SubEmitter;
  12460. /**
  12461. * Serialize current object to a JSON object
  12462. * @returns the serialized object
  12463. */
  12464. serialize(): any;
  12465. /** @hidden */
  12466. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12467. /**
  12468. * Creates a new SubEmitter from a serialized JSON version
  12469. * @param serializationObject defines the JSON object to read from
  12470. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12471. * @param rootUrl defines the rootUrl for data loading
  12472. * @returns a new SubEmitter
  12473. */
  12474. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12475. /** Release associated resources */
  12476. dispose(): void;
  12477. }
  12478. }
  12479. declare module BABYLON {
  12480. /** @hidden */
  12481. export var imageProcessingDeclaration: {
  12482. name: string;
  12483. shader: string;
  12484. };
  12485. }
  12486. declare module BABYLON {
  12487. /** @hidden */
  12488. export var imageProcessingFunctions: {
  12489. name: string;
  12490. shader: string;
  12491. };
  12492. }
  12493. declare module BABYLON {
  12494. /** @hidden */
  12495. export var particlesPixelShader: {
  12496. name: string;
  12497. shader: string;
  12498. };
  12499. }
  12500. declare module BABYLON {
  12501. /** @hidden */
  12502. export var particlesVertexShader: {
  12503. name: string;
  12504. shader: string;
  12505. };
  12506. }
  12507. declare module BABYLON {
  12508. /**
  12509. * Interface used to define entities containing multiple clip planes
  12510. */
  12511. export interface IClipPlanesHolder {
  12512. /**
  12513. * Gets or sets the active clipplane 1
  12514. */
  12515. clipPlane: Nullable<Plane>;
  12516. /**
  12517. * Gets or sets the active clipplane 2
  12518. */
  12519. clipPlane2: Nullable<Plane>;
  12520. /**
  12521. * Gets or sets the active clipplane 3
  12522. */
  12523. clipPlane3: Nullable<Plane>;
  12524. /**
  12525. * Gets or sets the active clipplane 4
  12526. */
  12527. clipPlane4: Nullable<Plane>;
  12528. /**
  12529. * Gets or sets the active clipplane 5
  12530. */
  12531. clipPlane5: Nullable<Plane>;
  12532. /**
  12533. * Gets or sets the active clipplane 6
  12534. */
  12535. clipPlane6: Nullable<Plane>;
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12541. *
  12542. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12543. *
  12544. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12545. */
  12546. export class ThinMaterialHelper {
  12547. /**
  12548. * Binds the clip plane information from the holder to the effect.
  12549. * @param effect The effect we are binding the data to
  12550. * @param holder The entity containing the clip plane information
  12551. */
  12552. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12553. }
  12554. }
  12555. declare module BABYLON {
  12556. interface ThinEngine {
  12557. /**
  12558. * Sets alpha constants used by some alpha blending modes
  12559. * @param r defines the red component
  12560. * @param g defines the green component
  12561. * @param b defines the blue component
  12562. * @param a defines the alpha component
  12563. */
  12564. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12565. /**
  12566. * Sets the current alpha mode
  12567. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12568. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12569. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12570. */
  12571. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12572. /**
  12573. * Gets the current alpha mode
  12574. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12575. * @returns the current alpha mode
  12576. */
  12577. getAlphaMode(): number;
  12578. /**
  12579. * Sets the current alpha equation
  12580. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12581. */
  12582. setAlphaEquation(equation: number): void;
  12583. /**
  12584. * Gets the current alpha equation.
  12585. * @returns the current alpha equation
  12586. */
  12587. getAlphaEquation(): number;
  12588. }
  12589. }
  12590. declare module BABYLON {
  12591. /**
  12592. * This represents a particle system in Babylon.
  12593. * 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.
  12594. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12595. * @example https://doc.babylonjs.com/babylon101/particles
  12596. */
  12597. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12598. /**
  12599. * Billboard mode will only apply to Y axis
  12600. */
  12601. static readonly BILLBOARDMODE_Y: number;
  12602. /**
  12603. * Billboard mode will apply to all axes
  12604. */
  12605. static readonly BILLBOARDMODE_ALL: number;
  12606. /**
  12607. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12608. */
  12609. static readonly BILLBOARDMODE_STRETCHED: number;
  12610. /**
  12611. * This function can be defined to provide custom update for active particles.
  12612. * This function will be called instead of regular update (age, position, color, etc.).
  12613. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12614. */
  12615. updateFunction: (particles: Particle[]) => void;
  12616. private _emitterWorldMatrix;
  12617. /**
  12618. * This function can be defined to specify initial direction for every new particle.
  12619. * It by default use the emitterType defined function
  12620. */
  12621. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12622. /**
  12623. * This function can be defined to specify initial position for every new particle.
  12624. * It by default use the emitterType defined function
  12625. */
  12626. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12627. /**
  12628. * @hidden
  12629. */
  12630. _inheritedVelocityOffset: Vector3;
  12631. /**
  12632. * An event triggered when the system is disposed
  12633. */
  12634. onDisposeObservable: Observable<IParticleSystem>;
  12635. private _onDisposeObserver;
  12636. /**
  12637. * Sets a callback that will be triggered when the system is disposed
  12638. */
  12639. set onDispose(callback: () => void);
  12640. private _particles;
  12641. private _epsilon;
  12642. private _capacity;
  12643. private _stockParticles;
  12644. private _newPartsExcess;
  12645. private _vertexData;
  12646. private _vertexBuffer;
  12647. private _vertexBuffers;
  12648. private _spriteBuffer;
  12649. private _indexBuffer;
  12650. private _effect;
  12651. private _customEffect;
  12652. private _cachedDefines;
  12653. private _scaledColorStep;
  12654. private _colorDiff;
  12655. private _scaledDirection;
  12656. private _scaledGravity;
  12657. private _currentRenderId;
  12658. private _alive;
  12659. private _useInstancing;
  12660. private _started;
  12661. private _stopped;
  12662. private _actualFrame;
  12663. private _scaledUpdateSpeed;
  12664. private _vertexBufferSize;
  12665. /** @hidden */
  12666. _currentEmitRateGradient: Nullable<FactorGradient>;
  12667. /** @hidden */
  12668. _currentEmitRate1: number;
  12669. /** @hidden */
  12670. _currentEmitRate2: number;
  12671. /** @hidden */
  12672. _currentStartSizeGradient: Nullable<FactorGradient>;
  12673. /** @hidden */
  12674. _currentStartSize1: number;
  12675. /** @hidden */
  12676. _currentStartSize2: number;
  12677. private readonly _rawTextureWidth;
  12678. private _rampGradientsTexture;
  12679. private _useRampGradients;
  12680. /** Gets or sets a matrix to use to compute projection */
  12681. defaultProjectionMatrix: Matrix;
  12682. /** Gets or sets a matrix to use to compute view */
  12683. defaultViewMatrix: Matrix;
  12684. /** Gets or sets a boolean indicating that ramp gradients must be used
  12685. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12686. */
  12687. get useRampGradients(): boolean;
  12688. set useRampGradients(value: boolean);
  12689. /**
  12690. * 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.
  12691. * 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: [])
  12692. */
  12693. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12694. private _subEmitters;
  12695. /**
  12696. * @hidden
  12697. * If the particle systems emitter should be disposed when the particle system is disposed
  12698. */
  12699. _disposeEmitterOnDispose: boolean;
  12700. /**
  12701. * The current active Sub-systems, this property is used by the root particle system only.
  12702. */
  12703. activeSubSystems: Array<ParticleSystem>;
  12704. /**
  12705. * Specifies if the particles are updated in emitter local space or world space
  12706. */
  12707. isLocal: boolean;
  12708. private _rootParticleSystem;
  12709. /**
  12710. * Gets the current list of active particles
  12711. */
  12712. get particles(): Particle[];
  12713. /**
  12714. * Gets the number of particles active at the same time.
  12715. * @returns The number of active particles.
  12716. */
  12717. getActiveCount(): number;
  12718. /**
  12719. * Returns the string "ParticleSystem"
  12720. * @returns a string containing the class name
  12721. */
  12722. getClassName(): string;
  12723. /**
  12724. * Gets a boolean indicating that the system is stopping
  12725. * @returns true if the system is currently stopping
  12726. */
  12727. isStopping(): boolean;
  12728. /**
  12729. * Gets the custom effect used to render the particles
  12730. * @param blendMode Blend mode for which the effect should be retrieved
  12731. * @returns The effect
  12732. */
  12733. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12734. /**
  12735. * Sets the custom effect used to render the particles
  12736. * @param effect The effect to set
  12737. * @param blendMode Blend mode for which the effect should be set
  12738. */
  12739. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12740. /** @hidden */
  12741. private _onBeforeDrawParticlesObservable;
  12742. /**
  12743. * Observable that will be called just before the particles are drawn
  12744. */
  12745. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12746. /**
  12747. * Gets the name of the particle vertex shader
  12748. */
  12749. get vertexShaderName(): string;
  12750. /**
  12751. * Instantiates a particle system.
  12752. * 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.
  12753. * @param name The name of the particle system
  12754. * @param capacity The max number of particles alive at the same time
  12755. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12756. * @param customEffect a custom effect used to change the way particles are rendered by default
  12757. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12758. * @param epsilon Offset used to render the particles
  12759. */
  12760. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12761. private _addFactorGradient;
  12762. private _removeFactorGradient;
  12763. /**
  12764. * Adds a new life time gradient
  12765. * @param gradient defines the gradient to use (between 0 and 1)
  12766. * @param factor defines the life time factor to affect to the specified gradient
  12767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12768. * @returns the current particle system
  12769. */
  12770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12771. /**
  12772. * Remove a specific life time gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12777. /**
  12778. * Adds a new size gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param factor defines the size factor to affect to the specified gradient
  12781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12782. * @returns the current particle system
  12783. */
  12784. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12785. /**
  12786. * Remove a specific size gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns the current particle system
  12789. */
  12790. removeSizeGradient(gradient: number): IParticleSystem;
  12791. /**
  12792. * Adds a new color remap gradient
  12793. * @param gradient defines the gradient to use (between 0 and 1)
  12794. * @param min defines the color remap minimal range
  12795. * @param max defines the color remap maximal range
  12796. * @returns the current particle system
  12797. */
  12798. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12799. /**
  12800. * Remove a specific color remap gradient
  12801. * @param gradient defines the gradient to remove
  12802. * @returns the current particle system
  12803. */
  12804. removeColorRemapGradient(gradient: number): IParticleSystem;
  12805. /**
  12806. * Adds a new alpha remap gradient
  12807. * @param gradient defines the gradient to use (between 0 and 1)
  12808. * @param min defines the alpha remap minimal range
  12809. * @param max defines the alpha remap maximal range
  12810. * @returns the current particle system
  12811. */
  12812. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12813. /**
  12814. * Remove a specific alpha remap gradient
  12815. * @param gradient defines the gradient to remove
  12816. * @returns the current particle system
  12817. */
  12818. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12819. /**
  12820. * Adds a new angular speed gradient
  12821. * @param gradient defines the gradient to use (between 0 and 1)
  12822. * @param factor defines the angular speed to affect to the specified gradient
  12823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12824. * @returns the current particle system
  12825. */
  12826. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12827. /**
  12828. * Remove a specific angular speed gradient
  12829. * @param gradient defines the gradient to remove
  12830. * @returns the current particle system
  12831. */
  12832. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12833. /**
  12834. * Adds a new velocity gradient
  12835. * @param gradient defines the gradient to use (between 0 and 1)
  12836. * @param factor defines the velocity to affect to the specified gradient
  12837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12838. * @returns the current particle system
  12839. */
  12840. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12841. /**
  12842. * Remove a specific velocity gradient
  12843. * @param gradient defines the gradient to remove
  12844. * @returns the current particle system
  12845. */
  12846. removeVelocityGradient(gradient: number): IParticleSystem;
  12847. /**
  12848. * Adds a new limit velocity gradient
  12849. * @param gradient defines the gradient to use (between 0 and 1)
  12850. * @param factor defines the limit velocity value to affect to the specified gradient
  12851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12852. * @returns the current particle system
  12853. */
  12854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12855. /**
  12856. * Remove a specific limit velocity gradient
  12857. * @param gradient defines the gradient to remove
  12858. * @returns the current particle system
  12859. */
  12860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12861. /**
  12862. * Adds a new drag gradient
  12863. * @param gradient defines the gradient to use (between 0 and 1)
  12864. * @param factor defines the drag value to affect to the specified gradient
  12865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12866. * @returns the current particle system
  12867. */
  12868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12869. /**
  12870. * Remove a specific drag gradient
  12871. * @param gradient defines the gradient to remove
  12872. * @returns the current particle system
  12873. */
  12874. removeDragGradient(gradient: number): IParticleSystem;
  12875. /**
  12876. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12877. * @param gradient defines the gradient to use (between 0 and 1)
  12878. * @param factor defines the emit rate value to affect to the specified gradient
  12879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12880. * @returns the current particle system
  12881. */
  12882. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12883. /**
  12884. * Remove a specific emit rate gradient
  12885. * @param gradient defines the gradient to remove
  12886. * @returns the current particle system
  12887. */
  12888. removeEmitRateGradient(gradient: number): IParticleSystem;
  12889. /**
  12890. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12891. * @param gradient defines the gradient to use (between 0 and 1)
  12892. * @param factor defines the start size value to affect to the specified gradient
  12893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12894. * @returns the current particle system
  12895. */
  12896. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12897. /**
  12898. * Remove a specific start size gradient
  12899. * @param gradient defines the gradient to remove
  12900. * @returns the current particle system
  12901. */
  12902. removeStartSizeGradient(gradient: number): IParticleSystem;
  12903. private _createRampGradientTexture;
  12904. /**
  12905. * Gets the current list of ramp gradients.
  12906. * You must use addRampGradient and removeRampGradient to udpate this list
  12907. * @returns the list of ramp gradients
  12908. */
  12909. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12910. /** Force the system to rebuild all gradients that need to be resync */
  12911. forceRefreshGradients(): void;
  12912. private _syncRampGradientTexture;
  12913. /**
  12914. * Adds a new ramp gradient used to remap particle colors
  12915. * @param gradient defines the gradient to use (between 0 and 1)
  12916. * @param color defines the color to affect to the specified gradient
  12917. * @returns the current particle system
  12918. */
  12919. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12920. /**
  12921. * Remove a specific ramp gradient
  12922. * @param gradient defines the gradient to remove
  12923. * @returns the current particle system
  12924. */
  12925. removeRampGradient(gradient: number): ParticleSystem;
  12926. /**
  12927. * Adds a new color gradient
  12928. * @param gradient defines the gradient to use (between 0 and 1)
  12929. * @param color1 defines the color to affect to the specified gradient
  12930. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12931. * @returns this particle system
  12932. */
  12933. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12934. /**
  12935. * Remove a specific color gradient
  12936. * @param gradient defines the gradient to remove
  12937. * @returns this particle system
  12938. */
  12939. removeColorGradient(gradient: number): IParticleSystem;
  12940. private _fetchR;
  12941. protected _reset(): void;
  12942. private _resetEffect;
  12943. private _createVertexBuffers;
  12944. private _createIndexBuffer;
  12945. /**
  12946. * Gets the maximum number of particles active at the same time.
  12947. * @returns The max number of active particles.
  12948. */
  12949. getCapacity(): number;
  12950. /**
  12951. * Gets whether there are still active particles in the system.
  12952. * @returns True if it is alive, otherwise false.
  12953. */
  12954. isAlive(): boolean;
  12955. /**
  12956. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12957. * @returns True if it has been started, otherwise false.
  12958. */
  12959. isStarted(): boolean;
  12960. private _prepareSubEmitterInternalArray;
  12961. /**
  12962. * Starts the particle system and begins to emit
  12963. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12964. */
  12965. start(delay?: number): void;
  12966. /**
  12967. * Stops the particle system.
  12968. * @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.
  12969. */
  12970. stop(stopSubEmitters?: boolean): void;
  12971. /**
  12972. * Remove all active particles
  12973. */
  12974. reset(): void;
  12975. /**
  12976. * @hidden (for internal use only)
  12977. */
  12978. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12979. /**
  12980. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12981. * Its lifetime will start back at 0.
  12982. */
  12983. recycleParticle: (particle: Particle) => void;
  12984. private _stopSubEmitters;
  12985. private _createParticle;
  12986. private _removeFromRoot;
  12987. private _emitFromParticle;
  12988. private _update;
  12989. /** @hidden */
  12990. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12991. /** @hidden */
  12992. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12993. /**
  12994. * Fill the defines array according to the current settings of the particle system
  12995. * @param defines Array to be updated
  12996. * @param blendMode blend mode to take into account when updating the array
  12997. */
  12998. fillDefines(defines: Array<string>, blendMode: number): void;
  12999. /**
  13000. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13001. * @param uniforms Uniforms array to fill
  13002. * @param attributes Attributes array to fill
  13003. * @param samplers Samplers array to fill
  13004. */
  13005. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13006. /** @hidden */
  13007. private _getEffect;
  13008. /**
  13009. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13010. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13011. */
  13012. animate(preWarmOnly?: boolean): void;
  13013. private _appendParticleVertices;
  13014. /**
  13015. * Rebuilds the particle system.
  13016. */
  13017. rebuild(): void;
  13018. /**
  13019. * Is this system ready to be used/rendered
  13020. * @return true if the system is ready
  13021. */
  13022. isReady(): boolean;
  13023. private _render;
  13024. /**
  13025. * Renders the particle system in its current state.
  13026. * @returns the current number of particles
  13027. */
  13028. render(): number;
  13029. /**
  13030. * Disposes the particle system and free the associated resources
  13031. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13032. */
  13033. dispose(disposeTexture?: boolean): void;
  13034. /**
  13035. * Clones the particle system.
  13036. * @param name The name of the cloned object
  13037. * @param newEmitter The new emitter to use
  13038. * @returns the cloned particle system
  13039. */
  13040. clone(name: string, newEmitter: any): ParticleSystem;
  13041. /**
  13042. * Serializes the particle system to a JSON object
  13043. * @param serializeTexture defines if the texture must be serialized as well
  13044. * @returns the JSON object
  13045. */
  13046. serialize(serializeTexture?: boolean): any;
  13047. /** @hidden */
  13048. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13049. /** @hidden */
  13050. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13051. /**
  13052. * Parses a JSON object to create a particle system.
  13053. * @param parsedParticleSystem The JSON object to parse
  13054. * @param sceneOrEngine The scene or the engine to create the particle system in
  13055. * @param rootUrl The root url to use to load external dependencies like texture
  13056. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13057. * @returns the Parsed particle system
  13058. */
  13059. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13060. }
  13061. }
  13062. declare module BABYLON {
  13063. /**
  13064. * A particle represents one of the element emitted by a particle system.
  13065. * This is mainly define by its coordinates, direction, velocity and age.
  13066. */
  13067. export class Particle {
  13068. /**
  13069. * The particle system the particle belongs to.
  13070. */
  13071. particleSystem: ParticleSystem;
  13072. private static _Count;
  13073. /**
  13074. * Unique ID of the particle
  13075. */
  13076. id: number;
  13077. /**
  13078. * The world position of the particle in the scene.
  13079. */
  13080. position: Vector3;
  13081. /**
  13082. * The world direction of the particle in the scene.
  13083. */
  13084. direction: Vector3;
  13085. /**
  13086. * The color of the particle.
  13087. */
  13088. color: Color4;
  13089. /**
  13090. * The color change of the particle per step.
  13091. */
  13092. colorStep: Color4;
  13093. /**
  13094. * Defines how long will the life of the particle be.
  13095. */
  13096. lifeTime: number;
  13097. /**
  13098. * The current age of the particle.
  13099. */
  13100. age: number;
  13101. /**
  13102. * The current size of the particle.
  13103. */
  13104. size: number;
  13105. /**
  13106. * The current scale of the particle.
  13107. */
  13108. scale: Vector2;
  13109. /**
  13110. * The current angle of the particle.
  13111. */
  13112. angle: number;
  13113. /**
  13114. * Defines how fast is the angle changing.
  13115. */
  13116. angularSpeed: number;
  13117. /**
  13118. * Defines the cell index used by the particle to be rendered from a sprite.
  13119. */
  13120. cellIndex: number;
  13121. /**
  13122. * The information required to support color remapping
  13123. */
  13124. remapData: Vector4;
  13125. /** @hidden */
  13126. _randomCellOffset?: number;
  13127. /** @hidden */
  13128. _initialDirection: Nullable<Vector3>;
  13129. /** @hidden */
  13130. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13131. /** @hidden */
  13132. _initialStartSpriteCellID: number;
  13133. /** @hidden */
  13134. _initialEndSpriteCellID: number;
  13135. /** @hidden */
  13136. _currentColorGradient: Nullable<ColorGradient>;
  13137. /** @hidden */
  13138. _currentColor1: Color4;
  13139. /** @hidden */
  13140. _currentColor2: Color4;
  13141. /** @hidden */
  13142. _currentSizeGradient: Nullable<FactorGradient>;
  13143. /** @hidden */
  13144. _currentSize1: number;
  13145. /** @hidden */
  13146. _currentSize2: number;
  13147. /** @hidden */
  13148. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13149. /** @hidden */
  13150. _currentAngularSpeed1: number;
  13151. /** @hidden */
  13152. _currentAngularSpeed2: number;
  13153. /** @hidden */
  13154. _currentVelocityGradient: Nullable<FactorGradient>;
  13155. /** @hidden */
  13156. _currentVelocity1: number;
  13157. /** @hidden */
  13158. _currentVelocity2: number;
  13159. /** @hidden */
  13160. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13161. /** @hidden */
  13162. _currentLimitVelocity1: number;
  13163. /** @hidden */
  13164. _currentLimitVelocity2: number;
  13165. /** @hidden */
  13166. _currentDragGradient: Nullable<FactorGradient>;
  13167. /** @hidden */
  13168. _currentDrag1: number;
  13169. /** @hidden */
  13170. _currentDrag2: number;
  13171. /** @hidden */
  13172. _randomNoiseCoordinates1: Vector3;
  13173. /** @hidden */
  13174. _randomNoiseCoordinates2: Vector3;
  13175. /** @hidden */
  13176. _localPosition?: Vector3;
  13177. /**
  13178. * Creates a new instance Particle
  13179. * @param particleSystem the particle system the particle belongs to
  13180. */
  13181. constructor(
  13182. /**
  13183. * The particle system the particle belongs to.
  13184. */
  13185. particleSystem: ParticleSystem);
  13186. private updateCellInfoFromSystem;
  13187. /**
  13188. * Defines how the sprite cell index is updated for the particle
  13189. */
  13190. updateCellIndex(): void;
  13191. /** @hidden */
  13192. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13193. /** @hidden */
  13194. _inheritParticleInfoToSubEmitters(): void;
  13195. /** @hidden */
  13196. _reset(): void;
  13197. /**
  13198. * Copy the properties of particle to another one.
  13199. * @param other the particle to copy the information to.
  13200. */
  13201. copyTo(other: Particle): void;
  13202. }
  13203. }
  13204. declare module BABYLON {
  13205. /**
  13206. * Particle emitter represents a volume emitting particles.
  13207. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13208. */
  13209. export interface IParticleEmitterType {
  13210. /**
  13211. * Called by the particle System when the direction is computed for the created particle.
  13212. * @param worldMatrix is the world matrix of the particle system
  13213. * @param directionToUpdate is the direction vector to update with the result
  13214. * @param particle is the particle we are computed the direction for
  13215. * @param isLocal defines if the direction should be set in local space
  13216. */
  13217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13218. /**
  13219. * Called by the particle System when the position is computed for the created particle.
  13220. * @param worldMatrix is the world matrix of the particle system
  13221. * @param positionToUpdate is the position vector to update with the result
  13222. * @param particle is the particle we are computed the position for
  13223. * @param isLocal defines if the position should be set in local space
  13224. */
  13225. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13226. /**
  13227. * Clones the current emitter and returns a copy of it
  13228. * @returns the new emitter
  13229. */
  13230. clone(): IParticleEmitterType;
  13231. /**
  13232. * Called by the GPUParticleSystem to setup the update shader
  13233. * @param effect defines the update shader
  13234. */
  13235. applyToShader(effect: Effect): void;
  13236. /**
  13237. * Returns a string to use to update the GPU particles update shader
  13238. * @returns the effect defines string
  13239. */
  13240. getEffectDefines(): string;
  13241. /**
  13242. * Returns a string representing the class name
  13243. * @returns a string containing the class name
  13244. */
  13245. getClassName(): string;
  13246. /**
  13247. * Serializes the particle system to a JSON object.
  13248. * @returns the JSON object
  13249. */
  13250. serialize(): any;
  13251. /**
  13252. * Parse properties from a JSON object
  13253. * @param serializationObject defines the JSON object
  13254. * @param scene defines the hosting scene
  13255. */
  13256. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13257. }
  13258. }
  13259. declare module BABYLON {
  13260. /**
  13261. * Particle emitter emitting particles from the inside of a box.
  13262. * It emits the particles randomly between 2 given directions.
  13263. */
  13264. export class BoxParticleEmitter implements IParticleEmitterType {
  13265. /**
  13266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13267. */
  13268. direction1: Vector3;
  13269. /**
  13270. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13271. */
  13272. direction2: Vector3;
  13273. /**
  13274. * 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.
  13275. */
  13276. minEmitBox: Vector3;
  13277. /**
  13278. * 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.
  13279. */
  13280. maxEmitBox: Vector3;
  13281. /**
  13282. * Creates a new instance BoxParticleEmitter
  13283. */
  13284. constructor();
  13285. /**
  13286. * Called by the particle System when the direction is computed for the created particle.
  13287. * @param worldMatrix is the world matrix of the particle system
  13288. * @param directionToUpdate is the direction vector to update with the result
  13289. * @param particle is the particle we are computed the direction for
  13290. * @param isLocal defines if the direction should be set in local space
  13291. */
  13292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13293. /**
  13294. * Called by the particle System when the position is computed for the created particle.
  13295. * @param worldMatrix is the world matrix of the particle system
  13296. * @param positionToUpdate is the position vector to update with the result
  13297. * @param particle is the particle we are computed the position for
  13298. * @param isLocal defines if the position should be set in local space
  13299. */
  13300. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13301. /**
  13302. * Clones the current emitter and returns a copy of it
  13303. * @returns the new emitter
  13304. */
  13305. clone(): BoxParticleEmitter;
  13306. /**
  13307. * Called by the GPUParticleSystem to setup the update shader
  13308. * @param effect defines the update shader
  13309. */
  13310. applyToShader(effect: Effect): void;
  13311. /**
  13312. * Returns a string to use to update the GPU particles update shader
  13313. * @returns a string containng the defines string
  13314. */
  13315. getEffectDefines(): string;
  13316. /**
  13317. * Returns the string "BoxParticleEmitter"
  13318. * @returns a string containing the class name
  13319. */
  13320. getClassName(): string;
  13321. /**
  13322. * Serializes the particle system to a JSON object.
  13323. * @returns the JSON object
  13324. */
  13325. serialize(): any;
  13326. /**
  13327. * Parse properties from a JSON object
  13328. * @param serializationObject defines the JSON object
  13329. */
  13330. parse(serializationObject: any): void;
  13331. }
  13332. }
  13333. declare module BABYLON {
  13334. /**
  13335. * Particle emitter emitting particles from the inside of a cone.
  13336. * It emits the particles alongside the cone volume from the base to the particle.
  13337. * The emission direction might be randomized.
  13338. */
  13339. export class ConeParticleEmitter implements IParticleEmitterType {
  13340. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13341. directionRandomizer: number;
  13342. private _radius;
  13343. private _angle;
  13344. private _height;
  13345. /**
  13346. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13347. */
  13348. radiusRange: number;
  13349. /**
  13350. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13351. */
  13352. heightRange: number;
  13353. /**
  13354. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13355. */
  13356. emitFromSpawnPointOnly: boolean;
  13357. /**
  13358. * Gets or sets the radius of the emission cone
  13359. */
  13360. get radius(): number;
  13361. set radius(value: number);
  13362. /**
  13363. * Gets or sets the angle of the emission cone
  13364. */
  13365. get angle(): number;
  13366. set angle(value: number);
  13367. private _buildHeight;
  13368. /**
  13369. * Creates a new instance ConeParticleEmitter
  13370. * @param radius the radius of the emission cone (1 by default)
  13371. * @param angle the cone base angle (PI by default)
  13372. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13373. */
  13374. constructor(radius?: number, angle?: number,
  13375. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  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(): ConeParticleEmitter;
  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 "ConeParticleEmitter"
  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 the inside of a cylinder.
  13428. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13429. */
  13430. export class CylinderParticleEmitter implements IParticleEmitterType {
  13431. /**
  13432. * The radius of the emission cylinder.
  13433. */
  13434. radius: number;
  13435. /**
  13436. * The height of the emission cylinder.
  13437. */
  13438. height: number;
  13439. /**
  13440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13441. */
  13442. radiusRange: number;
  13443. /**
  13444. * How much to randomize the particle direction [0-1].
  13445. */
  13446. directionRandomizer: number;
  13447. /**
  13448. * Creates a new instance CylinderParticleEmitter
  13449. * @param radius the radius of the emission cylinder (1 by default)
  13450. * @param height the height of the emission cylinder (1 by default)
  13451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13453. */
  13454. constructor(
  13455. /**
  13456. * The radius of the emission cylinder.
  13457. */
  13458. radius?: number,
  13459. /**
  13460. * The height of the emission cylinder.
  13461. */
  13462. height?: number,
  13463. /**
  13464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13465. */
  13466. radiusRange?: number,
  13467. /**
  13468. * How much to randomize the particle direction [0-1].
  13469. */
  13470. directionRandomizer?: number);
  13471. /**
  13472. * Called by the particle System when the direction is computed for the created particle.
  13473. * @param worldMatrix is the world matrix of the particle system
  13474. * @param directionToUpdate is the direction vector to update with the result
  13475. * @param particle is the particle we are computed the direction for
  13476. * @param isLocal defines if the direction should be set in local space
  13477. */
  13478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13479. /**
  13480. * Called by the particle System when the position is computed for the created particle.
  13481. * @param worldMatrix is the world matrix of the particle system
  13482. * @param positionToUpdate is the position vector to update with the result
  13483. * @param particle is the particle we are computed the position for
  13484. * @param isLocal defines if the position should be set in local space
  13485. */
  13486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13487. /**
  13488. * Clones the current emitter and returns a copy of it
  13489. * @returns the new emitter
  13490. */
  13491. clone(): CylinderParticleEmitter;
  13492. /**
  13493. * Called by the GPUParticleSystem to setup the update shader
  13494. * @param effect defines the update shader
  13495. */
  13496. applyToShader(effect: Effect): void;
  13497. /**
  13498. * Returns a string to use to update the GPU particles update shader
  13499. * @returns a string containng the defines string
  13500. */
  13501. getEffectDefines(): string;
  13502. /**
  13503. * Returns the string "CylinderParticleEmitter"
  13504. * @returns a string containing the class name
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Serializes the particle system to a JSON object.
  13509. * @returns the JSON object
  13510. */
  13511. serialize(): any;
  13512. /**
  13513. * Parse properties from a JSON object
  13514. * @param serializationObject defines the JSON object
  13515. */
  13516. parse(serializationObject: any): void;
  13517. }
  13518. /**
  13519. * Particle emitter emitting particles from the inside of a cylinder.
  13520. * It emits the particles randomly between two vectors.
  13521. */
  13522. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13523. /**
  13524. * The min limit of the emission direction.
  13525. */
  13526. direction1: Vector3;
  13527. /**
  13528. * The max limit of the emission direction.
  13529. */
  13530. direction2: Vector3;
  13531. /**
  13532. * Creates a new instance CylinderDirectedParticleEmitter
  13533. * @param radius the radius of the emission cylinder (1 by default)
  13534. * @param height the height of the emission cylinder (1 by default)
  13535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13536. * @param direction1 the min limit of the emission direction (up vector by default)
  13537. * @param direction2 the max limit of the emission direction (up vector by default)
  13538. */
  13539. constructor(radius?: number, height?: number, radiusRange?: number,
  13540. /**
  13541. * The min limit of the emission direction.
  13542. */
  13543. direction1?: Vector3,
  13544. /**
  13545. * The max limit of the emission direction.
  13546. */
  13547. direction2?: Vector3);
  13548. /**
  13549. * Called by the particle System when the direction is computed for the created particle.
  13550. * @param worldMatrix is the world matrix of the particle system
  13551. * @param directionToUpdate is the direction vector to update with the result
  13552. * @param particle is the particle we are computed the direction for
  13553. */
  13554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderDirectedParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderDirectedParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a hemisphere.
  13590. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13591. */
  13592. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission hemisphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance HemisphericParticleEmitter
  13607. * @param radius the radius of the emission hemisphere (1 by default)
  13608. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission hemisphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): HemisphericParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "HemisphericParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. }
  13672. declare module BABYLON {
  13673. /**
  13674. * Particle emitter emitting particles from a point.
  13675. * It emits the particles randomly between 2 given directions.
  13676. */
  13677. export class PointParticleEmitter implements IParticleEmitterType {
  13678. /**
  13679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance PointParticleEmitter
  13688. */
  13689. constructor();
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. * @param isLocal defines if the direction should be set in local space
  13696. */
  13697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13698. /**
  13699. * Called by the particle System when the position is computed for the created particle.
  13700. * @param worldMatrix is the world matrix of the particle system
  13701. * @param positionToUpdate is the position vector to update with the result
  13702. * @param particle is the particle we are computed the position for
  13703. * @param isLocal defines if the position should be set in local space
  13704. */
  13705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): PointParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "PointParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from the inside of a sphere.
  13741. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13742. */
  13743. export class SphereParticleEmitter implements IParticleEmitterType {
  13744. /**
  13745. * The radius of the emission sphere.
  13746. */
  13747. radius: number;
  13748. /**
  13749. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13750. */
  13751. radiusRange: number;
  13752. /**
  13753. * How much to randomize the particle direction [0-1].
  13754. */
  13755. directionRandomizer: number;
  13756. /**
  13757. * Creates a new instance SphereParticleEmitter
  13758. * @param radius the radius of the emission sphere (1 by default)
  13759. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13760. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13761. */
  13762. constructor(
  13763. /**
  13764. * The radius of the emission sphere.
  13765. */
  13766. radius?: number,
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange?: number,
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer?: number);
  13775. /**
  13776. * Called by the particle System when the direction is computed for the created particle.
  13777. * @param worldMatrix is the world matrix of the particle system
  13778. * @param directionToUpdate is the direction vector to update with the result
  13779. * @param particle is the particle we are computed the direction for
  13780. * @param isLocal defines if the direction should be set in local space
  13781. */
  13782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13783. /**
  13784. * Called by the particle System when the position is computed for the created particle.
  13785. * @param worldMatrix is the world matrix of the particle system
  13786. * @param positionToUpdate is the position vector to update with the result
  13787. * @param particle is the particle we are computed the position for
  13788. * @param isLocal defines if the position should be set in local space
  13789. */
  13790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13791. /**
  13792. * Clones the current emitter and returns a copy of it
  13793. * @returns the new emitter
  13794. */
  13795. clone(): SphereParticleEmitter;
  13796. /**
  13797. * Called by the GPUParticleSystem to setup the update shader
  13798. * @param effect defines the update shader
  13799. */
  13800. applyToShader(effect: Effect): void;
  13801. /**
  13802. * Returns a string to use to update the GPU particles update shader
  13803. * @returns a string containng the defines string
  13804. */
  13805. getEffectDefines(): string;
  13806. /**
  13807. * Returns the string "SphereParticleEmitter"
  13808. * @returns a string containing the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Serializes the particle system to a JSON object.
  13813. * @returns the JSON object
  13814. */
  13815. serialize(): any;
  13816. /**
  13817. * Parse properties from a JSON object
  13818. * @param serializationObject defines the JSON object
  13819. */
  13820. parse(serializationObject: any): void;
  13821. }
  13822. /**
  13823. * Particle emitter emitting particles from the inside of a sphere.
  13824. * It emits the particles randomly between two vectors.
  13825. */
  13826. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13827. /**
  13828. * The min limit of the emission direction.
  13829. */
  13830. direction1: Vector3;
  13831. /**
  13832. * The max limit of the emission direction.
  13833. */
  13834. direction2: Vector3;
  13835. /**
  13836. * Creates a new instance SphereDirectedParticleEmitter
  13837. * @param radius the radius of the emission sphere (1 by default)
  13838. * @param direction1 the min limit of the emission direction (up vector by default)
  13839. * @param direction2 the max limit of the emission direction (up vector by default)
  13840. */
  13841. constructor(radius?: number,
  13842. /**
  13843. * The min limit of the emission direction.
  13844. */
  13845. direction1?: Vector3,
  13846. /**
  13847. * The max limit of the emission direction.
  13848. */
  13849. direction2?: Vector3);
  13850. /**
  13851. * Called by the particle System when the direction is computed for the created particle.
  13852. * @param worldMatrix is the world matrix of the particle system
  13853. * @param directionToUpdate is the direction vector to update with the result
  13854. * @param particle is the particle we are computed the direction for
  13855. */
  13856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13857. /**
  13858. * Clones the current emitter and returns a copy of it
  13859. * @returns the new emitter
  13860. */
  13861. clone(): SphereDirectedParticleEmitter;
  13862. /**
  13863. * Called by the GPUParticleSystem to setup the update shader
  13864. * @param effect defines the update shader
  13865. */
  13866. applyToShader(effect: Effect): void;
  13867. /**
  13868. * Returns a string to use to update the GPU particles update shader
  13869. * @returns a string containng the defines string
  13870. */
  13871. getEffectDefines(): string;
  13872. /**
  13873. * Returns the string "SphereDirectedParticleEmitter"
  13874. * @returns a string containing the class name
  13875. */
  13876. getClassName(): string;
  13877. /**
  13878. * Serializes the particle system to a JSON object.
  13879. * @returns the JSON object
  13880. */
  13881. serialize(): any;
  13882. /**
  13883. * Parse properties from a JSON object
  13884. * @param serializationObject defines the JSON object
  13885. */
  13886. parse(serializationObject: any): void;
  13887. }
  13888. }
  13889. declare module BABYLON {
  13890. /**
  13891. * Particle emitter emitting particles from a custom list of positions.
  13892. */
  13893. export class CustomParticleEmitter implements IParticleEmitterType {
  13894. /**
  13895. * Gets or sets the position generator that will create the inital position of each particle.
  13896. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13897. */
  13898. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13899. /**
  13900. * Gets or sets the destination generator that will create the final destination of each particle.
  13901. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13902. */
  13903. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13904. /**
  13905. * Creates a new instance CustomParticleEmitter
  13906. */
  13907. constructor();
  13908. /**
  13909. * Called by the particle System when the direction is computed for the created particle.
  13910. * @param worldMatrix is the world matrix of the particle system
  13911. * @param directionToUpdate is the direction vector to update with the result
  13912. * @param particle is the particle we are computed the direction for
  13913. * @param isLocal defines if the direction should be set in local space
  13914. */
  13915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13916. /**
  13917. * Called by the particle System when the position is computed for the created particle.
  13918. * @param worldMatrix is the world matrix of the particle system
  13919. * @param positionToUpdate is the position vector to update with the result
  13920. * @param particle is the particle we are computed the position for
  13921. * @param isLocal defines if the position should be set in local space
  13922. */
  13923. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13924. /**
  13925. * Clones the current emitter and returns a copy of it
  13926. * @returns the new emitter
  13927. */
  13928. clone(): CustomParticleEmitter;
  13929. /**
  13930. * Called by the GPUParticleSystem to setup the update shader
  13931. * @param effect defines the update shader
  13932. */
  13933. applyToShader(effect: Effect): void;
  13934. /**
  13935. * Returns a string to use to update the GPU particles update shader
  13936. * @returns a string containng the defines string
  13937. */
  13938. getEffectDefines(): string;
  13939. /**
  13940. * Returns the string "PointParticleEmitter"
  13941. * @returns a string containing the class name
  13942. */
  13943. getClassName(): string;
  13944. /**
  13945. * Serializes the particle system to a JSON object.
  13946. * @returns the JSON object
  13947. */
  13948. serialize(): any;
  13949. /**
  13950. * Parse properties from a JSON object
  13951. * @param serializationObject defines the JSON object
  13952. */
  13953. parse(serializationObject: any): void;
  13954. }
  13955. }
  13956. declare module BABYLON {
  13957. /**
  13958. * Particle emitter emitting particles from the inside of a box.
  13959. * It emits the particles randomly between 2 given directions.
  13960. */
  13961. export class MeshParticleEmitter implements IParticleEmitterType {
  13962. private _indices;
  13963. private _positions;
  13964. private _normals;
  13965. private _storedNormal;
  13966. private _mesh;
  13967. /**
  13968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13969. */
  13970. direction1: Vector3;
  13971. /**
  13972. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13973. */
  13974. direction2: Vector3;
  13975. /**
  13976. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13977. */
  13978. useMeshNormalsForDirection: boolean;
  13979. /** Defines the mesh to use as source */
  13980. get mesh(): Nullable<AbstractMesh>;
  13981. set mesh(value: Nullable<AbstractMesh>);
  13982. /**
  13983. * Creates a new instance MeshParticleEmitter
  13984. * @param mesh defines the mesh to use as source
  13985. */
  13986. constructor(mesh?: Nullable<AbstractMesh>);
  13987. /**
  13988. * Called by the particle System when the direction is computed for the created particle.
  13989. * @param worldMatrix is the world matrix of the particle system
  13990. * @param directionToUpdate is the direction vector to update with the result
  13991. * @param particle is the particle we are computed the direction for
  13992. * @param isLocal defines if the direction should be set in local space
  13993. */
  13994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13995. /**
  13996. * Called by the particle System when the position is computed for the created particle.
  13997. * @param worldMatrix is the world matrix of the particle system
  13998. * @param positionToUpdate is the position vector to update with the result
  13999. * @param particle is the particle we are computed the position for
  14000. * @param isLocal defines if the position should be set in local space
  14001. */
  14002. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14003. /**
  14004. * Clones the current emitter and returns a copy of it
  14005. * @returns the new emitter
  14006. */
  14007. clone(): MeshParticleEmitter;
  14008. /**
  14009. * Called by the GPUParticleSystem to setup the update shader
  14010. * @param effect defines the update shader
  14011. */
  14012. applyToShader(effect: Effect): void;
  14013. /**
  14014. * Returns a string to use to update the GPU particles update shader
  14015. * @returns a string containng the defines string
  14016. */
  14017. getEffectDefines(): string;
  14018. /**
  14019. * Returns the string "BoxParticleEmitter"
  14020. * @returns a string containing the class name
  14021. */
  14022. getClassName(): string;
  14023. /**
  14024. * Serializes the particle system to a JSON object.
  14025. * @returns the JSON object
  14026. */
  14027. serialize(): any;
  14028. /**
  14029. * Parse properties from a JSON object
  14030. * @param serializationObject defines the JSON object
  14031. * @param scene defines the hosting scene
  14032. */
  14033. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14034. }
  14035. }
  14036. declare module BABYLON {
  14037. /**
  14038. * Interface representing a particle system in Babylon.js.
  14039. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14040. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14041. */
  14042. export interface IParticleSystem {
  14043. /**
  14044. * List of animations used by the particle system.
  14045. */
  14046. animations: Animation[];
  14047. /**
  14048. * The id of the Particle system.
  14049. */
  14050. id: string;
  14051. /**
  14052. * The name of the Particle system.
  14053. */
  14054. name: string;
  14055. /**
  14056. * The emitter represents the Mesh or position we are attaching the particle system to.
  14057. */
  14058. emitter: Nullable<AbstractMesh | Vector3>;
  14059. /**
  14060. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14061. */
  14062. isBillboardBased: boolean;
  14063. /**
  14064. * The rendering group used by the Particle system to chose when to render.
  14065. */
  14066. renderingGroupId: number;
  14067. /**
  14068. * The layer mask we are rendering the particles through.
  14069. */
  14070. layerMask: number;
  14071. /**
  14072. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14073. */
  14074. updateSpeed: number;
  14075. /**
  14076. * The amount of time the particle system is running (depends of the overall update speed).
  14077. */
  14078. targetStopDuration: number;
  14079. /**
  14080. * The texture used to render each particle. (this can be a spritesheet)
  14081. */
  14082. particleTexture: Nullable<BaseTexture>;
  14083. /**
  14084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14085. */
  14086. blendMode: number;
  14087. /**
  14088. * Minimum life time of emitting particles.
  14089. */
  14090. minLifeTime: number;
  14091. /**
  14092. * Maximum life time of emitting particles.
  14093. */
  14094. maxLifeTime: number;
  14095. /**
  14096. * Minimum Size of emitting particles.
  14097. */
  14098. minSize: number;
  14099. /**
  14100. * Maximum Size of emitting particles.
  14101. */
  14102. maxSize: number;
  14103. /**
  14104. * Minimum scale of emitting particles on X axis.
  14105. */
  14106. minScaleX: number;
  14107. /**
  14108. * Maximum scale of emitting particles on X axis.
  14109. */
  14110. maxScaleX: number;
  14111. /**
  14112. * Minimum scale of emitting particles on Y axis.
  14113. */
  14114. minScaleY: number;
  14115. /**
  14116. * Maximum scale of emitting particles on Y axis.
  14117. */
  14118. maxScaleY: number;
  14119. /**
  14120. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14121. */
  14122. color1: Color4;
  14123. /**
  14124. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14125. */
  14126. color2: Color4;
  14127. /**
  14128. * Color the particle will have at the end of its lifetime.
  14129. */
  14130. colorDead: Color4;
  14131. /**
  14132. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14133. */
  14134. emitRate: number;
  14135. /**
  14136. * You can use gravity if you want to give an orientation to your particles.
  14137. */
  14138. gravity: Vector3;
  14139. /**
  14140. * Minimum power of emitting particles.
  14141. */
  14142. minEmitPower: number;
  14143. /**
  14144. * Maximum power of emitting particles.
  14145. */
  14146. maxEmitPower: number;
  14147. /**
  14148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14149. */
  14150. minAngularSpeed: number;
  14151. /**
  14152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14153. */
  14154. maxAngularSpeed: number;
  14155. /**
  14156. * Gets or sets the minimal initial rotation in radians.
  14157. */
  14158. minInitialRotation: number;
  14159. /**
  14160. * Gets or sets the maximal initial rotation in radians.
  14161. */
  14162. maxInitialRotation: number;
  14163. /**
  14164. * The particle emitter type defines the emitter used by the particle system.
  14165. * It can be for example box, sphere, or cone...
  14166. */
  14167. particleEmitterType: Nullable<IParticleEmitterType>;
  14168. /**
  14169. * Defines the delay in milliseconds before starting the system (0 by default)
  14170. */
  14171. startDelay: number;
  14172. /**
  14173. * 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
  14174. */
  14175. preWarmCycles: number;
  14176. /**
  14177. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14178. */
  14179. preWarmStepOffset: number;
  14180. /**
  14181. * 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)
  14182. */
  14183. spriteCellChangeSpeed: number;
  14184. /**
  14185. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14186. */
  14187. startSpriteCellID: number;
  14188. /**
  14189. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14190. */
  14191. endSpriteCellID: number;
  14192. /**
  14193. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14194. */
  14195. spriteCellWidth: number;
  14196. /**
  14197. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14198. */
  14199. spriteCellHeight: number;
  14200. /**
  14201. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14202. */
  14203. spriteRandomStartCell: boolean;
  14204. /**
  14205. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14206. */
  14207. isAnimationSheetEnabled: boolean;
  14208. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14209. translationPivot: Vector2;
  14210. /**
  14211. * Gets or sets a texture used to add random noise to particle positions
  14212. */
  14213. noiseTexture: Nullable<BaseTexture>;
  14214. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14215. noiseStrength: Vector3;
  14216. /**
  14217. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14218. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14219. */
  14220. billboardMode: number;
  14221. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14222. limitVelocityDamping: number;
  14223. /**
  14224. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14225. */
  14226. beginAnimationOnStart: boolean;
  14227. /**
  14228. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14229. */
  14230. beginAnimationFrom: number;
  14231. /**
  14232. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14233. */
  14234. beginAnimationTo: number;
  14235. /**
  14236. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14237. */
  14238. beginAnimationLoop: boolean;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Specifies if the particles are updated in emitter local space or world space
  14245. */
  14246. isLocal: boolean;
  14247. /** Snippet ID if the particle system was created from the snippet server */
  14248. snippetId: string;
  14249. /** Gets or sets a matrix to use to compute projection */
  14250. defaultProjectionMatrix: Matrix;
  14251. /**
  14252. * Gets the maximum number of particles active at the same time.
  14253. * @returns The max number of active particles.
  14254. */
  14255. getCapacity(): number;
  14256. /**
  14257. * Gets the number of particles active at the same time.
  14258. * @returns The number of active particles.
  14259. */
  14260. getActiveCount(): number;
  14261. /**
  14262. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14263. * @returns True if it has been started, otherwise false.
  14264. */
  14265. isStarted(): boolean;
  14266. /**
  14267. * Animates the particle system for this frame.
  14268. */
  14269. animate(): void;
  14270. /**
  14271. * Renders the particle system in its current state.
  14272. * @returns the current number of particles
  14273. */
  14274. render(): number;
  14275. /**
  14276. * Dispose the particle system and frees its associated resources.
  14277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14278. */
  14279. dispose(disposeTexture?: boolean): void;
  14280. /**
  14281. * An event triggered when the system is disposed
  14282. */
  14283. onDisposeObservable: Observable<IParticleSystem>;
  14284. /**
  14285. * Clones the particle system.
  14286. * @param name The name of the cloned object
  14287. * @param newEmitter The new emitter to use
  14288. * @returns the cloned particle system
  14289. */
  14290. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14291. /**
  14292. * Serializes the particle system to a JSON object
  14293. * @param serializeTexture defines if the texture must be serialized as well
  14294. * @returns the JSON object
  14295. */
  14296. serialize(serializeTexture: boolean): any;
  14297. /**
  14298. * Rebuild the particle system
  14299. */
  14300. rebuild(): void;
  14301. /** Force the system to rebuild all gradients that need to be resync */
  14302. forceRefreshGradients(): void;
  14303. /**
  14304. * Starts the particle system and begins to emit
  14305. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14306. */
  14307. start(delay?: number): void;
  14308. /**
  14309. * Stops the particle system.
  14310. */
  14311. stop(): void;
  14312. /**
  14313. * Remove all active particles
  14314. */
  14315. reset(): void;
  14316. /**
  14317. * Gets a boolean indicating that the system is stopping
  14318. * @returns true if the system is currently stopping
  14319. */
  14320. isStopping(): boolean;
  14321. /**
  14322. * Is this system ready to be used/rendered
  14323. * @return true if the system is ready
  14324. */
  14325. isReady(): boolean;
  14326. /**
  14327. * Returns the string "ParticleSystem"
  14328. * @returns a string containing the class name
  14329. */
  14330. getClassName(): string;
  14331. /**
  14332. * Gets the custom effect used to render the particles
  14333. * @param blendMode Blend mode for which the effect should be retrieved
  14334. * @returns The effect
  14335. */
  14336. getCustomEffect(blendMode: number): Nullable<Effect>;
  14337. /**
  14338. * Sets the custom effect used to render the particles
  14339. * @param effect The effect to set
  14340. * @param blendMode Blend mode for which the effect should be set
  14341. */
  14342. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14343. /**
  14344. * Fill the defines array according to the current settings of the particle system
  14345. * @param defines Array to be updated
  14346. * @param blendMode blend mode to take into account when updating the array
  14347. */
  14348. fillDefines(defines: Array<string>, blendMode: number): void;
  14349. /**
  14350. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14351. * @param uniforms Uniforms array to fill
  14352. * @param attributes Attributes array to fill
  14353. * @param samplers Samplers array to fill
  14354. */
  14355. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14356. /**
  14357. * Observable that will be called just before the particles are drawn
  14358. */
  14359. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14360. /**
  14361. * Gets the name of the particle vertex shader
  14362. */
  14363. vertexShaderName: string;
  14364. /**
  14365. * Adds a new color gradient
  14366. * @param gradient defines the gradient to use (between 0 and 1)
  14367. * @param color1 defines the color to affect to the specified gradient
  14368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14369. * @returns the current particle system
  14370. */
  14371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14372. /**
  14373. * Remove a specific color gradient
  14374. * @param gradient defines the gradient to remove
  14375. * @returns the current particle system
  14376. */
  14377. removeColorGradient(gradient: number): IParticleSystem;
  14378. /**
  14379. * Adds a new size gradient
  14380. * @param gradient defines the gradient to use (between 0 and 1)
  14381. * @param factor defines the size factor to affect to the specified gradient
  14382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14383. * @returns the current particle system
  14384. */
  14385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14386. /**
  14387. * Remove a specific size gradient
  14388. * @param gradient defines the gradient to remove
  14389. * @returns the current particle system
  14390. */
  14391. removeSizeGradient(gradient: number): IParticleSystem;
  14392. /**
  14393. * Gets the current list of color gradients.
  14394. * You must use addColorGradient and removeColorGradient to udpate this list
  14395. * @returns the list of color gradients
  14396. */
  14397. getColorGradients(): Nullable<Array<ColorGradient>>;
  14398. /**
  14399. * Gets the current list of size gradients.
  14400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14401. * @returns the list of size gradients
  14402. */
  14403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Gets the current list of angular speed gradients.
  14406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14407. * @returns the list of angular speed gradients
  14408. */
  14409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14410. /**
  14411. * Adds a new angular speed gradient
  14412. * @param gradient defines the gradient to use (between 0 and 1)
  14413. * @param factor defines the angular speed to affect to the specified gradient
  14414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14415. * @returns the current particle system
  14416. */
  14417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14418. /**
  14419. * Remove a specific angular speed gradient
  14420. * @param gradient defines the gradient to remove
  14421. * @returns the current particle system
  14422. */
  14423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of velocity gradients.
  14426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14427. * @returns the list of velocity gradients
  14428. */
  14429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new velocity gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param factor defines the velocity to affect to the specified gradient
  14434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14435. * @returns the current particle system
  14436. */
  14437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14438. /**
  14439. * Remove a specific velocity gradient
  14440. * @param gradient defines the gradient to remove
  14441. * @returns the current particle system
  14442. */
  14443. removeVelocityGradient(gradient: number): IParticleSystem;
  14444. /**
  14445. * Gets the current list of limit velocity gradients.
  14446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14447. * @returns the list of limit velocity gradients
  14448. */
  14449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14450. /**
  14451. * Adds a new limit velocity gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the limit velocity to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific limit velocity gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Adds a new drag gradient
  14466. * @param gradient defines the gradient to use (between 0 and 1)
  14467. * @param factor defines the drag to affect to the specified gradient
  14468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14469. * @returns the current particle system
  14470. */
  14471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14472. /**
  14473. * Remove a specific drag gradient
  14474. * @param gradient defines the gradient to remove
  14475. * @returns the current particle system
  14476. */
  14477. removeDragGradient(gradient: number): IParticleSystem;
  14478. /**
  14479. * Gets the current list of drag gradients.
  14480. * You must use addDragGradient and removeDragGradient to udpate this list
  14481. * @returns the list of drag gradients
  14482. */
  14483. getDragGradients(): Nullable<Array<FactorGradient>>;
  14484. /**
  14485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14486. * @param gradient defines the gradient to use (between 0 and 1)
  14487. * @param factor defines the emit rate to affect to the specified gradient
  14488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14489. * @returns the current particle system
  14490. */
  14491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14492. /**
  14493. * Remove a specific emit rate gradient
  14494. * @param gradient defines the gradient to remove
  14495. * @returns the current particle system
  14496. */
  14497. removeEmitRateGradient(gradient: number): IParticleSystem;
  14498. /**
  14499. * Gets the current list of emit rate gradients.
  14500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14501. * @returns the list of emit rate gradients
  14502. */
  14503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param factor defines the start size to affect to the specified gradient
  14508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14509. * @returns the current particle system
  14510. */
  14511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14512. /**
  14513. * Remove a specific start size gradient
  14514. * @param gradient defines the gradient to remove
  14515. * @returns the current particle system
  14516. */
  14517. removeStartSizeGradient(gradient: number): IParticleSystem;
  14518. /**
  14519. * Gets the current list of start size gradients.
  14520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14521. * @returns the list of start size gradients
  14522. */
  14523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14524. /**
  14525. * Adds a new life time gradient
  14526. * @param gradient defines the gradient to use (between 0 and 1)
  14527. * @param factor defines the life time factor to affect to the specified gradient
  14528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14529. * @returns the current particle system
  14530. */
  14531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14532. /**
  14533. * Remove a specific life time gradient
  14534. * @param gradient defines the gradient to remove
  14535. * @returns the current particle system
  14536. */
  14537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14538. /**
  14539. * Gets the current list of life time gradients.
  14540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14541. * @returns the list of life time gradients
  14542. */
  14543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Gets the current list of color gradients.
  14546. * You must use addColorGradient and removeColorGradient to udpate this list
  14547. * @returns the list of color gradients
  14548. */
  14549. getColorGradients(): Nullable<Array<ColorGradient>>;
  14550. /**
  14551. * Adds a new ramp gradient used to remap particle colors
  14552. * @param gradient defines the gradient to use (between 0 and 1)
  14553. * @param color defines the color to affect to the specified gradient
  14554. * @returns the current particle system
  14555. */
  14556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14557. /**
  14558. * Gets the current list of ramp gradients.
  14559. * You must use addRampGradient and removeRampGradient to udpate this list
  14560. * @returns the list of ramp gradients
  14561. */
  14562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14563. /** Gets or sets a boolean indicating that ramp gradients must be used
  14564. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14565. */
  14566. useRampGradients: boolean;
  14567. /**
  14568. * Adds a new color remap gradient
  14569. * @param gradient defines the gradient to use (between 0 and 1)
  14570. * @param min defines the color remap minimal range
  14571. * @param max defines the color remap maximal range
  14572. * @returns the current particle system
  14573. */
  14574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14575. /**
  14576. * Gets the current list of color remap gradients.
  14577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14578. * @returns the list of color remap gradients
  14579. */
  14580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14581. /**
  14582. * Adds a new alpha remap gradient
  14583. * @param gradient defines the gradient to use (between 0 and 1)
  14584. * @param min defines the alpha remap minimal range
  14585. * @param max defines the alpha remap maximal range
  14586. * @returns the current particle system
  14587. */
  14588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14589. /**
  14590. * Gets the current list of alpha remap gradients.
  14591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14592. * @returns the list of alpha remap gradients
  14593. */
  14594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14595. /**
  14596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14599. * @returns the emitter
  14600. */
  14601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14602. /**
  14603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14604. * @param radius The radius of the hemisphere to emit from
  14605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14606. * @returns the emitter
  14607. */
  14608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14609. /**
  14610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14611. * @param radius The radius of the sphere to emit from
  14612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14613. * @returns the emitter
  14614. */
  14615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14616. /**
  14617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14618. * @param radius The radius of the sphere to emit from
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14621. * @returns the emitter
  14622. */
  14623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14626. * @param radius The radius of the emission cylinder
  14627. * @param height The height of the emission cylinder
  14628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14630. * @returns the emitter
  14631. */
  14632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14633. /**
  14634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14635. * @param radius The radius of the cylinder to emit from
  14636. * @param height The height of the emission cylinder
  14637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14640. * @returns the emitter
  14641. */
  14642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14643. /**
  14644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14645. * @param radius The radius of the cone to emit from
  14646. * @param angle The base angle of the cone
  14647. * @returns the emitter
  14648. */
  14649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14650. /**
  14651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14656. * @returns the emitter
  14657. */
  14658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14659. /**
  14660. * Get hosting scene
  14661. * @returns the scene
  14662. */
  14663. getScene(): Nullable<Scene>;
  14664. }
  14665. }
  14666. declare module BABYLON {
  14667. /**
  14668. * 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.
  14669. * @see https://doc.babylonjs.com/how_to/transformnode
  14670. */
  14671. export class TransformNode extends Node {
  14672. /**
  14673. * Object will not rotate to face the camera
  14674. */
  14675. static BILLBOARDMODE_NONE: number;
  14676. /**
  14677. * Object will rotate to face the camera but only on the x axis
  14678. */
  14679. static BILLBOARDMODE_X: number;
  14680. /**
  14681. * Object will rotate to face the camera but only on the y axis
  14682. */
  14683. static BILLBOARDMODE_Y: number;
  14684. /**
  14685. * Object will rotate to face the camera but only on the z axis
  14686. */
  14687. static BILLBOARDMODE_Z: number;
  14688. /**
  14689. * Object will rotate to face the camera
  14690. */
  14691. static BILLBOARDMODE_ALL: number;
  14692. /**
  14693. * Object will rotate to face the camera's position instead of orientation
  14694. */
  14695. static BILLBOARDMODE_USE_POSITION: number;
  14696. private static _TmpRotation;
  14697. private static _TmpScaling;
  14698. private static _TmpTranslation;
  14699. private _forward;
  14700. private _forwardInverted;
  14701. private _up;
  14702. private _right;
  14703. private _rightInverted;
  14704. private _position;
  14705. private _rotation;
  14706. private _rotationQuaternion;
  14707. protected _scaling: Vector3;
  14708. protected _isDirty: boolean;
  14709. private _transformToBoneReferal;
  14710. private _isAbsoluteSynced;
  14711. private _billboardMode;
  14712. /**
  14713. * Gets or sets the billboard mode. Default is 0.
  14714. *
  14715. * | Value | Type | Description |
  14716. * | --- | --- | --- |
  14717. * | 0 | BILLBOARDMODE_NONE | |
  14718. * | 1 | BILLBOARDMODE_X | |
  14719. * | 2 | BILLBOARDMODE_Y | |
  14720. * | 4 | BILLBOARDMODE_Z | |
  14721. * | 7 | BILLBOARDMODE_ALL | |
  14722. *
  14723. */
  14724. get billboardMode(): number;
  14725. set billboardMode(value: number);
  14726. private _preserveParentRotationForBillboard;
  14727. /**
  14728. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14729. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14730. */
  14731. get preserveParentRotationForBillboard(): boolean;
  14732. set preserveParentRotationForBillboard(value: boolean);
  14733. /**
  14734. * 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
  14735. */
  14736. scalingDeterminant: number;
  14737. private _infiniteDistance;
  14738. /**
  14739. * Gets or sets the distance of the object to max, often used by skybox
  14740. */
  14741. get infiniteDistance(): boolean;
  14742. set infiniteDistance(value: boolean);
  14743. /**
  14744. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14745. * By default the system will update normals to compensate
  14746. */
  14747. ignoreNonUniformScaling: boolean;
  14748. /**
  14749. * 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
  14750. */
  14751. reIntegrateRotationIntoRotationQuaternion: boolean;
  14752. /** @hidden */
  14753. _poseMatrix: Nullable<Matrix>;
  14754. /** @hidden */
  14755. _localMatrix: Matrix;
  14756. private _usePivotMatrix;
  14757. private _absolutePosition;
  14758. private _absoluteScaling;
  14759. private _absoluteRotationQuaternion;
  14760. private _pivotMatrix;
  14761. private _pivotMatrixInverse;
  14762. /** @hidden */
  14763. _postMultiplyPivotMatrix: boolean;
  14764. protected _isWorldMatrixFrozen: boolean;
  14765. /** @hidden */
  14766. _indexInSceneTransformNodesArray: number;
  14767. /**
  14768. * An event triggered after the world matrix is updated
  14769. */
  14770. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14771. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14772. /**
  14773. * Gets a string identifying the name of the class
  14774. * @returns "TransformNode" string
  14775. */
  14776. getClassName(): string;
  14777. /**
  14778. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14779. */
  14780. get position(): Vector3;
  14781. set position(newPosition: Vector3);
  14782. /**
  14783. * 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)).
  14784. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14785. */
  14786. get rotation(): Vector3;
  14787. set rotation(newRotation: Vector3);
  14788. /**
  14789. * 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)).
  14790. */
  14791. get scaling(): Vector3;
  14792. set scaling(newScaling: Vector3);
  14793. /**
  14794. * 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).
  14795. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14796. */
  14797. get rotationQuaternion(): Nullable<Quaternion>;
  14798. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14799. /**
  14800. * The forward direction of that transform in world space.
  14801. */
  14802. get forward(): Vector3;
  14803. /**
  14804. * The up direction of that transform in world space.
  14805. */
  14806. get up(): Vector3;
  14807. /**
  14808. * The right direction of that transform in world space.
  14809. */
  14810. get right(): Vector3;
  14811. /**
  14812. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14813. * @param matrix the matrix to copy the pose from
  14814. * @returns this TransformNode.
  14815. */
  14816. updatePoseMatrix(matrix: Matrix): TransformNode;
  14817. /**
  14818. * Returns the mesh Pose matrix.
  14819. * @returns the pose matrix
  14820. */
  14821. getPoseMatrix(): Matrix;
  14822. /** @hidden */
  14823. _isSynchronized(): boolean;
  14824. /** @hidden */
  14825. _initCache(): void;
  14826. /**
  14827. * Flag the transform node as dirty (Forcing it to update everything)
  14828. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14829. * @returns this transform node
  14830. */
  14831. markAsDirty(property: string): TransformNode;
  14832. /**
  14833. * Returns the current mesh absolute position.
  14834. * Returns a Vector3.
  14835. */
  14836. get absolutePosition(): Vector3;
  14837. /**
  14838. * Returns the current mesh absolute scaling.
  14839. * Returns a Vector3.
  14840. */
  14841. get absoluteScaling(): Vector3;
  14842. /**
  14843. * Returns the current mesh absolute rotation.
  14844. * Returns a Quaternion.
  14845. */
  14846. get absoluteRotationQuaternion(): Quaternion;
  14847. /**
  14848. * Sets a new matrix to apply before all other transformation
  14849. * @param matrix defines the transform matrix
  14850. * @returns the current TransformNode
  14851. */
  14852. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14853. /**
  14854. * Sets a new pivot matrix to the current node
  14855. * @param matrix defines the new pivot matrix to use
  14856. * @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
  14857. * @returns the current TransformNode
  14858. */
  14859. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14860. /**
  14861. * Returns the mesh pivot matrix.
  14862. * Default : Identity.
  14863. * @returns the matrix
  14864. */
  14865. getPivotMatrix(): Matrix;
  14866. /**
  14867. * Instantiate (when possible) or clone that node with its hierarchy
  14868. * @param newParent defines the new parent to use for the instance (or clone)
  14869. * @param options defines options to configure how copy is done
  14870. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14871. * @returns an instance (or a clone) of the current node with its hiearchy
  14872. */
  14873. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14874. doNotInstantiate: boolean;
  14875. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14876. /**
  14877. * Prevents the World matrix to be computed any longer
  14878. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14879. * @returns the TransformNode.
  14880. */
  14881. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14882. /**
  14883. * Allows back the World matrix computation.
  14884. * @returns the TransformNode.
  14885. */
  14886. unfreezeWorldMatrix(): this;
  14887. /**
  14888. * True if the World matrix has been frozen.
  14889. */
  14890. get isWorldMatrixFrozen(): boolean;
  14891. /**
  14892. * Retuns the mesh absolute position in the World.
  14893. * @returns a Vector3.
  14894. */
  14895. getAbsolutePosition(): Vector3;
  14896. /**
  14897. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14898. * @param absolutePosition the absolute position to set
  14899. * @returns the TransformNode.
  14900. */
  14901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14902. /**
  14903. * Sets the mesh position in its local space.
  14904. * @param vector3 the position to set in localspace
  14905. * @returns the TransformNode.
  14906. */
  14907. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14908. /**
  14909. * Returns the mesh position in the local space from the current World matrix values.
  14910. * @returns a new Vector3.
  14911. */
  14912. getPositionExpressedInLocalSpace(): Vector3;
  14913. /**
  14914. * Translates the mesh along the passed Vector3 in its local space.
  14915. * @param vector3 the distance to translate in localspace
  14916. * @returns the TransformNode.
  14917. */
  14918. locallyTranslate(vector3: Vector3): TransformNode;
  14919. private static _lookAtVectorCache;
  14920. /**
  14921. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14922. * @param targetPoint the position (must be in same space as current mesh) to look at
  14923. * @param yawCor optional yaw (y-axis) correction in radians
  14924. * @param pitchCor optional pitch (x-axis) correction in radians
  14925. * @param rollCor optional roll (z-axis) correction in radians
  14926. * @param space the choosen space of the target
  14927. * @returns the TransformNode.
  14928. */
  14929. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14930. /**
  14931. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14932. * This Vector3 is expressed in the World space.
  14933. * @param localAxis axis to rotate
  14934. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14935. */
  14936. getDirection(localAxis: Vector3): Vector3;
  14937. /**
  14938. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14939. * localAxis is expressed in the mesh local space.
  14940. * result is computed in the Wordl space from the mesh World matrix.
  14941. * @param localAxis axis to rotate
  14942. * @param result the resulting transformnode
  14943. * @returns this TransformNode.
  14944. */
  14945. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14946. /**
  14947. * Sets this transform node rotation to the given local axis.
  14948. * @param localAxis the axis in local space
  14949. * @param yawCor optional yaw (y-axis) correction in radians
  14950. * @param pitchCor optional pitch (x-axis) correction in radians
  14951. * @param rollCor optional roll (z-axis) correction in radians
  14952. * @returns this TransformNode
  14953. */
  14954. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14955. /**
  14956. * Sets a new pivot point to the current node
  14957. * @param point defines the new pivot point to use
  14958. * @param space defines if the point is in world or local space (local by default)
  14959. * @returns the current TransformNode
  14960. */
  14961. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14962. /**
  14963. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14964. * @returns the pivot point
  14965. */
  14966. getPivotPoint(): Vector3;
  14967. /**
  14968. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14969. * @param result the vector3 to store the result
  14970. * @returns this TransformNode.
  14971. */
  14972. getPivotPointToRef(result: Vector3): TransformNode;
  14973. /**
  14974. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14975. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14976. */
  14977. getAbsolutePivotPoint(): Vector3;
  14978. /**
  14979. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14980. * @param result vector3 to store the result
  14981. * @returns this TransformNode.
  14982. */
  14983. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14984. /**
  14985. * Defines the passed node as the parent of the current node.
  14986. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14987. * @see https://doc.babylonjs.com/how_to/parenting
  14988. * @param node the node ot set as the parent
  14989. * @returns this TransformNode.
  14990. */
  14991. setParent(node: Nullable<Node>): TransformNode;
  14992. private _nonUniformScaling;
  14993. /**
  14994. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14995. */
  14996. get nonUniformScaling(): boolean;
  14997. /** @hidden */
  14998. _updateNonUniformScalingState(value: boolean): boolean;
  14999. /**
  15000. * Attach the current TransformNode to another TransformNode associated with a bone
  15001. * @param bone Bone affecting the TransformNode
  15002. * @param affectedTransformNode TransformNode associated with the bone
  15003. * @returns this object
  15004. */
  15005. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15006. /**
  15007. * Detach the transform node if its associated with a bone
  15008. * @returns this object
  15009. */
  15010. detachFromBone(): TransformNode;
  15011. private static _rotationAxisCache;
  15012. /**
  15013. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15014. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15015. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15016. * The passed axis is also normalized.
  15017. * @param axis the axis to rotate around
  15018. * @param amount the amount to rotate in radians
  15019. * @param space Space to rotate in (Default: local)
  15020. * @returns the TransformNode.
  15021. */
  15022. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15023. /**
  15024. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15025. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15026. * The passed axis is also normalized. .
  15027. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15028. * @param point the point to rotate around
  15029. * @param axis the axis to rotate around
  15030. * @param amount the amount to rotate in radians
  15031. * @returns the TransformNode
  15032. */
  15033. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15034. /**
  15035. * Translates the mesh along the axis vector for the passed distance in the given space.
  15036. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15037. * @param axis the axis to translate in
  15038. * @param distance the distance to translate
  15039. * @param space Space to rotate in (Default: local)
  15040. * @returns the TransformNode.
  15041. */
  15042. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15043. /**
  15044. * Adds a rotation step to the mesh current rotation.
  15045. * x, y, z are Euler angles expressed in radians.
  15046. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15047. * This means this rotation is made in the mesh local space only.
  15048. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15049. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15050. * ```javascript
  15051. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15052. * ```
  15053. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15054. * 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.
  15055. * @param x Rotation to add
  15056. * @param y Rotation to add
  15057. * @param z Rotation to add
  15058. * @returns the TransformNode.
  15059. */
  15060. addRotation(x: number, y: number, z: number): TransformNode;
  15061. /**
  15062. * @hidden
  15063. */
  15064. protected _getEffectiveParent(): Nullable<Node>;
  15065. /**
  15066. * Computes the world matrix of the node
  15067. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15068. * @returns the world matrix
  15069. */
  15070. computeWorldMatrix(force?: boolean): Matrix;
  15071. /**
  15072. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15073. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15074. */
  15075. resetLocalMatrix(independentOfChildren?: boolean): void;
  15076. protected _afterComputeWorldMatrix(): void;
  15077. /**
  15078. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15079. * @param func callback function to add
  15080. *
  15081. * @returns the TransformNode.
  15082. */
  15083. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15084. /**
  15085. * Removes a registered callback function.
  15086. * @param func callback function to remove
  15087. * @returns the TransformNode.
  15088. */
  15089. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15090. /**
  15091. * Gets the position of the current mesh in camera space
  15092. * @param camera defines the camera to use
  15093. * @returns a position
  15094. */
  15095. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15096. /**
  15097. * Returns the distance from the mesh to the active camera
  15098. * @param camera defines the camera to use
  15099. * @returns the distance
  15100. */
  15101. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15102. /**
  15103. * Clone the current transform node
  15104. * @param name Name of the new clone
  15105. * @param newParent New parent for the clone
  15106. * @param doNotCloneChildren Do not clone children hierarchy
  15107. * @returns the new transform node
  15108. */
  15109. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15110. /**
  15111. * Serializes the objects information.
  15112. * @param currentSerializationObject defines the object to serialize in
  15113. * @returns the serialized object
  15114. */
  15115. serialize(currentSerializationObject?: any): any;
  15116. /**
  15117. * Returns a new TransformNode object parsed from the source provided.
  15118. * @param parsedTransformNode is the source.
  15119. * @param scene the scne the object belongs to
  15120. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15121. * @returns a new TransformNode object parsed from the source provided.
  15122. */
  15123. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15124. /**
  15125. * Get all child-transformNodes of this node
  15126. * @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
  15127. * @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
  15128. * @returns an array of TransformNode
  15129. */
  15130. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15131. /**
  15132. * Releases resources associated with this transform node.
  15133. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15134. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15135. */
  15136. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15137. /**
  15138. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15139. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15140. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15141. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15142. * @returns the current mesh
  15143. */
  15144. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15145. private _syncAbsoluteScalingAndRotation;
  15146. }
  15147. }
  15148. declare module BABYLON {
  15149. /**
  15150. * Class used to override all child animations of a given target
  15151. */
  15152. export class AnimationPropertiesOverride {
  15153. /**
  15154. * Gets or sets a value indicating if animation blending must be used
  15155. */
  15156. enableBlending: boolean;
  15157. /**
  15158. * Gets or sets the blending speed to use when enableBlending is true
  15159. */
  15160. blendingSpeed: number;
  15161. /**
  15162. * Gets or sets the default loop mode to use
  15163. */
  15164. loopMode: number;
  15165. }
  15166. }
  15167. declare module BABYLON {
  15168. /**
  15169. * Class used to store bone information
  15170. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15171. */
  15172. export class Bone extends Node {
  15173. /**
  15174. * defines the bone name
  15175. */
  15176. name: string;
  15177. private static _tmpVecs;
  15178. private static _tmpQuat;
  15179. private static _tmpMats;
  15180. /**
  15181. * Gets the list of child bones
  15182. */
  15183. children: Bone[];
  15184. /** Gets the animations associated with this bone */
  15185. animations: Animation[];
  15186. /**
  15187. * Gets or sets bone length
  15188. */
  15189. length: number;
  15190. /**
  15191. * @hidden Internal only
  15192. * Set this value to map this bone to a different index in the transform matrices
  15193. * Set this value to -1 to exclude the bone from the transform matrices
  15194. */
  15195. _index: Nullable<number>;
  15196. private _skeleton;
  15197. private _localMatrix;
  15198. private _restPose;
  15199. private _bindPose;
  15200. private _baseMatrix;
  15201. private _absoluteTransform;
  15202. private _invertedAbsoluteTransform;
  15203. private _parent;
  15204. private _scalingDeterminant;
  15205. private _worldTransform;
  15206. private _localScaling;
  15207. private _localRotation;
  15208. private _localPosition;
  15209. private _needToDecompose;
  15210. private _needToCompose;
  15211. /** @hidden */
  15212. _linkedTransformNode: Nullable<TransformNode>;
  15213. /** @hidden */
  15214. _waitingTransformNodeId: Nullable<string>;
  15215. /** @hidden */
  15216. get _matrix(): Matrix;
  15217. /** @hidden */
  15218. set _matrix(value: Matrix);
  15219. /**
  15220. * Create a new bone
  15221. * @param name defines the bone name
  15222. * @param skeleton defines the parent skeleton
  15223. * @param parentBone defines the parent (can be null if the bone is the root)
  15224. * @param localMatrix defines the local matrix
  15225. * @param restPose defines the rest pose matrix
  15226. * @param baseMatrix defines the base matrix
  15227. * @param index defines index of the bone in the hiearchy
  15228. */
  15229. constructor(
  15230. /**
  15231. * defines the bone name
  15232. */
  15233. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15234. /**
  15235. * Gets the current object class name.
  15236. * @return the class name
  15237. */
  15238. getClassName(): string;
  15239. /**
  15240. * Gets the parent skeleton
  15241. * @returns a skeleton
  15242. */
  15243. getSkeleton(): Skeleton;
  15244. /**
  15245. * Gets parent bone
  15246. * @returns a bone or null if the bone is the root of the bone hierarchy
  15247. */
  15248. getParent(): Nullable<Bone>;
  15249. /**
  15250. * Returns an array containing the root bones
  15251. * @returns an array containing the root bones
  15252. */
  15253. getChildren(): Array<Bone>;
  15254. /**
  15255. * Gets the node index in matrix array generated for rendering
  15256. * @returns the node index
  15257. */
  15258. getIndex(): number;
  15259. /**
  15260. * Sets the parent bone
  15261. * @param parent defines the parent (can be null if the bone is the root)
  15262. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15263. */
  15264. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15265. /**
  15266. * Gets the local matrix
  15267. * @returns a matrix
  15268. */
  15269. getLocalMatrix(): Matrix;
  15270. /**
  15271. * Gets the base matrix (initial matrix which remains unchanged)
  15272. * @returns a matrix
  15273. */
  15274. getBaseMatrix(): Matrix;
  15275. /**
  15276. * Gets the rest pose matrix
  15277. * @returns a matrix
  15278. */
  15279. getRestPose(): Matrix;
  15280. /**
  15281. * Sets the rest pose matrix
  15282. * @param matrix the local-space rest pose to set for this bone
  15283. */
  15284. setRestPose(matrix: Matrix): void;
  15285. /**
  15286. * Gets the bind pose matrix
  15287. * @returns the bind pose matrix
  15288. */
  15289. getBindPose(): Matrix;
  15290. /**
  15291. * Sets the bind pose matrix
  15292. * @param matrix the local-space bind pose to set for this bone
  15293. */
  15294. setBindPose(matrix: Matrix): void;
  15295. /**
  15296. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15297. */
  15298. getWorldMatrix(): Matrix;
  15299. /**
  15300. * Sets the local matrix to rest pose matrix
  15301. */
  15302. returnToRest(): void;
  15303. /**
  15304. * Gets the inverse of the absolute transform matrix.
  15305. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15306. * @returns a matrix
  15307. */
  15308. getInvertedAbsoluteTransform(): Matrix;
  15309. /**
  15310. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15311. * @returns a matrix
  15312. */
  15313. getAbsoluteTransform(): Matrix;
  15314. /**
  15315. * Links with the given transform node.
  15316. * The local matrix of this bone is copied from the transform node every frame.
  15317. * @param transformNode defines the transform node to link to
  15318. */
  15319. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15320. /**
  15321. * Gets the node used to drive the bone's transformation
  15322. * @returns a transform node or null
  15323. */
  15324. getTransformNode(): Nullable<TransformNode>;
  15325. /** Gets or sets current position (in local space) */
  15326. get position(): Vector3;
  15327. set position(newPosition: Vector3);
  15328. /** Gets or sets current rotation (in local space) */
  15329. get rotation(): Vector3;
  15330. set rotation(newRotation: Vector3);
  15331. /** Gets or sets current rotation quaternion (in local space) */
  15332. get rotationQuaternion(): Quaternion;
  15333. set rotationQuaternion(newRotation: Quaternion);
  15334. /** Gets or sets current scaling (in local space) */
  15335. get scaling(): Vector3;
  15336. set scaling(newScaling: Vector3);
  15337. /**
  15338. * Gets the animation properties override
  15339. */
  15340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15341. private _decompose;
  15342. private _compose;
  15343. /**
  15344. * Update the base and local matrices
  15345. * @param matrix defines the new base or local matrix
  15346. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15347. * @param updateLocalMatrix defines if the local matrix should be updated
  15348. */
  15349. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15350. /** @hidden */
  15351. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15352. /**
  15353. * Flag the bone as dirty (Forcing it to update everything)
  15354. */
  15355. markAsDirty(): void;
  15356. /** @hidden */
  15357. _markAsDirtyAndCompose(): void;
  15358. private _markAsDirtyAndDecompose;
  15359. /**
  15360. * Translate the bone in local or world space
  15361. * @param vec The amount to translate the bone
  15362. * @param space The space that the translation is in
  15363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15364. */
  15365. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15366. /**
  15367. * Set the postion of the bone in local or world space
  15368. * @param position The position to set the bone
  15369. * @param space The space that the position is in
  15370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15371. */
  15372. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15373. /**
  15374. * Set the absolute position of the bone (world space)
  15375. * @param position The position to set the bone
  15376. * @param mesh The mesh that this bone is attached to
  15377. */
  15378. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15379. /**
  15380. * Scale the bone on the x, y and z axes (in local space)
  15381. * @param x The amount to scale the bone on the x axis
  15382. * @param y The amount to scale the bone on the y axis
  15383. * @param z The amount to scale the bone on the z axis
  15384. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15385. */
  15386. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15387. /**
  15388. * Set the bone scaling in local space
  15389. * @param scale defines the scaling vector
  15390. */
  15391. setScale(scale: Vector3): void;
  15392. /**
  15393. * Gets the current scaling in local space
  15394. * @returns the current scaling vector
  15395. */
  15396. getScale(): Vector3;
  15397. /**
  15398. * Gets the current scaling in local space and stores it in a target vector
  15399. * @param result defines the target vector
  15400. */
  15401. getScaleToRef(result: Vector3): void;
  15402. /**
  15403. * Set the yaw, pitch, and roll of the bone in local or world space
  15404. * @param yaw The rotation of the bone on the y axis
  15405. * @param pitch The rotation of the bone on the x axis
  15406. * @param roll The rotation of the bone on the z axis
  15407. * @param space The space that the axes of rotation are in
  15408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15409. */
  15410. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15411. /**
  15412. * Add a rotation to the bone on an axis in local or world space
  15413. * @param axis The axis to rotate the bone on
  15414. * @param amount The amount to rotate the bone
  15415. * @param space The space that the axis is in
  15416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15417. */
  15418. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15419. /**
  15420. * Set the rotation of the bone to a particular axis angle in local or world space
  15421. * @param axis The axis to rotate the bone on
  15422. * @param angle The angle that the bone should be rotated to
  15423. * @param space The space that the axis is in
  15424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15425. */
  15426. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15427. /**
  15428. * Set the euler rotation of the bone in local or world space
  15429. * @param rotation The euler rotation that the bone should be set to
  15430. * @param space The space that the rotation is in
  15431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15432. */
  15433. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15434. /**
  15435. * Set the quaternion rotation of the bone in local or world space
  15436. * @param quat The quaternion rotation that the bone should be set to
  15437. * @param space The space that the rotation is in
  15438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15439. */
  15440. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15441. /**
  15442. * Set the rotation matrix of the bone in local or world space
  15443. * @param rotMat The rotation matrix that the bone should be set to
  15444. * @param space The space that the rotation is in
  15445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15446. */
  15447. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15448. private _rotateWithMatrix;
  15449. private _getNegativeRotationToRef;
  15450. /**
  15451. * Get the position of the bone in local or world space
  15452. * @param space The space that the returned position is in
  15453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15454. * @returns The position of the bone
  15455. */
  15456. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15457. /**
  15458. * Copy the position of the bone to a vector3 in local or world space
  15459. * @param space The space that the returned position is in
  15460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15461. * @param result The vector3 to copy the position to
  15462. */
  15463. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15464. /**
  15465. * Get the absolute position of the bone (world space)
  15466. * @param mesh The mesh that this bone is attached to
  15467. * @returns The absolute position of the bone
  15468. */
  15469. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15470. /**
  15471. * Copy the absolute position of the bone (world space) to the result param
  15472. * @param mesh The mesh that this bone is attached to
  15473. * @param result The vector3 to copy the absolute position to
  15474. */
  15475. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15476. /**
  15477. * Compute the absolute transforms of this bone and its children
  15478. */
  15479. computeAbsoluteTransforms(): void;
  15480. /**
  15481. * Get the world direction from an axis that is in the local space of the bone
  15482. * @param localAxis The local direction that is used to compute the world direction
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @returns The world direction
  15485. */
  15486. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15487. /**
  15488. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15489. * @param localAxis The local direction that is used to compute the world direction
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @param result The vector3 that the world direction will be copied to
  15492. */
  15493. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15494. /**
  15495. * Get the euler rotation of the bone in local or world space
  15496. * @param space The space that the rotation should be in
  15497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15498. * @returns The euler rotation
  15499. */
  15500. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15501. /**
  15502. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15503. * @param space The space that the rotation should be in
  15504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15505. * @param result The vector3 that the rotation should be copied to
  15506. */
  15507. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15508. /**
  15509. * Get the quaternion rotation of the bone in either local or world space
  15510. * @param space The space that the rotation should be in
  15511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15512. * @returns The quaternion rotation
  15513. */
  15514. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15515. /**
  15516. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15517. * @param space The space that the rotation should be in
  15518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15519. * @param result The quaternion that the rotation should be copied to
  15520. */
  15521. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15522. /**
  15523. * Get the rotation matrix of the bone in local or world space
  15524. * @param space The space that the rotation should be in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The rotation matrix
  15527. */
  15528. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15529. /**
  15530. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15531. * @param space The space that the rotation should be in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The quaternion that the rotation should be copied to
  15534. */
  15535. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15536. /**
  15537. * Get the world position of a point that is in the local space of the bone
  15538. * @param position The local position
  15539. * @param mesh The mesh that this bone is attached to
  15540. * @returns The world position
  15541. */
  15542. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15543. /**
  15544. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15545. * @param position The local position
  15546. * @param mesh The mesh that this bone is attached to
  15547. * @param result The vector3 that the world position should be copied to
  15548. */
  15549. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15550. /**
  15551. * Get the local position of a point that is in world space
  15552. * @param position The world position
  15553. * @param mesh The mesh that this bone is attached to
  15554. * @returns The local position
  15555. */
  15556. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15557. /**
  15558. * Get the local position of a point that is in world space and copy it to the result param
  15559. * @param position The world position
  15560. * @param mesh The mesh that this bone is attached to
  15561. * @param result The vector3 that the local position should be copied to
  15562. */
  15563. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15564. /**
  15565. * Set the current local matrix as the restPose for this bone.
  15566. */
  15567. setCurrentPoseAsRest(): void;
  15568. }
  15569. }
  15570. declare module BABYLON {
  15571. /**
  15572. * Defines a runtime animation
  15573. */
  15574. export class RuntimeAnimation {
  15575. private _events;
  15576. /**
  15577. * The current frame of the runtime animation
  15578. */
  15579. private _currentFrame;
  15580. /**
  15581. * The animation used by the runtime animation
  15582. */
  15583. private _animation;
  15584. /**
  15585. * The target of the runtime animation
  15586. */
  15587. private _target;
  15588. /**
  15589. * The initiating animatable
  15590. */
  15591. private _host;
  15592. /**
  15593. * The original value of the runtime animation
  15594. */
  15595. private _originalValue;
  15596. /**
  15597. * The original blend value of the runtime animation
  15598. */
  15599. private _originalBlendValue;
  15600. /**
  15601. * The offsets cache of the runtime animation
  15602. */
  15603. private _offsetsCache;
  15604. /**
  15605. * The high limits cache of the runtime animation
  15606. */
  15607. private _highLimitsCache;
  15608. /**
  15609. * Specifies if the runtime animation has been stopped
  15610. */
  15611. private _stopped;
  15612. /**
  15613. * The blending factor of the runtime animation
  15614. */
  15615. private _blendingFactor;
  15616. /**
  15617. * The BabylonJS scene
  15618. */
  15619. private _scene;
  15620. /**
  15621. * The current value of the runtime animation
  15622. */
  15623. private _currentValue;
  15624. /** @hidden */
  15625. _animationState: _IAnimationState;
  15626. /**
  15627. * The active target of the runtime animation
  15628. */
  15629. private _activeTargets;
  15630. private _currentActiveTarget;
  15631. private _directTarget;
  15632. /**
  15633. * The target path of the runtime animation
  15634. */
  15635. private _targetPath;
  15636. /**
  15637. * The weight of the runtime animation
  15638. */
  15639. private _weight;
  15640. /**
  15641. * The ratio offset of the runtime animation
  15642. */
  15643. private _ratioOffset;
  15644. /**
  15645. * The previous delay of the runtime animation
  15646. */
  15647. private _previousDelay;
  15648. /**
  15649. * The previous ratio of the runtime animation
  15650. */
  15651. private _previousRatio;
  15652. private _enableBlending;
  15653. private _keys;
  15654. private _minFrame;
  15655. private _maxFrame;
  15656. private _minValue;
  15657. private _maxValue;
  15658. private _targetIsArray;
  15659. /**
  15660. * Gets the current frame of the runtime animation
  15661. */
  15662. get currentFrame(): number;
  15663. /**
  15664. * Gets the weight of the runtime animation
  15665. */
  15666. get weight(): number;
  15667. /**
  15668. * Gets the current value of the runtime animation
  15669. */
  15670. get currentValue(): any;
  15671. /**
  15672. * Gets the target path of the runtime animation
  15673. */
  15674. get targetPath(): string;
  15675. /**
  15676. * Gets the actual target of the runtime animation
  15677. */
  15678. get target(): any;
  15679. /**
  15680. * Gets the additive state of the runtime animation
  15681. */
  15682. get isAdditive(): boolean;
  15683. /** @hidden */
  15684. _onLoop: () => void;
  15685. /**
  15686. * Create a new RuntimeAnimation object
  15687. * @param target defines the target of the animation
  15688. * @param animation defines the source animation object
  15689. * @param scene defines the hosting scene
  15690. * @param host defines the initiating Animatable
  15691. */
  15692. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15693. private _preparePath;
  15694. /**
  15695. * Gets the animation from the runtime animation
  15696. */
  15697. get animation(): Animation;
  15698. /**
  15699. * Resets the runtime animation to the beginning
  15700. * @param restoreOriginal defines whether to restore the target property to the original value
  15701. */
  15702. reset(restoreOriginal?: boolean): void;
  15703. /**
  15704. * Specifies if the runtime animation is stopped
  15705. * @returns Boolean specifying if the runtime animation is stopped
  15706. */
  15707. isStopped(): boolean;
  15708. /**
  15709. * Disposes of the runtime animation
  15710. */
  15711. dispose(): void;
  15712. /**
  15713. * Apply the interpolated value to the target
  15714. * @param currentValue defines the value computed by the animation
  15715. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15716. */
  15717. setValue(currentValue: any, weight: number): void;
  15718. private _getOriginalValues;
  15719. private _setValue;
  15720. /**
  15721. * Gets the loop pmode of the runtime animation
  15722. * @returns Loop Mode
  15723. */
  15724. private _getCorrectLoopMode;
  15725. /**
  15726. * Move the current animation to a given frame
  15727. * @param frame defines the frame to move to
  15728. */
  15729. goToFrame(frame: number): void;
  15730. /**
  15731. * @hidden Internal use only
  15732. */
  15733. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15734. /**
  15735. * Execute the current animation
  15736. * @param delay defines the delay to add to the current frame
  15737. * @param from defines the lower bound of the animation range
  15738. * @param to defines the upper bound of the animation range
  15739. * @param loop defines if the current animation must loop
  15740. * @param speedRatio defines the current speed ratio
  15741. * @param weight defines the weight of the animation (default is -1 so no weight)
  15742. * @param onLoop optional callback called when animation loops
  15743. * @returns a boolean indicating if the animation is running
  15744. */
  15745. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15746. }
  15747. }
  15748. declare module BABYLON {
  15749. /**
  15750. * Class used to store an actual running animation
  15751. */
  15752. export class Animatable {
  15753. /** defines the target object */
  15754. target: any;
  15755. /** defines the starting frame number (default is 0) */
  15756. fromFrame: number;
  15757. /** defines the ending frame number (default is 100) */
  15758. toFrame: number;
  15759. /** defines if the animation must loop (default is false) */
  15760. loopAnimation: boolean;
  15761. /** defines a callback to call when animation ends if it is not looping */
  15762. onAnimationEnd?: (() => void) | null | undefined;
  15763. /** defines a callback to call when animation loops */
  15764. onAnimationLoop?: (() => void) | null | undefined;
  15765. /** defines whether the animation should be evaluated additively */
  15766. isAdditive: boolean;
  15767. private _localDelayOffset;
  15768. private _pausedDelay;
  15769. private _runtimeAnimations;
  15770. private _paused;
  15771. private _scene;
  15772. private _speedRatio;
  15773. private _weight;
  15774. private _syncRoot;
  15775. /**
  15776. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15777. * This will only apply for non looping animation (default is true)
  15778. */
  15779. disposeOnEnd: boolean;
  15780. /**
  15781. * Gets a boolean indicating if the animation has started
  15782. */
  15783. animationStarted: boolean;
  15784. /**
  15785. * Observer raised when the animation ends
  15786. */
  15787. onAnimationEndObservable: Observable<Animatable>;
  15788. /**
  15789. * Observer raised when the animation loops
  15790. */
  15791. onAnimationLoopObservable: Observable<Animatable>;
  15792. /**
  15793. * Gets the root Animatable used to synchronize and normalize animations
  15794. */
  15795. get syncRoot(): Nullable<Animatable>;
  15796. /**
  15797. * Gets the current frame of the first RuntimeAnimation
  15798. * Used to synchronize Animatables
  15799. */
  15800. get masterFrame(): number;
  15801. /**
  15802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15803. */
  15804. get weight(): number;
  15805. set weight(value: number);
  15806. /**
  15807. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15808. */
  15809. get speedRatio(): number;
  15810. set speedRatio(value: number);
  15811. /**
  15812. * Creates a new Animatable
  15813. * @param scene defines the hosting scene
  15814. * @param target defines the target object
  15815. * @param fromFrame defines the starting frame number (default is 0)
  15816. * @param toFrame defines the ending frame number (default is 100)
  15817. * @param loopAnimation defines if the animation must loop (default is false)
  15818. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15819. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15820. * @param animations defines a group of animation to add to the new Animatable
  15821. * @param onAnimationLoop defines a callback to call when animation loops
  15822. * @param isAdditive defines whether the animation should be evaluated additively
  15823. */
  15824. constructor(scene: Scene,
  15825. /** defines the target object */
  15826. target: any,
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame?: number,
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame?: number,
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation?: boolean, speedRatio?: number,
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined,
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive?: boolean);
  15839. /**
  15840. * Synchronize and normalize current Animatable with a source Animatable
  15841. * This is useful when using animation weights and when animations are not of the same length
  15842. * @param root defines the root Animatable to synchronize with
  15843. * @returns the current Animatable
  15844. */
  15845. syncWith(root: Animatable): Animatable;
  15846. /**
  15847. * Gets the list of runtime animations
  15848. * @returns an array of RuntimeAnimation
  15849. */
  15850. getAnimations(): RuntimeAnimation[];
  15851. /**
  15852. * Adds more animations to the current animatable
  15853. * @param target defines the target of the animations
  15854. * @param animations defines the new animations to add
  15855. */
  15856. appendAnimations(target: any, animations: Animation[]): void;
  15857. /**
  15858. * Gets the source animation for a specific property
  15859. * @param property defines the propertyu to look for
  15860. * @returns null or the source animation for the given property
  15861. */
  15862. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15863. /**
  15864. * Gets the runtime animation for a specific property
  15865. * @param property defines the propertyu to look for
  15866. * @returns null or the runtime animation for the given property
  15867. */
  15868. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15869. /**
  15870. * Resets the animatable to its original state
  15871. */
  15872. reset(): void;
  15873. /**
  15874. * Allows the animatable to blend with current running animations
  15875. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15876. * @param blendingSpeed defines the blending speed to use
  15877. */
  15878. enableBlending(blendingSpeed: number): void;
  15879. /**
  15880. * Disable animation blending
  15881. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15882. */
  15883. disableBlending(): void;
  15884. /**
  15885. * Jump directly to a given frame
  15886. * @param frame defines the frame to jump to
  15887. */
  15888. goToFrame(frame: number): void;
  15889. /**
  15890. * Pause the animation
  15891. */
  15892. pause(): void;
  15893. /**
  15894. * Restart the animation
  15895. */
  15896. restart(): void;
  15897. private _raiseOnAnimationEnd;
  15898. /**
  15899. * Stop and delete the current animation
  15900. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15901. * @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)
  15902. */
  15903. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15904. /**
  15905. * Wait asynchronously for the animation to end
  15906. * @returns a promise which will be fullfilled when the animation ends
  15907. */
  15908. waitAsync(): Promise<Animatable>;
  15909. /** @hidden */
  15910. _animate(delay: number): boolean;
  15911. }
  15912. interface Scene {
  15913. /** @hidden */
  15914. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15915. /** @hidden */
  15916. _processLateAnimationBindingsForMatrices(holder: {
  15917. totalWeight: number;
  15918. totalAdditiveWeight: number;
  15919. animations: RuntimeAnimation[];
  15920. additiveAnimations: RuntimeAnimation[];
  15921. originalValue: Matrix;
  15922. }): any;
  15923. /** @hidden */
  15924. _processLateAnimationBindingsForQuaternions(holder: {
  15925. totalWeight: number;
  15926. totalAdditiveWeight: number;
  15927. animations: RuntimeAnimation[];
  15928. additiveAnimations: RuntimeAnimation[];
  15929. originalValue: Quaternion;
  15930. }, refQuaternion: Quaternion): Quaternion;
  15931. /** @hidden */
  15932. _processLateAnimationBindings(): void;
  15933. /**
  15934. * Will start the animation sequence of a given target
  15935. * @param target defines the target
  15936. * @param from defines from which frame should animation start
  15937. * @param to defines until which frame should animation run.
  15938. * @param weight defines the weight to apply to the animation (1.0 by default)
  15939. * @param loop defines if the animation loops
  15940. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15941. * @param onAnimationEnd defines the function to be executed when the animation ends
  15942. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15943. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15944. * @param onAnimationLoop defines the callback to call when an animation loops
  15945. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15946. * @returns the animatable object created for this animation
  15947. */
  15948. 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;
  15949. /**
  15950. * Will start the animation sequence of a given target
  15951. * @param target defines the target
  15952. * @param from defines from which frame should animation start
  15953. * @param to defines until which frame should animation run.
  15954. * @param loop defines if the animation loops
  15955. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15956. * @param onAnimationEnd defines the function to be executed when the animation ends
  15957. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15958. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15959. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15960. * @param onAnimationLoop defines the callback to call when an animation loops
  15961. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15962. * @returns the animatable object created for this animation
  15963. */
  15964. 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;
  15965. /**
  15966. * Will start the animation sequence of a given target and its hierarchy
  15967. * @param target defines the target
  15968. * @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.
  15969. * @param from defines from which frame should animation start
  15970. * @param to defines until which frame should animation run.
  15971. * @param loop defines if the animation loops
  15972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15973. * @param onAnimationEnd defines the function to be executed when the animation ends
  15974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15975. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15976. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15977. * @param onAnimationLoop defines the callback to call when an animation loops
  15978. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15979. * @returns the list of created animatables
  15980. */
  15981. 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[];
  15982. /**
  15983. * Begin a new animation on a given node
  15984. * @param target defines the target where the animation will take place
  15985. * @param animations defines the list of animations to start
  15986. * @param from defines the initial value
  15987. * @param to defines the final value
  15988. * @param loop defines if you want animation to loop (off by default)
  15989. * @param speedRatio defines the speed ratio to apply to all animations
  15990. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15991. * @param onAnimationLoop defines the callback to call when an animation loops
  15992. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15993. * @returns the list of created animatables
  15994. */
  15995. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15996. /**
  15997. * Begin a new animation on a given node and its hierarchy
  15998. * @param target defines the root node where the animation will take place
  15999. * @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.
  16000. * @param animations defines the list of animations to start
  16001. * @param from defines the initial value
  16002. * @param to defines the final value
  16003. * @param loop defines if you want animation to loop (off by default)
  16004. * @param speedRatio defines the speed ratio to apply to all animations
  16005. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16006. * @param onAnimationLoop defines the callback to call when an animation loops
  16007. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16008. * @returns the list of animatables created for all nodes
  16009. */
  16010. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16011. /**
  16012. * Gets the animatable associated with a specific target
  16013. * @param target defines the target of the animatable
  16014. * @returns the required animatable if found
  16015. */
  16016. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16017. /**
  16018. * Gets all animatables associated with a given target
  16019. * @param target defines the target to look animatables for
  16020. * @returns an array of Animatables
  16021. */
  16022. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16023. /**
  16024. * Stops and removes all animations that have been applied to the scene
  16025. */
  16026. stopAllAnimations(): void;
  16027. /**
  16028. * Gets the current delta time used by animation engine
  16029. */
  16030. deltaTime: number;
  16031. }
  16032. interface Bone {
  16033. /**
  16034. * Copy an animation range from another bone
  16035. * @param source defines the source bone
  16036. * @param rangeName defines the range name to copy
  16037. * @param frameOffset defines the frame offset
  16038. * @param rescaleAsRequired defines if rescaling must be applied if required
  16039. * @param skelDimensionsRatio defines the scaling ratio
  16040. * @returns true if operation was successful
  16041. */
  16042. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16043. }
  16044. }
  16045. declare module BABYLON {
  16046. /**
  16047. * Class used to handle skinning animations
  16048. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16049. */
  16050. export class Skeleton implements IAnimatable {
  16051. /** defines the skeleton name */
  16052. name: string;
  16053. /** defines the skeleton Id */
  16054. id: string;
  16055. /**
  16056. * Defines the list of child bones
  16057. */
  16058. bones: Bone[];
  16059. /**
  16060. * Defines an estimate of the dimension of the skeleton at rest
  16061. */
  16062. dimensionsAtRest: Vector3;
  16063. /**
  16064. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16065. */
  16066. needInitialSkinMatrix: boolean;
  16067. /**
  16068. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16069. */
  16070. overrideMesh: Nullable<AbstractMesh>;
  16071. /**
  16072. * Gets the list of animations attached to this skeleton
  16073. */
  16074. animations: Array<Animation>;
  16075. private _scene;
  16076. private _isDirty;
  16077. private _transformMatrices;
  16078. private _transformMatrixTexture;
  16079. private _meshesWithPoseMatrix;
  16080. private _animatables;
  16081. private _identity;
  16082. private _synchronizedWithMesh;
  16083. private _ranges;
  16084. private _lastAbsoluteTransformsUpdateId;
  16085. private _canUseTextureForBones;
  16086. private _uniqueId;
  16087. /** @hidden */
  16088. _numBonesWithLinkedTransformNode: number;
  16089. /** @hidden */
  16090. _hasWaitingData: Nullable<boolean>;
  16091. /** @hidden */
  16092. _waitingOverrideMeshId: Nullable<string>;
  16093. /**
  16094. * Specifies if the skeleton should be serialized
  16095. */
  16096. doNotSerialize: boolean;
  16097. private _useTextureToStoreBoneMatrices;
  16098. /**
  16099. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16100. * Please note that this option is not available if the hardware does not support it
  16101. */
  16102. get useTextureToStoreBoneMatrices(): boolean;
  16103. set useTextureToStoreBoneMatrices(value: boolean);
  16104. private _animationPropertiesOverride;
  16105. /**
  16106. * Gets or sets the animation properties override
  16107. */
  16108. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16109. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16110. /**
  16111. * List of inspectable custom properties (used by the Inspector)
  16112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16113. */
  16114. inspectableCustomProperties: IInspectable[];
  16115. /**
  16116. * An observable triggered before computing the skeleton's matrices
  16117. */
  16118. onBeforeComputeObservable: Observable<Skeleton>;
  16119. /**
  16120. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16121. */
  16122. get isUsingTextureForMatrices(): boolean;
  16123. /**
  16124. * Gets the unique ID of this skeleton
  16125. */
  16126. get uniqueId(): number;
  16127. /**
  16128. * Creates a new skeleton
  16129. * @param name defines the skeleton name
  16130. * @param id defines the skeleton Id
  16131. * @param scene defines the hosting scene
  16132. */
  16133. constructor(
  16134. /** defines the skeleton name */
  16135. name: string,
  16136. /** defines the skeleton Id */
  16137. id: string, scene: Scene);
  16138. /**
  16139. * Gets the current object class name.
  16140. * @return the class name
  16141. */
  16142. getClassName(): string;
  16143. /**
  16144. * Returns an array containing the root bones
  16145. * @returns an array containing the root bones
  16146. */
  16147. getChildren(): Array<Bone>;
  16148. /**
  16149. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16150. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16151. * @returns a Float32Array containing matrices data
  16152. */
  16153. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16154. /**
  16155. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16156. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16157. * @returns a raw texture containing the data
  16158. */
  16159. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16160. /**
  16161. * Gets the current hosting scene
  16162. * @returns a scene object
  16163. */
  16164. getScene(): Scene;
  16165. /**
  16166. * Gets a string representing the current skeleton data
  16167. * @param fullDetails defines a boolean indicating if we want a verbose version
  16168. * @returns a string representing the current skeleton data
  16169. */
  16170. toString(fullDetails?: boolean): string;
  16171. /**
  16172. * Get bone's index searching by name
  16173. * @param name defines bone's name to search for
  16174. * @return the indice of the bone. Returns -1 if not found
  16175. */
  16176. getBoneIndexByName(name: string): number;
  16177. /**
  16178. * Creater a new animation range
  16179. * @param name defines the name of the range
  16180. * @param from defines the start key
  16181. * @param to defines the end key
  16182. */
  16183. createAnimationRange(name: string, from: number, to: number): void;
  16184. /**
  16185. * Delete a specific animation range
  16186. * @param name defines the name of the range
  16187. * @param deleteFrames defines if frames must be removed as well
  16188. */
  16189. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16190. /**
  16191. * Gets a specific animation range
  16192. * @param name defines the name of the range to look for
  16193. * @returns the requested animation range or null if not found
  16194. */
  16195. getAnimationRange(name: string): Nullable<AnimationRange>;
  16196. /**
  16197. * Gets the list of all animation ranges defined on this skeleton
  16198. * @returns an array
  16199. */
  16200. getAnimationRanges(): Nullable<AnimationRange>[];
  16201. /**
  16202. * Copy animation range from a source skeleton.
  16203. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16204. * @param source defines the source skeleton
  16205. * @param name defines the name of the range to copy
  16206. * @param rescaleAsRequired defines if rescaling must be applied if required
  16207. * @returns true if operation was successful
  16208. */
  16209. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16210. /**
  16211. * Forces the skeleton to go to rest pose
  16212. */
  16213. returnToRest(): void;
  16214. private _getHighestAnimationFrame;
  16215. /**
  16216. * Begin a specific animation range
  16217. * @param name defines the name of the range to start
  16218. * @param loop defines if looping must be turned on (false by default)
  16219. * @param speedRatio defines the speed ratio to apply (1 by default)
  16220. * @param onAnimationEnd defines a callback which will be called when animation will end
  16221. * @returns a new animatable
  16222. */
  16223. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16224. /**
  16225. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16226. * @param skeleton defines the Skeleton containing the animation range to convert
  16227. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16228. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16229. * @returns the original skeleton
  16230. */
  16231. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16232. /** @hidden */
  16233. _markAsDirty(): void;
  16234. /** @hidden */
  16235. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16236. /** @hidden */
  16237. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16238. private _computeTransformMatrices;
  16239. /**
  16240. * Build all resources required to render a skeleton
  16241. */
  16242. prepare(): void;
  16243. /**
  16244. * Gets the list of animatables currently running for this skeleton
  16245. * @returns an array of animatables
  16246. */
  16247. getAnimatables(): IAnimatable[];
  16248. /**
  16249. * Clone the current skeleton
  16250. * @param name defines the name of the new skeleton
  16251. * @param id defines the id of the new skeleton
  16252. * @returns the new skeleton
  16253. */
  16254. clone(name: string, id?: string): Skeleton;
  16255. /**
  16256. * Enable animation blending for this skeleton
  16257. * @param blendingSpeed defines the blending speed to apply
  16258. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16259. */
  16260. enableBlending(blendingSpeed?: number): void;
  16261. /**
  16262. * Releases all resources associated with the current skeleton
  16263. */
  16264. dispose(): void;
  16265. /**
  16266. * Serialize the skeleton in a JSON object
  16267. * @returns a JSON object
  16268. */
  16269. serialize(): any;
  16270. /**
  16271. * Creates a new skeleton from serialized data
  16272. * @param parsedSkeleton defines the serialized data
  16273. * @param scene defines the hosting scene
  16274. * @returns a new skeleton
  16275. */
  16276. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16277. /**
  16278. * Compute all node absolute transforms
  16279. * @param forceUpdate defines if computation must be done even if cache is up to date
  16280. */
  16281. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16282. /**
  16283. * Gets the root pose matrix
  16284. * @returns a matrix
  16285. */
  16286. getPoseMatrix(): Nullable<Matrix>;
  16287. /**
  16288. * Sorts bones per internal index
  16289. */
  16290. sortBones(): void;
  16291. private _sortBones;
  16292. /**
  16293. * Set the current local matrix as the restPose for all bones in the skeleton.
  16294. */
  16295. setCurrentPoseAsRest(): void;
  16296. }
  16297. }
  16298. declare module BABYLON {
  16299. /**
  16300. * Creates an instance based on a source mesh.
  16301. */
  16302. export class InstancedMesh extends AbstractMesh {
  16303. private _sourceMesh;
  16304. private _currentLOD;
  16305. /** @hidden */
  16306. _indexInSourceMeshInstanceArray: number;
  16307. constructor(name: string, source: Mesh);
  16308. /**
  16309. * Returns the string "InstancedMesh".
  16310. */
  16311. getClassName(): string;
  16312. /** Gets the list of lights affecting that mesh */
  16313. get lightSources(): Light[];
  16314. _resyncLightSources(): void;
  16315. _resyncLightSource(light: Light): void;
  16316. _removeLightSource(light: Light, dispose: boolean): void;
  16317. /**
  16318. * If the source mesh receives shadows
  16319. */
  16320. get receiveShadows(): boolean;
  16321. /**
  16322. * The material of the source mesh
  16323. */
  16324. get material(): Nullable<Material>;
  16325. /**
  16326. * Visibility of the source mesh
  16327. */
  16328. get visibility(): number;
  16329. /**
  16330. * Skeleton of the source mesh
  16331. */
  16332. get skeleton(): Nullable<Skeleton>;
  16333. /**
  16334. * Rendering ground id of the source mesh
  16335. */
  16336. get renderingGroupId(): number;
  16337. set renderingGroupId(value: number);
  16338. /**
  16339. * Returns the total number of vertices (integer).
  16340. */
  16341. getTotalVertices(): number;
  16342. /**
  16343. * Returns a positive integer : the total number of indices in this mesh geometry.
  16344. * @returns the numner of indices or zero if the mesh has no geometry.
  16345. */
  16346. getTotalIndices(): number;
  16347. /**
  16348. * The source mesh of the instance
  16349. */
  16350. get sourceMesh(): Mesh;
  16351. /**
  16352. * Creates a new InstancedMesh object from the mesh model.
  16353. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16354. * @param name defines the name of the new instance
  16355. * @returns a new InstancedMesh
  16356. */
  16357. createInstance(name: string): InstancedMesh;
  16358. /**
  16359. * Is this node ready to be used/rendered
  16360. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16361. * @return {boolean} is it ready
  16362. */
  16363. isReady(completeCheck?: boolean): boolean;
  16364. /**
  16365. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16366. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16367. * @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.
  16368. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16369. */
  16370. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16371. /**
  16372. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16373. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16374. * The `data` are either a numeric array either a Float32Array.
  16375. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16376. * 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).
  16377. * Note that a new underlying VertexBuffer object is created each call.
  16378. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16379. *
  16380. * Possible `kind` values :
  16381. * - VertexBuffer.PositionKind
  16382. * - VertexBuffer.UVKind
  16383. * - VertexBuffer.UV2Kind
  16384. * - VertexBuffer.UV3Kind
  16385. * - VertexBuffer.UV4Kind
  16386. * - VertexBuffer.UV5Kind
  16387. * - VertexBuffer.UV6Kind
  16388. * - VertexBuffer.ColorKind
  16389. * - VertexBuffer.MatricesIndicesKind
  16390. * - VertexBuffer.MatricesIndicesExtraKind
  16391. * - VertexBuffer.MatricesWeightsKind
  16392. * - VertexBuffer.MatricesWeightsExtraKind
  16393. *
  16394. * Returns the Mesh.
  16395. */
  16396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16397. /**
  16398. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16399. * If the mesh has no geometry, it is simply returned as it is.
  16400. * The `data` are either a numeric array either a Float32Array.
  16401. * No new underlying VertexBuffer object is created.
  16402. * 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.
  16403. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16404. *
  16405. * Possible `kind` values :
  16406. * - VertexBuffer.PositionKind
  16407. * - VertexBuffer.UVKind
  16408. * - VertexBuffer.UV2Kind
  16409. * - VertexBuffer.UV3Kind
  16410. * - VertexBuffer.UV4Kind
  16411. * - VertexBuffer.UV5Kind
  16412. * - VertexBuffer.UV6Kind
  16413. * - VertexBuffer.ColorKind
  16414. * - VertexBuffer.MatricesIndicesKind
  16415. * - VertexBuffer.MatricesIndicesExtraKind
  16416. * - VertexBuffer.MatricesWeightsKind
  16417. * - VertexBuffer.MatricesWeightsExtraKind
  16418. *
  16419. * Returns the Mesh.
  16420. */
  16421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16422. /**
  16423. * Sets the mesh indices.
  16424. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16425. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16426. * This method creates a new index buffer each call.
  16427. * Returns the Mesh.
  16428. */
  16429. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16430. /**
  16431. * Boolean : True if the mesh owns the requested kind of data.
  16432. */
  16433. isVerticesDataPresent(kind: string): boolean;
  16434. /**
  16435. * Returns an array of indices (IndicesArray).
  16436. */
  16437. getIndices(): Nullable<IndicesArray>;
  16438. get _positions(): Nullable<Vector3[]>;
  16439. /**
  16440. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16441. * This means the mesh underlying bounding box and sphere are recomputed.
  16442. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16443. * @returns the current mesh
  16444. */
  16445. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16446. /** @hidden */
  16447. _preActivate(): InstancedMesh;
  16448. /** @hidden */
  16449. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16450. /** @hidden */
  16451. _postActivate(): void;
  16452. getWorldMatrix(): Matrix;
  16453. get isAnInstance(): boolean;
  16454. /**
  16455. * Returns the current associated LOD AbstractMesh.
  16456. */
  16457. getLOD(camera: Camera): AbstractMesh;
  16458. /** @hidden */
  16459. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16460. /** @hidden */
  16461. _syncSubMeshes(): InstancedMesh;
  16462. /** @hidden */
  16463. _generatePointsArray(): boolean;
  16464. /** @hidden */
  16465. _updateBoundingInfo(): AbstractMesh;
  16466. /**
  16467. * Creates a new InstancedMesh from the current mesh.
  16468. * - name (string) : the cloned mesh name
  16469. * - newParent (optional Node) : the optional Node to parent the clone to.
  16470. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16471. *
  16472. * Returns the clone.
  16473. */
  16474. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16475. /**
  16476. * Disposes the InstancedMesh.
  16477. * Returns nothing.
  16478. */
  16479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16480. }
  16481. interface Mesh {
  16482. /**
  16483. * Register a custom buffer that will be instanced
  16484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16485. * @param kind defines the buffer kind
  16486. * @param stride defines the stride in floats
  16487. */
  16488. registerInstancedBuffer(kind: string, stride: number): void;
  16489. /**
  16490. * true to use the edge renderer for all instances of this mesh
  16491. */
  16492. edgesShareWithInstances: boolean;
  16493. /** @hidden */
  16494. _userInstancedBuffersStorage: {
  16495. data: {
  16496. [key: string]: Float32Array;
  16497. };
  16498. sizes: {
  16499. [key: string]: number;
  16500. };
  16501. vertexBuffers: {
  16502. [key: string]: Nullable<VertexBuffer>;
  16503. };
  16504. strides: {
  16505. [key: string]: number;
  16506. };
  16507. };
  16508. }
  16509. interface AbstractMesh {
  16510. /**
  16511. * Object used to store instanced buffers defined by user
  16512. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16513. */
  16514. instancedBuffers: {
  16515. [key: string]: any;
  16516. };
  16517. }
  16518. }
  16519. declare module BABYLON {
  16520. /**
  16521. * Defines the options associated with the creation of a shader material.
  16522. */
  16523. export interface IShaderMaterialOptions {
  16524. /**
  16525. * Does the material work in alpha blend mode
  16526. */
  16527. needAlphaBlending: boolean;
  16528. /**
  16529. * Does the material work in alpha test mode
  16530. */
  16531. needAlphaTesting: boolean;
  16532. /**
  16533. * The list of attribute names used in the shader
  16534. */
  16535. attributes: string[];
  16536. /**
  16537. * The list of unifrom names used in the shader
  16538. */
  16539. uniforms: string[];
  16540. /**
  16541. * The list of UBO names used in the shader
  16542. */
  16543. uniformBuffers: string[];
  16544. /**
  16545. * The list of sampler names used in the shader
  16546. */
  16547. samplers: string[];
  16548. /**
  16549. * The list of defines used in the shader
  16550. */
  16551. defines: string[];
  16552. }
  16553. /**
  16554. * 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.
  16555. *
  16556. * This returned material effects how the mesh will look based on the code in the shaders.
  16557. *
  16558. * @see https://doc.babylonjs.com/how_to/shader_material
  16559. */
  16560. export class ShaderMaterial extends Material {
  16561. private _shaderPath;
  16562. private _options;
  16563. private _textures;
  16564. private _textureArrays;
  16565. private _floats;
  16566. private _ints;
  16567. private _floatsArrays;
  16568. private _colors3;
  16569. private _colors3Arrays;
  16570. private _colors4;
  16571. private _colors4Arrays;
  16572. private _vectors2;
  16573. private _vectors3;
  16574. private _vectors4;
  16575. private _matrices;
  16576. private _matrixArrays;
  16577. private _matrices3x3;
  16578. private _matrices2x2;
  16579. private _vectors2Arrays;
  16580. private _vectors3Arrays;
  16581. private _vectors4Arrays;
  16582. private _cachedWorldViewMatrix;
  16583. private _cachedWorldViewProjectionMatrix;
  16584. private _renderId;
  16585. private _multiview;
  16586. private _cachedDefines;
  16587. /** Define the Url to load snippets */
  16588. static SnippetUrl: string;
  16589. /** Snippet ID if the material was created from the snippet server */
  16590. snippetId: string;
  16591. /**
  16592. * Instantiate a new shader material.
  16593. * 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.
  16594. * This returned material effects how the mesh will look based on the code in the shaders.
  16595. * @see https://doc.babylonjs.com/how_to/shader_material
  16596. * @param name Define the name of the material in the scene
  16597. * @param scene Define the scene the material belongs to
  16598. * @param shaderPath Defines the route to the shader code in one of three ways:
  16599. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16600. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16601. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16602. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16603. * @param options Define the options used to create the shader
  16604. */
  16605. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16606. /**
  16607. * Gets the shader path used to define the shader code
  16608. * It can be modified to trigger a new compilation
  16609. */
  16610. get shaderPath(): any;
  16611. /**
  16612. * Sets the shader path used to define the shader code
  16613. * It can be modified to trigger a new compilation
  16614. */
  16615. set shaderPath(shaderPath: any);
  16616. /**
  16617. * Gets the options used to compile the shader.
  16618. * They can be modified to trigger a new compilation
  16619. */
  16620. get options(): IShaderMaterialOptions;
  16621. /**
  16622. * Gets the current class name of the material e.g. "ShaderMaterial"
  16623. * Mainly use in serialization.
  16624. * @returns the class name
  16625. */
  16626. getClassName(): string;
  16627. /**
  16628. * Specifies if the material will require alpha blending
  16629. * @returns a boolean specifying if alpha blending is needed
  16630. */
  16631. needAlphaBlending(): boolean;
  16632. /**
  16633. * Specifies if this material should be rendered in alpha test mode
  16634. * @returns a boolean specifying if an alpha test is needed.
  16635. */
  16636. needAlphaTesting(): boolean;
  16637. private _checkUniform;
  16638. /**
  16639. * Set a texture in the shader.
  16640. * @param name Define the name of the uniform samplers as defined in the shader
  16641. * @param texture Define the texture to bind to this sampler
  16642. * @return the material itself allowing "fluent" like uniform updates
  16643. */
  16644. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16645. /**
  16646. * Set a texture array in the shader.
  16647. * @param name Define the name of the uniform sampler array as defined in the shader
  16648. * @param textures Define the list of textures to bind to this sampler
  16649. * @return the material itself allowing "fluent" like uniform updates
  16650. */
  16651. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16652. /**
  16653. * Set a float in the shader.
  16654. * @param name Define the name of the uniform as defined in the shader
  16655. * @param value Define the value to give to the uniform
  16656. * @return the material itself allowing "fluent" like uniform updates
  16657. */
  16658. setFloat(name: string, value: number): ShaderMaterial;
  16659. /**
  16660. * Set a int in the shader.
  16661. * @param name Define the name of the uniform as defined in the shader
  16662. * @param value Define the value to give to the uniform
  16663. * @return the material itself allowing "fluent" like uniform updates
  16664. */
  16665. setInt(name: string, value: number): ShaderMaterial;
  16666. /**
  16667. * Set an array of floats in the shader.
  16668. * @param name Define the name of the uniform as defined in the shader
  16669. * @param value Define the value to give to the uniform
  16670. * @return the material itself allowing "fluent" like uniform updates
  16671. */
  16672. setFloats(name: string, value: number[]): ShaderMaterial;
  16673. /**
  16674. * Set a vec3 in the shader from a Color3.
  16675. * @param name Define the name of the uniform as defined in the shader
  16676. * @param value Define the value to give to the uniform
  16677. * @return the material itself allowing "fluent" like uniform updates
  16678. */
  16679. setColor3(name: string, value: Color3): ShaderMaterial;
  16680. /**
  16681. * Set a vec3 array in the shader from a Color3 array.
  16682. * @param name Define the name of the uniform as defined in the shader
  16683. * @param value Define the value to give to the uniform
  16684. * @return the material itself allowing "fluent" like uniform updates
  16685. */
  16686. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16687. /**
  16688. * Set a vec4 in the shader from a Color4.
  16689. * @param name Define the name of the uniform as defined in the shader
  16690. * @param value Define the value to give to the uniform
  16691. * @return the material itself allowing "fluent" like uniform updates
  16692. */
  16693. setColor4(name: string, value: Color4): ShaderMaterial;
  16694. /**
  16695. * Set a vec4 array in the shader from a Color4 array.
  16696. * @param name Define the name of the uniform as defined in the shader
  16697. * @param value Define the value to give to the uniform
  16698. * @return the material itself allowing "fluent" like uniform updates
  16699. */
  16700. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16701. /**
  16702. * Set a vec2 in the shader from a Vector2.
  16703. * @param name Define the name of the uniform as defined in the shader
  16704. * @param value Define the value to give to the uniform
  16705. * @return the material itself allowing "fluent" like uniform updates
  16706. */
  16707. setVector2(name: string, value: Vector2): ShaderMaterial;
  16708. /**
  16709. * Set a vec3 in the shader from a Vector3.
  16710. * @param name Define the name of the uniform as defined in the shader
  16711. * @param value Define the value to give to the uniform
  16712. * @return the material itself allowing "fluent" like uniform updates
  16713. */
  16714. setVector3(name: string, value: Vector3): ShaderMaterial;
  16715. /**
  16716. * Set a vec4 in the shader from a Vector4.
  16717. * @param name Define the name of the uniform as defined in the shader
  16718. * @param value Define the value to give to the uniform
  16719. * @return the material itself allowing "fluent" like uniform updates
  16720. */
  16721. setVector4(name: string, value: Vector4): ShaderMaterial;
  16722. /**
  16723. * Set a mat4 in the shader from a Matrix.
  16724. * @param name Define the name of the uniform as defined in the shader
  16725. * @param value Define the value to give to the uniform
  16726. * @return the material itself allowing "fluent" like uniform updates
  16727. */
  16728. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16729. /**
  16730. * Set a float32Array in the shader from a matrix array.
  16731. * @param name Define the name of the uniform as defined in the shader
  16732. * @param value Define the value to give to the uniform
  16733. * @return the material itself allowing "fluent" like uniform updates
  16734. */
  16735. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16736. /**
  16737. * Set a mat3 in the shader from a Float32Array.
  16738. * @param name Define the name of the uniform as defined in the shader
  16739. * @param value Define the value to give to the uniform
  16740. * @return the material itself allowing "fluent" like uniform updates
  16741. */
  16742. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16743. /**
  16744. * Set a mat2 in the shader from a Float32Array.
  16745. * @param name Define the name of the uniform as defined in the shader
  16746. * @param value Define the value to give to the uniform
  16747. * @return the material itself allowing "fluent" like uniform updates
  16748. */
  16749. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16750. /**
  16751. * Set a vec2 array in the shader from a number array.
  16752. * @param name Define the name of the uniform as defined in the shader
  16753. * @param value Define the value to give to the uniform
  16754. * @return the material itself allowing "fluent" like uniform updates
  16755. */
  16756. setArray2(name: string, value: number[]): ShaderMaterial;
  16757. /**
  16758. * Set a vec3 array in the shader from a number array.
  16759. * @param name Define the name of the uniform as defined in the shader
  16760. * @param value Define the value to give to the uniform
  16761. * @return the material itself allowing "fluent" like uniform updates
  16762. */
  16763. setArray3(name: string, value: number[]): ShaderMaterial;
  16764. /**
  16765. * Set a vec4 array in the shader from a number array.
  16766. * @param name Define the name of the uniform as defined in the shader
  16767. * @param value Define the value to give to the uniform
  16768. * @return the material itself allowing "fluent" like uniform updates
  16769. */
  16770. setArray4(name: string, value: number[]): ShaderMaterial;
  16771. private _checkCache;
  16772. /**
  16773. * Specifies that the submesh is ready to be used
  16774. * @param mesh defines the mesh to check
  16775. * @param subMesh defines which submesh to check
  16776. * @param useInstances specifies that instances should be used
  16777. * @returns a boolean indicating that the submesh is ready or not
  16778. */
  16779. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16780. /**
  16781. * Checks if the material is ready to render the requested mesh
  16782. * @param mesh Define the mesh to render
  16783. * @param useInstances Define whether or not the material is used with instances
  16784. * @returns true if ready, otherwise false
  16785. */
  16786. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16787. /**
  16788. * Binds the world matrix to the material
  16789. * @param world defines the world transformation matrix
  16790. * @param effectOverride - If provided, use this effect instead of internal effect
  16791. */
  16792. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16793. /**
  16794. * Binds the submesh to this material by preparing the effect and shader to draw
  16795. * @param world defines the world transformation matrix
  16796. * @param mesh defines the mesh containing the submesh
  16797. * @param subMesh defines the submesh to bind the material to
  16798. */
  16799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16800. /**
  16801. * Binds the material to the mesh
  16802. * @param world defines the world transformation matrix
  16803. * @param mesh defines the mesh to bind the material to
  16804. * @param effectOverride - If provided, use this effect instead of internal effect
  16805. */
  16806. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16807. protected _afterBind(mesh?: Mesh): void;
  16808. /**
  16809. * Gets the active textures from the material
  16810. * @returns an array of textures
  16811. */
  16812. getActiveTextures(): BaseTexture[];
  16813. /**
  16814. * Specifies if the material uses a texture
  16815. * @param texture defines the texture to check against the material
  16816. * @returns a boolean specifying if the material uses the texture
  16817. */
  16818. hasTexture(texture: BaseTexture): boolean;
  16819. /**
  16820. * Makes a duplicate of the material, and gives it a new name
  16821. * @param name defines the new name for the duplicated material
  16822. * @returns the cloned material
  16823. */
  16824. clone(name: string): ShaderMaterial;
  16825. /**
  16826. * Disposes the material
  16827. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16828. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16829. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16830. */
  16831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16832. /**
  16833. * Serializes this material in a JSON representation
  16834. * @returns the serialized material object
  16835. */
  16836. serialize(): any;
  16837. /**
  16838. * Creates a shader material from parsed shader material data
  16839. * @param source defines the JSON represnetation of the material
  16840. * @param scene defines the hosting scene
  16841. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16842. * @returns a new material
  16843. */
  16844. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16845. /**
  16846. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16847. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16848. * @param url defines the url to load from
  16849. * @param scene defines the hosting scene
  16850. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16851. * @returns a promise that will resolve to the new ShaderMaterial
  16852. */
  16853. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16854. /**
  16855. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16856. * @param snippetId defines the snippet to load
  16857. * @param scene defines the hosting scene
  16858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16859. * @returns a promise that will resolve to the new ShaderMaterial
  16860. */
  16861. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16862. }
  16863. }
  16864. declare module BABYLON {
  16865. /** @hidden */
  16866. export var colorPixelShader: {
  16867. name: string;
  16868. shader: string;
  16869. };
  16870. }
  16871. declare module BABYLON {
  16872. /** @hidden */
  16873. export var colorVertexShader: {
  16874. name: string;
  16875. shader: string;
  16876. };
  16877. }
  16878. declare module BABYLON {
  16879. /**
  16880. * Line mesh
  16881. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16882. */
  16883. export class LinesMesh extends Mesh {
  16884. /**
  16885. * If vertex color should be applied to the mesh
  16886. */
  16887. readonly useVertexColor?: boolean | undefined;
  16888. /**
  16889. * If vertex alpha should be applied to the mesh
  16890. */
  16891. readonly useVertexAlpha?: boolean | undefined;
  16892. /**
  16893. * Color of the line (Default: White)
  16894. */
  16895. color: Color3;
  16896. /**
  16897. * Alpha of the line (Default: 1)
  16898. */
  16899. alpha: number;
  16900. /**
  16901. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16902. * This margin is expressed in world space coordinates, so its value may vary.
  16903. * Default value is 0.1
  16904. */
  16905. intersectionThreshold: number;
  16906. private _colorShader;
  16907. private color4;
  16908. /**
  16909. * Creates a new LinesMesh
  16910. * @param name defines the name
  16911. * @param scene defines the hosting scene
  16912. * @param parent defines the parent mesh if any
  16913. * @param source defines the optional source LinesMesh used to clone data from
  16914. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16915. * When false, achieved by calling a clone(), also passing False.
  16916. * This will make creation of children, recursive.
  16917. * @param useVertexColor defines if this LinesMesh supports vertex color
  16918. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16919. */
  16920. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16921. /**
  16922. * If vertex color should be applied to the mesh
  16923. */
  16924. useVertexColor?: boolean | undefined,
  16925. /**
  16926. * If vertex alpha should be applied to the mesh
  16927. */
  16928. useVertexAlpha?: boolean | undefined);
  16929. private _addClipPlaneDefine;
  16930. private _removeClipPlaneDefine;
  16931. isReady(): boolean;
  16932. /**
  16933. * Returns the string "LineMesh"
  16934. */
  16935. getClassName(): string;
  16936. /**
  16937. * @hidden
  16938. */
  16939. get material(): Material;
  16940. /**
  16941. * @hidden
  16942. */
  16943. set material(value: Material);
  16944. /**
  16945. * @hidden
  16946. */
  16947. get checkCollisions(): boolean;
  16948. /** @hidden */
  16949. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16950. /** @hidden */
  16951. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16952. /**
  16953. * Disposes of the line mesh
  16954. * @param doNotRecurse If children should be disposed
  16955. */
  16956. dispose(doNotRecurse?: boolean): void;
  16957. /**
  16958. * Returns a new LineMesh object cloned from the current one.
  16959. */
  16960. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16961. /**
  16962. * Creates a new InstancedLinesMesh object from the mesh model.
  16963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16964. * @param name defines the name of the new instance
  16965. * @returns a new InstancedLinesMesh
  16966. */
  16967. createInstance(name: string): InstancedLinesMesh;
  16968. }
  16969. /**
  16970. * Creates an instance based on a source LinesMesh
  16971. */
  16972. export class InstancedLinesMesh extends InstancedMesh {
  16973. /**
  16974. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16975. * This margin is expressed in world space coordinates, so its value may vary.
  16976. * Initilized with the intersectionThreshold value of the source LinesMesh
  16977. */
  16978. intersectionThreshold: number;
  16979. constructor(name: string, source: LinesMesh);
  16980. /**
  16981. * Returns the string "InstancedLinesMesh".
  16982. */
  16983. getClassName(): string;
  16984. }
  16985. }
  16986. declare module BABYLON {
  16987. /** @hidden */
  16988. export var linePixelShader: {
  16989. name: string;
  16990. shader: string;
  16991. };
  16992. }
  16993. declare module BABYLON {
  16994. /** @hidden */
  16995. export var lineVertexShader: {
  16996. name: string;
  16997. shader: string;
  16998. };
  16999. }
  17000. declare module BABYLON {
  17001. interface Scene {
  17002. /** @hidden */
  17003. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17004. }
  17005. interface AbstractMesh {
  17006. /**
  17007. * Gets the edgesRenderer associated with the mesh
  17008. */
  17009. edgesRenderer: Nullable<EdgesRenderer>;
  17010. }
  17011. interface LinesMesh {
  17012. /**
  17013. * Enables the edge rendering mode on the mesh.
  17014. * This mode makes the mesh edges visible
  17015. * @param epsilon defines the maximal distance between two angles to detect a face
  17016. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17017. * @returns the currentAbstractMesh
  17018. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17019. */
  17020. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17021. }
  17022. interface InstancedLinesMesh {
  17023. /**
  17024. * Enables the edge rendering mode on the mesh.
  17025. * This mode makes the mesh edges visible
  17026. * @param epsilon defines the maximal distance between two angles to detect a face
  17027. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17028. * @returns the current InstancedLinesMesh
  17029. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17030. */
  17031. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17032. }
  17033. /**
  17034. * Defines the minimum contract an Edges renderer should follow.
  17035. */
  17036. export interface IEdgesRenderer extends IDisposable {
  17037. /**
  17038. * Gets or sets a boolean indicating if the edgesRenderer is active
  17039. */
  17040. isEnabled: boolean;
  17041. /**
  17042. * Renders the edges of the attached mesh,
  17043. */
  17044. render(): void;
  17045. /**
  17046. * Checks wether or not the edges renderer is ready to render.
  17047. * @return true if ready, otherwise false.
  17048. */
  17049. isReady(): boolean;
  17050. /**
  17051. * List of instances to render in case the source mesh has instances
  17052. */
  17053. customInstances: SmartArray<Matrix>;
  17054. }
  17055. /**
  17056. * Defines the additional options of the edges renderer
  17057. */
  17058. export interface IEdgesRendererOptions {
  17059. /**
  17060. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17061. * If not defined, the default value is true
  17062. */
  17063. useAlternateEdgeFinder?: boolean;
  17064. /**
  17065. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17066. * If not defined, the default value is true.
  17067. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17068. * This option is used only if useAlternateEdgeFinder = true
  17069. */
  17070. useFastVertexMerger?: boolean;
  17071. /**
  17072. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17073. * The default value is 1e-6
  17074. * This option is used only if useAlternateEdgeFinder = true
  17075. */
  17076. epsilonVertexMerge?: number;
  17077. /**
  17078. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17079. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17080. * This option is used only if useAlternateEdgeFinder = true
  17081. */
  17082. applyTessellation?: boolean;
  17083. /**
  17084. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17085. * The default value is 1e-6
  17086. * This option is used only if useAlternateEdgeFinder = true
  17087. */
  17088. epsilonVertexAligned?: number;
  17089. }
  17090. /**
  17091. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17092. */
  17093. export class EdgesRenderer implements IEdgesRenderer {
  17094. /**
  17095. * Define the size of the edges with an orthographic camera
  17096. */
  17097. edgesWidthScalerForOrthographic: number;
  17098. /**
  17099. * Define the size of the edges with a perspective camera
  17100. */
  17101. edgesWidthScalerForPerspective: number;
  17102. protected _source: AbstractMesh;
  17103. protected _linesPositions: number[];
  17104. protected _linesNormals: number[];
  17105. protected _linesIndices: number[];
  17106. protected _epsilon: number;
  17107. protected _indicesCount: number;
  17108. protected _lineShader: ShaderMaterial;
  17109. protected _ib: DataBuffer;
  17110. protected _buffers: {
  17111. [key: string]: Nullable<VertexBuffer>;
  17112. };
  17113. protected _buffersForInstances: {
  17114. [key: string]: Nullable<VertexBuffer>;
  17115. };
  17116. protected _checkVerticesInsteadOfIndices: boolean;
  17117. protected _options: Nullable<IEdgesRendererOptions>;
  17118. private _meshRebuildObserver;
  17119. private _meshDisposeObserver;
  17120. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17121. isEnabled: boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. private static GetShader;
  17127. /**
  17128. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17129. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17130. * @param source Mesh used to create edges
  17131. * @param epsilon sum of angles in adjacency to check for edge
  17132. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17133. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17134. * @param options The options to apply when generating the edges
  17135. */
  17136. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17137. protected _prepareRessources(): void;
  17138. /** @hidden */
  17139. _rebuild(): void;
  17140. /**
  17141. * Releases the required resources for the edges renderer
  17142. */
  17143. dispose(): void;
  17144. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17145. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17146. /**
  17147. * Checks if the pair of p0 and p1 is en edge
  17148. * @param faceIndex
  17149. * @param edge
  17150. * @param faceNormals
  17151. * @param p0
  17152. * @param p1
  17153. * @private
  17154. */
  17155. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17156. /**
  17157. * push line into the position, normal and index buffer
  17158. * @protected
  17159. */
  17160. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17161. /**
  17162. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17163. */
  17164. private _tessellateTriangle;
  17165. private _generateEdgesLinesAlternate;
  17166. /**
  17167. * Generates lines edges from adjacencjes
  17168. * @private
  17169. */
  17170. _generateEdgesLines(): void;
  17171. /**
  17172. * Checks wether or not the edges renderer is ready to render.
  17173. * @return true if ready, otherwise false.
  17174. */
  17175. isReady(): boolean;
  17176. /**
  17177. * Renders the edges of the attached mesh,
  17178. */
  17179. render(): void;
  17180. }
  17181. /**
  17182. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17183. */
  17184. export class LineEdgesRenderer extends EdgesRenderer {
  17185. /**
  17186. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17187. * @param source LineMesh used to generate edges
  17188. * @param epsilon not important (specified angle for edge detection)
  17189. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17190. */
  17191. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17192. /**
  17193. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17194. */
  17195. _generateEdgesLines(): void;
  17196. }
  17197. }
  17198. declare module BABYLON {
  17199. /**
  17200. * This represents the object necessary to create a rendering group.
  17201. * This is exclusively used and created by the rendering manager.
  17202. * To modify the behavior, you use the available helpers in your scene or meshes.
  17203. * @hidden
  17204. */
  17205. export class RenderingGroup {
  17206. index: number;
  17207. private static _zeroVector;
  17208. private _scene;
  17209. private _opaqueSubMeshes;
  17210. private _transparentSubMeshes;
  17211. private _alphaTestSubMeshes;
  17212. private _depthOnlySubMeshes;
  17213. private _particleSystems;
  17214. private _spriteManagers;
  17215. private _opaqueSortCompareFn;
  17216. private _alphaTestSortCompareFn;
  17217. private _transparentSortCompareFn;
  17218. private _renderOpaque;
  17219. private _renderAlphaTest;
  17220. private _renderTransparent;
  17221. /** @hidden */
  17222. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17223. onBeforeTransparentRendering: () => void;
  17224. /**
  17225. * Set the opaque sort comparison function.
  17226. * If null the sub meshes will be render in the order they were created
  17227. */
  17228. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17229. /**
  17230. * Set the alpha test sort comparison function.
  17231. * If null the sub meshes will be render in the order they were created
  17232. */
  17233. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17234. /**
  17235. * Set the transparent sort comparison function.
  17236. * If null the sub meshes will be render in the order they were created
  17237. */
  17238. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17239. /**
  17240. * Creates a new rendering group.
  17241. * @param index The rendering group index
  17242. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17243. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17244. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17245. */
  17246. 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>);
  17247. /**
  17248. * Render all the sub meshes contained in the group.
  17249. * @param customRenderFunction Used to override the default render behaviour of the group.
  17250. * @returns true if rendered some submeshes.
  17251. */
  17252. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17253. /**
  17254. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17255. * @param subMeshes The submeshes to render
  17256. */
  17257. private renderOpaqueSorted;
  17258. /**
  17259. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17260. * @param subMeshes The submeshes to render
  17261. */
  17262. private renderAlphaTestSorted;
  17263. /**
  17264. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17265. * @param subMeshes The submeshes to render
  17266. */
  17267. private renderTransparentSorted;
  17268. /**
  17269. * Renders the submeshes in a specified order.
  17270. * @param subMeshes The submeshes to sort before render
  17271. * @param sortCompareFn The comparison function use to sort
  17272. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17273. * @param transparent Specifies to activate blending if true
  17274. */
  17275. private static renderSorted;
  17276. /**
  17277. * Renders the submeshes in the order they were dispatched (no sort applied).
  17278. * @param subMeshes The submeshes to render
  17279. */
  17280. private static renderUnsorted;
  17281. /**
  17282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17283. * are rendered back to front if in the same alpha index.
  17284. *
  17285. * @param a The first submesh
  17286. * @param b The second submesh
  17287. * @returns The result of the comparison
  17288. */
  17289. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17290. /**
  17291. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17292. * are rendered back to front.
  17293. *
  17294. * @param a The first submesh
  17295. * @param b The second submesh
  17296. * @returns The result of the comparison
  17297. */
  17298. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17299. /**
  17300. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17301. * are rendered front to back (prevent overdraw).
  17302. *
  17303. * @param a The first submesh
  17304. * @param b The second submesh
  17305. * @returns The result of the comparison
  17306. */
  17307. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17308. /**
  17309. * Resets the different lists of submeshes to prepare a new frame.
  17310. */
  17311. prepare(): void;
  17312. dispose(): void;
  17313. /**
  17314. * Inserts the submesh in its correct queue depending on its material.
  17315. * @param subMesh The submesh to dispatch
  17316. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17317. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17318. */
  17319. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17320. dispatchSprites(spriteManager: ISpriteManager): void;
  17321. dispatchParticles(particleSystem: IParticleSystem): void;
  17322. private _renderParticles;
  17323. private _renderSprites;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Interface describing the different options available in the rendering manager
  17329. * regarding Auto Clear between groups.
  17330. */
  17331. export interface IRenderingManagerAutoClearSetup {
  17332. /**
  17333. * Defines whether or not autoclear is enable.
  17334. */
  17335. autoClear: boolean;
  17336. /**
  17337. * Defines whether or not to autoclear the depth buffer.
  17338. */
  17339. depth: boolean;
  17340. /**
  17341. * Defines whether or not to autoclear the stencil buffer.
  17342. */
  17343. stencil: boolean;
  17344. }
  17345. /**
  17346. * This class is used by the onRenderingGroupObservable
  17347. */
  17348. export class RenderingGroupInfo {
  17349. /**
  17350. * The Scene that being rendered
  17351. */
  17352. scene: Scene;
  17353. /**
  17354. * The camera currently used for the rendering pass
  17355. */
  17356. camera: Nullable<Camera>;
  17357. /**
  17358. * The ID of the renderingGroup being processed
  17359. */
  17360. renderingGroupId: number;
  17361. }
  17362. /**
  17363. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17364. * It is enable to manage the different groups as well as the different necessary sort functions.
  17365. * This should not be used directly aside of the few static configurations
  17366. */
  17367. export class RenderingManager {
  17368. /**
  17369. * The max id used for rendering groups (not included)
  17370. */
  17371. static MAX_RENDERINGGROUPS: number;
  17372. /**
  17373. * The min id used for rendering groups (included)
  17374. */
  17375. static MIN_RENDERINGGROUPS: number;
  17376. /**
  17377. * Used to globally prevent autoclearing scenes.
  17378. */
  17379. static AUTOCLEAR: boolean;
  17380. /**
  17381. * @hidden
  17382. */
  17383. _useSceneAutoClearSetup: boolean;
  17384. private _scene;
  17385. private _renderingGroups;
  17386. private _depthStencilBufferAlreadyCleaned;
  17387. private _autoClearDepthStencil;
  17388. private _customOpaqueSortCompareFn;
  17389. private _customAlphaTestSortCompareFn;
  17390. private _customTransparentSortCompareFn;
  17391. private _renderingGroupInfo;
  17392. /**
  17393. * Instantiates a new rendering group for a particular scene
  17394. * @param scene Defines the scene the groups belongs to
  17395. */
  17396. constructor(scene: Scene);
  17397. private _clearDepthStencilBuffer;
  17398. /**
  17399. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17400. * @hidden
  17401. */
  17402. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17403. /**
  17404. * Resets the different information of the group to prepare a new frame
  17405. * @hidden
  17406. */
  17407. reset(): void;
  17408. /**
  17409. * Dispose and release the group and its associated resources.
  17410. * @hidden
  17411. */
  17412. dispose(): void;
  17413. /**
  17414. * Clear the info related to rendering groups preventing retention points during dispose.
  17415. */
  17416. freeRenderingGroups(): void;
  17417. private _prepareRenderingGroup;
  17418. /**
  17419. * Add a sprite manager to the rendering manager in order to render it this frame.
  17420. * @param spriteManager Define the sprite manager to render
  17421. */
  17422. dispatchSprites(spriteManager: ISpriteManager): void;
  17423. /**
  17424. * Add a particle system to the rendering manager in order to render it this frame.
  17425. * @param particleSystem Define the particle system to render
  17426. */
  17427. dispatchParticles(particleSystem: IParticleSystem): void;
  17428. /**
  17429. * Add a submesh to the manager in order to render it this frame
  17430. * @param subMesh The submesh to dispatch
  17431. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17432. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17433. */
  17434. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17435. /**
  17436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17437. * This allowed control for front to back rendering or reversly depending of the special needs.
  17438. *
  17439. * @param renderingGroupId The rendering group id corresponding to its index
  17440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17443. */
  17444. 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;
  17445. /**
  17446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17447. *
  17448. * @param renderingGroupId The rendering group id corresponding to its index
  17449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17450. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17451. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17452. */
  17453. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17454. /**
  17455. * Gets the current auto clear configuration for one rendering group of the rendering
  17456. * manager.
  17457. * @param index the rendering group index to get the information for
  17458. * @returns The auto clear setup for the requested rendering group
  17459. */
  17460. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17461. }
  17462. }
  17463. declare module BABYLON {
  17464. /**
  17465. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17466. */
  17467. export interface ICustomShaderOptions {
  17468. /**
  17469. * Gets or sets the custom shader name to use
  17470. */
  17471. shaderName: string;
  17472. /**
  17473. * The list of attribute names used in the shader
  17474. */
  17475. attributes?: string[];
  17476. /**
  17477. * The list of unifrom names used in the shader
  17478. */
  17479. uniforms?: string[];
  17480. /**
  17481. * The list of sampler names used in the shader
  17482. */
  17483. samplers?: string[];
  17484. /**
  17485. * The list of defines used in the shader
  17486. */
  17487. defines?: string[];
  17488. }
  17489. /**
  17490. * Interface to implement to create a shadow generator compatible with BJS.
  17491. */
  17492. export interface IShadowGenerator {
  17493. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17494. id: string;
  17495. /**
  17496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17497. * @returns The render target texture if present otherwise, null
  17498. */
  17499. getShadowMap(): Nullable<RenderTargetTexture>;
  17500. /**
  17501. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17502. * @param subMesh The submesh we want to render in the shadow map
  17503. * @param useInstances Defines wether will draw in the map using instances
  17504. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17505. * @returns true if ready otherwise, false
  17506. */
  17507. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17508. /**
  17509. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17510. * @param defines Defines of the material we want to update
  17511. * @param lightIndex Index of the light in the enabled light list of the material
  17512. */
  17513. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17514. /**
  17515. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17516. * defined in the generator but impacting the effect).
  17517. * It implies the unifroms available on the materials are the standard BJS ones.
  17518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17519. * @param effect The effect we are binfing the information for
  17520. */
  17521. bindShadowLight(lightIndex: string, effect: Effect): void;
  17522. /**
  17523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17524. * (eq to shadow prjection matrix * light transform matrix)
  17525. * @returns The transform matrix used to create the shadow map
  17526. */
  17527. getTransformMatrix(): Matrix;
  17528. /**
  17529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17530. * Cube and 2D textures for instance.
  17531. */
  17532. recreateShadowMap(): void;
  17533. /**
  17534. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17535. * @param onCompiled Callback triggered at the and of the effects compilation
  17536. * @param options Sets of optional options forcing the compilation with different modes
  17537. */
  17538. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17539. useInstances: boolean;
  17540. }>): void;
  17541. /**
  17542. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17543. * @param options Sets of optional options forcing the compilation with different modes
  17544. * @returns A promise that resolves when the compilation completes
  17545. */
  17546. forceCompilationAsync(options?: Partial<{
  17547. useInstances: boolean;
  17548. }>): Promise<void>;
  17549. /**
  17550. * Serializes the shadow generator setup to a json object.
  17551. * @returns The serialized JSON object
  17552. */
  17553. serialize(): any;
  17554. /**
  17555. * Disposes the Shadow map and related Textures and effects.
  17556. */
  17557. dispose(): void;
  17558. }
  17559. /**
  17560. * Default implementation IShadowGenerator.
  17561. * This is the main object responsible of generating shadows in the framework.
  17562. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17563. */
  17564. export class ShadowGenerator implements IShadowGenerator {
  17565. /**
  17566. * Name of the shadow generator class
  17567. */
  17568. static CLASSNAME: string;
  17569. /**
  17570. * Shadow generator mode None: no filtering applied.
  17571. */
  17572. static readonly FILTER_NONE: number;
  17573. /**
  17574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17576. */
  17577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17578. /**
  17579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17581. */
  17582. static readonly FILTER_POISSONSAMPLING: number;
  17583. /**
  17584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17586. */
  17587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17588. /**
  17589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17590. * edge artifacts on steep falloff.
  17591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17592. */
  17593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17594. /**
  17595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17596. * edge artifacts on steep falloff.
  17597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17598. */
  17599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17600. /**
  17601. * Shadow generator mode PCF: Percentage Closer Filtering
  17602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17604. */
  17605. static readonly FILTER_PCF: number;
  17606. /**
  17607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17609. * Contact Hardening
  17610. */
  17611. static readonly FILTER_PCSS: number;
  17612. /**
  17613. * Reserved for PCF and PCSS
  17614. * Highest Quality.
  17615. *
  17616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17617. *
  17618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17619. */
  17620. static readonly QUALITY_HIGH: number;
  17621. /**
  17622. * Reserved for PCF and PCSS
  17623. * Good tradeoff for quality/perf cross devices
  17624. *
  17625. * Execute PCF on a 3*3 kernel.
  17626. *
  17627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17628. */
  17629. static readonly QUALITY_MEDIUM: number;
  17630. /**
  17631. * Reserved for PCF and PCSS
  17632. * The lowest quality but the fastest.
  17633. *
  17634. * Execute PCF on a 1*1 kernel.
  17635. *
  17636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17637. */
  17638. static readonly QUALITY_LOW: number;
  17639. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17640. id: string;
  17641. /** Gets or sets the custom shader name to use */
  17642. customShaderOptions: ICustomShaderOptions;
  17643. /**
  17644. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17645. */
  17646. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17647. /**
  17648. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17649. */
  17650. onAfterShadowMapRenderObservable: Observable<Effect>;
  17651. /**
  17652. * Observable triggered before a mesh is rendered in the shadow map.
  17653. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17654. */
  17655. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17656. /**
  17657. * Observable triggered after a mesh is rendered in the shadow map.
  17658. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17659. */
  17660. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17661. protected _bias: number;
  17662. /**
  17663. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17664. */
  17665. get bias(): number;
  17666. /**
  17667. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17668. */
  17669. set bias(bias: number);
  17670. protected _normalBias: number;
  17671. /**
  17672. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17673. */
  17674. get normalBias(): number;
  17675. /**
  17676. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17677. */
  17678. set normalBias(normalBias: number);
  17679. protected _blurBoxOffset: number;
  17680. /**
  17681. * Gets the blur box offset: offset applied during the blur pass.
  17682. * Only useful if useKernelBlur = false
  17683. */
  17684. get blurBoxOffset(): number;
  17685. /**
  17686. * Sets the blur box offset: offset applied during the blur pass.
  17687. * Only useful if useKernelBlur = false
  17688. */
  17689. set blurBoxOffset(value: number);
  17690. protected _blurScale: number;
  17691. /**
  17692. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17693. * 2 means half of the size.
  17694. */
  17695. get blurScale(): number;
  17696. /**
  17697. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17698. * 2 means half of the size.
  17699. */
  17700. set blurScale(value: number);
  17701. protected _blurKernel: number;
  17702. /**
  17703. * Gets the blur kernel: kernel size of the blur pass.
  17704. * Only useful if useKernelBlur = true
  17705. */
  17706. get blurKernel(): number;
  17707. /**
  17708. * Sets the blur kernel: kernel size of the blur pass.
  17709. * Only useful if useKernelBlur = true
  17710. */
  17711. set blurKernel(value: number);
  17712. protected _useKernelBlur: boolean;
  17713. /**
  17714. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17715. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17716. */
  17717. get useKernelBlur(): boolean;
  17718. /**
  17719. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17720. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17721. */
  17722. set useKernelBlur(value: boolean);
  17723. protected _depthScale: number;
  17724. /**
  17725. * Gets the depth scale used in ESM mode.
  17726. */
  17727. get depthScale(): number;
  17728. /**
  17729. * Sets the depth scale used in ESM mode.
  17730. * This can override the scale stored on the light.
  17731. */
  17732. set depthScale(value: number);
  17733. protected _validateFilter(filter: number): number;
  17734. protected _filter: number;
  17735. /**
  17736. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17737. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17738. */
  17739. get filter(): number;
  17740. /**
  17741. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17742. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17743. */
  17744. set filter(value: number);
  17745. /**
  17746. * Gets if the current filter is set to Poisson Sampling.
  17747. */
  17748. get usePoissonSampling(): boolean;
  17749. /**
  17750. * Sets the current filter to Poisson Sampling.
  17751. */
  17752. set usePoissonSampling(value: boolean);
  17753. /**
  17754. * Gets if the current filter is set to ESM.
  17755. */
  17756. get useExponentialShadowMap(): boolean;
  17757. /**
  17758. * Sets the current filter is to ESM.
  17759. */
  17760. set useExponentialShadowMap(value: boolean);
  17761. /**
  17762. * Gets if the current filter is set to filtered ESM.
  17763. */
  17764. get useBlurExponentialShadowMap(): boolean;
  17765. /**
  17766. * Gets if the current filter is set to filtered ESM.
  17767. */
  17768. set useBlurExponentialShadowMap(value: boolean);
  17769. /**
  17770. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17771. * exponential to prevent steep falloff artifacts).
  17772. */
  17773. get useCloseExponentialShadowMap(): boolean;
  17774. /**
  17775. * Sets the current filter to "close ESM" (using the inverse of the
  17776. * exponential to prevent steep falloff artifacts).
  17777. */
  17778. set useCloseExponentialShadowMap(value: boolean);
  17779. /**
  17780. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17781. * exponential to prevent steep falloff artifacts).
  17782. */
  17783. get useBlurCloseExponentialShadowMap(): boolean;
  17784. /**
  17785. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17786. * exponential to prevent steep falloff artifacts).
  17787. */
  17788. set useBlurCloseExponentialShadowMap(value: boolean);
  17789. /**
  17790. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17791. */
  17792. get usePercentageCloserFiltering(): boolean;
  17793. /**
  17794. * Sets the current filter to "PCF" (percentage closer filtering).
  17795. */
  17796. set usePercentageCloserFiltering(value: boolean);
  17797. protected _filteringQuality: number;
  17798. /**
  17799. * Gets the PCF or PCSS Quality.
  17800. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17801. */
  17802. get filteringQuality(): number;
  17803. /**
  17804. * Sets the PCF or PCSS Quality.
  17805. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17806. */
  17807. set filteringQuality(filteringQuality: number);
  17808. /**
  17809. * Gets if the current filter is set to "PCSS" (contact hardening).
  17810. */
  17811. get useContactHardeningShadow(): boolean;
  17812. /**
  17813. * Sets the current filter to "PCSS" (contact hardening).
  17814. */
  17815. set useContactHardeningShadow(value: boolean);
  17816. protected _contactHardeningLightSizeUVRatio: number;
  17817. /**
  17818. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17819. * Using a ratio helps keeping shape stability independently of the map size.
  17820. *
  17821. * It does not account for the light projection as it was having too much
  17822. * instability during the light setup or during light position changes.
  17823. *
  17824. * Only valid if useContactHardeningShadow is true.
  17825. */
  17826. get contactHardeningLightSizeUVRatio(): number;
  17827. /**
  17828. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17829. * Using a ratio helps keeping shape stability independently of the map size.
  17830. *
  17831. * It does not account for the light projection as it was having too much
  17832. * instability during the light setup or during light position changes.
  17833. *
  17834. * Only valid if useContactHardeningShadow is true.
  17835. */
  17836. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17837. protected _darkness: number;
  17838. /** Gets or sets the actual darkness of a shadow */
  17839. get darkness(): number;
  17840. set darkness(value: number);
  17841. /**
  17842. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17843. * 0 means strongest and 1 would means no shadow.
  17844. * @returns the darkness.
  17845. */
  17846. getDarkness(): number;
  17847. /**
  17848. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17849. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17850. * @returns the shadow generator allowing fluent coding.
  17851. */
  17852. setDarkness(darkness: number): ShadowGenerator;
  17853. protected _transparencyShadow: boolean;
  17854. /** Gets or sets the ability to have transparent shadow */
  17855. get transparencyShadow(): boolean;
  17856. set transparencyShadow(value: boolean);
  17857. /**
  17858. * Sets the ability to have transparent shadow (boolean).
  17859. * @param transparent True if transparent else False
  17860. * @returns the shadow generator allowing fluent coding
  17861. */
  17862. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17863. /**
  17864. * Enables or disables shadows with varying strength based on the transparency
  17865. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17866. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17867. * mesh.visibility * alphaTexture.a
  17868. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17869. */
  17870. enableSoftTransparentShadow: boolean;
  17871. protected _shadowMap: Nullable<RenderTargetTexture>;
  17872. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17873. /**
  17874. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17875. * @returns The render target texture if present otherwise, null
  17876. */
  17877. getShadowMap(): Nullable<RenderTargetTexture>;
  17878. /**
  17879. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17880. * @returns The render target texture if the shadow map is present otherwise, null
  17881. */
  17882. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17883. /**
  17884. * Gets the class name of that object
  17885. * @returns "ShadowGenerator"
  17886. */
  17887. getClassName(): string;
  17888. /**
  17889. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17890. * @param mesh Mesh to add
  17891. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17892. * @returns the Shadow Generator itself
  17893. */
  17894. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17895. /**
  17896. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17897. * @param mesh Mesh to remove
  17898. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17899. * @returns the Shadow Generator itself
  17900. */
  17901. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17902. /**
  17903. * Controls the extent to which the shadows fade out at the edge of the frustum
  17904. */
  17905. frustumEdgeFalloff: number;
  17906. protected _light: IShadowLight;
  17907. /**
  17908. * Returns the associated light object.
  17909. * @returns the light generating the shadow
  17910. */
  17911. getLight(): IShadowLight;
  17912. /**
  17913. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17914. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17915. * It might on the other hand introduce peter panning.
  17916. */
  17917. forceBackFacesOnly: boolean;
  17918. protected _scene: Scene;
  17919. protected _lightDirection: Vector3;
  17920. protected _effect: Effect;
  17921. protected _viewMatrix: Matrix;
  17922. protected _projectionMatrix: Matrix;
  17923. protected _transformMatrix: Matrix;
  17924. protected _cachedPosition: Vector3;
  17925. protected _cachedDirection: Vector3;
  17926. protected _cachedDefines: string;
  17927. protected _currentRenderID: number;
  17928. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17929. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17930. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17931. protected _blurPostProcesses: PostProcess[];
  17932. protected _mapSize: number;
  17933. protected _currentFaceIndex: number;
  17934. protected _currentFaceIndexCache: number;
  17935. protected _textureType: number;
  17936. protected _defaultTextureMatrix: Matrix;
  17937. protected _storedUniqueId: Nullable<number>;
  17938. /** @hidden */
  17939. static _SceneComponentInitialization: (scene: Scene) => void;
  17940. /**
  17941. * Creates a ShadowGenerator object.
  17942. * A ShadowGenerator is the required tool to use the shadows.
  17943. * Each light casting shadows needs to use its own ShadowGenerator.
  17944. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17945. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17946. * @param light The light object generating the shadows.
  17947. * @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.
  17948. */
  17949. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17950. protected _initializeGenerator(): void;
  17951. protected _createTargetRenderTexture(): void;
  17952. protected _initializeShadowMap(): void;
  17953. protected _initializeBlurRTTAndPostProcesses(): void;
  17954. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17955. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17956. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17957. protected _applyFilterValues(): void;
  17958. /**
  17959. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17960. * @param onCompiled Callback triggered at the and of the effects compilation
  17961. * @param options Sets of optional options forcing the compilation with different modes
  17962. */
  17963. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17964. useInstances: boolean;
  17965. }>): void;
  17966. /**
  17967. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17968. * @param options Sets of optional options forcing the compilation with different modes
  17969. * @returns A promise that resolves when the compilation completes
  17970. */
  17971. forceCompilationAsync(options?: Partial<{
  17972. useInstances: boolean;
  17973. }>): Promise<void>;
  17974. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17975. private _prepareShadowDefines;
  17976. /**
  17977. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17978. * @param subMesh The submesh we want to render in the shadow map
  17979. * @param useInstances Defines wether will draw in the map using instances
  17980. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17981. * @returns true if ready otherwise, false
  17982. */
  17983. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17984. /**
  17985. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17986. * @param defines Defines of the material we want to update
  17987. * @param lightIndex Index of the light in the enabled light list of the material
  17988. */
  17989. prepareDefines(defines: any, lightIndex: number): void;
  17990. /**
  17991. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17992. * defined in the generator but impacting the effect).
  17993. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17994. * @param effect The effect we are binfing the information for
  17995. */
  17996. bindShadowLight(lightIndex: string, effect: Effect): void;
  17997. /**
  17998. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17999. * (eq to shadow prjection matrix * light transform matrix)
  18000. * @returns The transform matrix used to create the shadow map
  18001. */
  18002. getTransformMatrix(): Matrix;
  18003. /**
  18004. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18005. * Cube and 2D textures for instance.
  18006. */
  18007. recreateShadowMap(): void;
  18008. protected _disposeBlurPostProcesses(): void;
  18009. protected _disposeRTTandPostProcesses(): void;
  18010. /**
  18011. * Disposes the ShadowGenerator.
  18012. * Returns nothing.
  18013. */
  18014. dispose(): void;
  18015. /**
  18016. * Serializes the shadow generator setup to a json object.
  18017. * @returns The serialized JSON object
  18018. */
  18019. serialize(): any;
  18020. /**
  18021. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18022. * @param parsedShadowGenerator The JSON object to parse
  18023. * @param scene The scene to create the shadow map for
  18024. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18025. * @returns The parsed shadow generator
  18026. */
  18027. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18028. }
  18029. }
  18030. declare module BABYLON {
  18031. /**
  18032. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18033. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18034. * 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.
  18035. */
  18036. export abstract class Light extends Node {
  18037. /**
  18038. * Falloff Default: light is falling off following the material specification:
  18039. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18040. */
  18041. static readonly FALLOFF_DEFAULT: number;
  18042. /**
  18043. * Falloff Physical: light is falling off following the inverse squared distance law.
  18044. */
  18045. static readonly FALLOFF_PHYSICAL: number;
  18046. /**
  18047. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18048. * to enhance interoperability with other engines.
  18049. */
  18050. static readonly FALLOFF_GLTF: number;
  18051. /**
  18052. * Falloff Standard: light is falling off like in the standard material
  18053. * to enhance interoperability with other materials.
  18054. */
  18055. static readonly FALLOFF_STANDARD: number;
  18056. /**
  18057. * If every light affecting the material is in this lightmapMode,
  18058. * material.lightmapTexture adds or multiplies
  18059. * (depends on material.useLightmapAsShadowmap)
  18060. * after every other light calculations.
  18061. */
  18062. static readonly LIGHTMAP_DEFAULT: number;
  18063. /**
  18064. * material.lightmapTexture as only diffuse lighting from this light
  18065. * adds only specular lighting from this light
  18066. * adds dynamic shadows
  18067. */
  18068. static readonly LIGHTMAP_SPECULAR: number;
  18069. /**
  18070. * material.lightmapTexture as only lighting
  18071. * no light calculation from this light
  18072. * only adds dynamic shadows from this light
  18073. */
  18074. static readonly LIGHTMAP_SHADOWSONLY: number;
  18075. /**
  18076. * Each light type uses the default quantity according to its type:
  18077. * point/spot lights use luminous intensity
  18078. * directional lights use illuminance
  18079. */
  18080. static readonly INTENSITYMODE_AUTOMATIC: number;
  18081. /**
  18082. * lumen (lm)
  18083. */
  18084. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18085. /**
  18086. * candela (lm/sr)
  18087. */
  18088. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18089. /**
  18090. * lux (lm/m^2)
  18091. */
  18092. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18093. /**
  18094. * nit (cd/m^2)
  18095. */
  18096. static readonly INTENSITYMODE_LUMINANCE: number;
  18097. /**
  18098. * Light type const id of the point light.
  18099. */
  18100. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18101. /**
  18102. * Light type const id of the directional light.
  18103. */
  18104. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18105. /**
  18106. * Light type const id of the spot light.
  18107. */
  18108. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18109. /**
  18110. * Light type const id of the hemispheric light.
  18111. */
  18112. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18113. /**
  18114. * Diffuse gives the basic color to an object.
  18115. */
  18116. diffuse: Color3;
  18117. /**
  18118. * Specular produces a highlight color on an object.
  18119. * Note: This is note affecting PBR materials.
  18120. */
  18121. specular: Color3;
  18122. /**
  18123. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18124. * falling off base on range or angle.
  18125. * This can be set to any values in Light.FALLOFF_x.
  18126. *
  18127. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18128. * other types of materials.
  18129. */
  18130. falloffType: number;
  18131. /**
  18132. * Strength of the light.
  18133. * Note: By default it is define in the framework own unit.
  18134. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18135. */
  18136. intensity: number;
  18137. private _range;
  18138. protected _inverseSquaredRange: number;
  18139. /**
  18140. * Defines how far from the source the light is impacting in scene units.
  18141. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18142. */
  18143. get range(): number;
  18144. /**
  18145. * Defines how far from the source the light is impacting in scene units.
  18146. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18147. */
  18148. set range(value: number);
  18149. /**
  18150. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18151. * of light.
  18152. */
  18153. private _photometricScale;
  18154. private _intensityMode;
  18155. /**
  18156. * Gets the photometric scale used to interpret the intensity.
  18157. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18158. */
  18159. get intensityMode(): number;
  18160. /**
  18161. * Sets the photometric scale used to interpret the intensity.
  18162. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18163. */
  18164. set intensityMode(value: number);
  18165. private _radius;
  18166. /**
  18167. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18168. */
  18169. get radius(): number;
  18170. /**
  18171. * sets the light radius used by PBR Materials to simulate soft area lights.
  18172. */
  18173. set radius(value: number);
  18174. private _renderPriority;
  18175. /**
  18176. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18177. * exceeding the number allowed of the materials.
  18178. */
  18179. renderPriority: number;
  18180. private _shadowEnabled;
  18181. /**
  18182. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18183. * the current shadow generator.
  18184. */
  18185. get shadowEnabled(): boolean;
  18186. /**
  18187. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18188. * the current shadow generator.
  18189. */
  18190. set shadowEnabled(value: boolean);
  18191. private _includedOnlyMeshes;
  18192. /**
  18193. * Gets the only meshes impacted by this light.
  18194. */
  18195. get includedOnlyMeshes(): AbstractMesh[];
  18196. /**
  18197. * Sets the only meshes impacted by this light.
  18198. */
  18199. set includedOnlyMeshes(value: AbstractMesh[]);
  18200. private _excludedMeshes;
  18201. /**
  18202. * Gets the meshes not impacted by this light.
  18203. */
  18204. get excludedMeshes(): AbstractMesh[];
  18205. /**
  18206. * Sets the meshes not impacted by this light.
  18207. */
  18208. set excludedMeshes(value: AbstractMesh[]);
  18209. private _excludeWithLayerMask;
  18210. /**
  18211. * Gets the layer id use to find what meshes are not impacted by the light.
  18212. * Inactive if 0
  18213. */
  18214. get excludeWithLayerMask(): number;
  18215. /**
  18216. * Sets the layer id use to find what meshes are not impacted by the light.
  18217. * Inactive if 0
  18218. */
  18219. set excludeWithLayerMask(value: number);
  18220. private _includeOnlyWithLayerMask;
  18221. /**
  18222. * Gets the layer id use to find what meshes are impacted by the light.
  18223. * Inactive if 0
  18224. */
  18225. get includeOnlyWithLayerMask(): number;
  18226. /**
  18227. * Sets the layer id use to find what meshes are impacted by the light.
  18228. * Inactive if 0
  18229. */
  18230. set includeOnlyWithLayerMask(value: number);
  18231. private _lightmapMode;
  18232. /**
  18233. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18234. */
  18235. get lightmapMode(): number;
  18236. /**
  18237. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18238. */
  18239. set lightmapMode(value: number);
  18240. /**
  18241. * Shadow generator associted to the light.
  18242. * @hidden Internal use only.
  18243. */
  18244. _shadowGenerator: Nullable<IShadowGenerator>;
  18245. /**
  18246. * @hidden Internal use only.
  18247. */
  18248. _excludedMeshesIds: string[];
  18249. /**
  18250. * @hidden Internal use only.
  18251. */
  18252. _includedOnlyMeshesIds: string[];
  18253. /**
  18254. * The current light unifom buffer.
  18255. * @hidden Internal use only.
  18256. */
  18257. _uniformBuffer: UniformBuffer;
  18258. /** @hidden */
  18259. _renderId: number;
  18260. /**
  18261. * Creates a Light object in the scene.
  18262. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18263. * @param name The firendly name of the light
  18264. * @param scene The scene the light belongs too
  18265. */
  18266. constructor(name: string, scene: Scene);
  18267. protected abstract _buildUniformLayout(): void;
  18268. /**
  18269. * Sets the passed Effect "effect" with the Light information.
  18270. * @param effect The effect to update
  18271. * @param lightIndex The index of the light in the effect to update
  18272. * @returns The light
  18273. */
  18274. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18275. /**
  18276. * Sets the passed Effect "effect" with the Light textures.
  18277. * @param effect The effect to update
  18278. * @param lightIndex The index of the light in the effect to update
  18279. * @returns The light
  18280. */
  18281. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18282. /**
  18283. * Binds the lights information from the scene to the effect for the given mesh.
  18284. * @param lightIndex Light index
  18285. * @param scene The scene where the light belongs to
  18286. * @param effect The effect we are binding the data to
  18287. * @param useSpecular Defines if specular is supported
  18288. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18289. */
  18290. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18291. /**
  18292. * Sets the passed Effect "effect" with the Light information.
  18293. * @param effect The effect to update
  18294. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18295. * @returns The light
  18296. */
  18297. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18298. /**
  18299. * Returns the string "Light".
  18300. * @returns the class name
  18301. */
  18302. getClassName(): string;
  18303. /** @hidden */
  18304. readonly _isLight: boolean;
  18305. /**
  18306. * Converts the light information to a readable string for debug purpose.
  18307. * @param fullDetails Supports for multiple levels of logging within scene loading
  18308. * @returns the human readable light info
  18309. */
  18310. toString(fullDetails?: boolean): string;
  18311. /** @hidden */
  18312. protected _syncParentEnabledState(): void;
  18313. /**
  18314. * Set the enabled state of this node.
  18315. * @param value - the new enabled state
  18316. */
  18317. setEnabled(value: boolean): void;
  18318. /**
  18319. * Returns the Light associated shadow generator if any.
  18320. * @return the associated shadow generator.
  18321. */
  18322. getShadowGenerator(): Nullable<IShadowGenerator>;
  18323. /**
  18324. * Returns a Vector3, the absolute light position in the World.
  18325. * @returns the world space position of the light
  18326. */
  18327. getAbsolutePosition(): Vector3;
  18328. /**
  18329. * Specifies if the light will affect the passed mesh.
  18330. * @param mesh The mesh to test against the light
  18331. * @return true the mesh is affected otherwise, false.
  18332. */
  18333. canAffectMesh(mesh: AbstractMesh): boolean;
  18334. /**
  18335. * Sort function to order lights for rendering.
  18336. * @param a First Light object to compare to second.
  18337. * @param b Second Light object to compare first.
  18338. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18339. */
  18340. static CompareLightsPriority(a: Light, b: Light): number;
  18341. /**
  18342. * Releases resources associated with this node.
  18343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18345. */
  18346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18347. /**
  18348. * Returns the light type ID (integer).
  18349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18350. */
  18351. getTypeID(): number;
  18352. /**
  18353. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18354. * @returns the scaled intensity in intensity mode unit
  18355. */
  18356. getScaledIntensity(): number;
  18357. /**
  18358. * Returns a new Light object, named "name", from the current one.
  18359. * @param name The name of the cloned light
  18360. * @param newParent The parent of this light, if it has one
  18361. * @returns the new created light
  18362. */
  18363. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18364. /**
  18365. * Serializes the current light into a Serialization object.
  18366. * @returns the serialized object.
  18367. */
  18368. serialize(): any;
  18369. /**
  18370. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18371. * This new light is named "name" and added to the passed scene.
  18372. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18373. * @param name The friendly name of the light
  18374. * @param scene The scene the new light will belong to
  18375. * @returns the constructor function
  18376. */
  18377. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18378. /**
  18379. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18380. * @param parsedLight The JSON representation of the light
  18381. * @param scene The scene to create the parsed light in
  18382. * @returns the created light after parsing
  18383. */
  18384. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18385. private _hookArrayForExcluded;
  18386. private _hookArrayForIncludedOnly;
  18387. private _resyncMeshes;
  18388. /**
  18389. * Forces the meshes to update their light related information in their rendering used effects
  18390. * @hidden Internal Use Only
  18391. */
  18392. _markMeshesAsLightDirty(): void;
  18393. /**
  18394. * Recomputes the cached photometric scale if needed.
  18395. */
  18396. private _computePhotometricScale;
  18397. /**
  18398. * Returns the Photometric Scale according to the light type and intensity mode.
  18399. */
  18400. private _getPhotometricScale;
  18401. /**
  18402. * Reorder the light in the scene according to their defined priority.
  18403. * @hidden Internal Use Only
  18404. */
  18405. _reorderLightsInScene(): void;
  18406. /**
  18407. * Prepares the list of defines specific to the light type.
  18408. * @param defines the list of defines
  18409. * @param lightIndex defines the index of the light for the effect
  18410. */
  18411. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18412. }
  18413. }
  18414. declare module BABYLON {
  18415. /**
  18416. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18417. * This is the base of the follow, arc rotate cameras and Free camera
  18418. * @see https://doc.babylonjs.com/features/cameras
  18419. */
  18420. export class TargetCamera extends Camera {
  18421. private static _RigCamTransformMatrix;
  18422. private static _TargetTransformMatrix;
  18423. private static _TargetFocalPoint;
  18424. private _tmpUpVector;
  18425. private _tmpTargetVector;
  18426. /**
  18427. * Define the current direction the camera is moving to
  18428. */
  18429. cameraDirection: Vector3;
  18430. /**
  18431. * Define the current rotation the camera is rotating to
  18432. */
  18433. cameraRotation: Vector2;
  18434. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18435. ignoreParentScaling: boolean;
  18436. /**
  18437. * When set, the up vector of the camera will be updated by the rotation of the camera
  18438. */
  18439. updateUpVectorFromRotation: boolean;
  18440. private _tmpQuaternion;
  18441. /**
  18442. * Define the current rotation of the camera
  18443. */
  18444. rotation: Vector3;
  18445. /**
  18446. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18447. */
  18448. rotationQuaternion: Quaternion;
  18449. /**
  18450. * Define the current speed of the camera
  18451. */
  18452. speed: number;
  18453. /**
  18454. * Add constraint to the camera to prevent it to move freely in all directions and
  18455. * around all axis.
  18456. */
  18457. noRotationConstraint: boolean;
  18458. /**
  18459. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18460. * panning
  18461. */
  18462. invertRotation: boolean;
  18463. /**
  18464. * Speed multiplier for inverse camera panning
  18465. */
  18466. inverseRotationSpeed: number;
  18467. /**
  18468. * Define the current target of the camera as an object or a position.
  18469. */
  18470. lockedTarget: any;
  18471. /** @hidden */
  18472. _currentTarget: Vector3;
  18473. /** @hidden */
  18474. _initialFocalDistance: number;
  18475. /** @hidden */
  18476. _viewMatrix: Matrix;
  18477. /** @hidden */
  18478. _camMatrix: Matrix;
  18479. /** @hidden */
  18480. _cameraTransformMatrix: Matrix;
  18481. /** @hidden */
  18482. _cameraRotationMatrix: Matrix;
  18483. /** @hidden */
  18484. _referencePoint: Vector3;
  18485. /** @hidden */
  18486. _transformedReferencePoint: Vector3;
  18487. /** @hidden */
  18488. _reset: () => void;
  18489. private _defaultUp;
  18490. /**
  18491. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18492. * This is the base of the follow, arc rotate cameras and Free camera
  18493. * @see https://doc.babylonjs.com/features/cameras
  18494. * @param name Defines the name of the camera in the scene
  18495. * @param position Defines the start position of the camera in the scene
  18496. * @param scene Defines the scene the camera belongs to
  18497. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18498. */
  18499. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18500. /**
  18501. * Gets the position in front of the camera at a given distance.
  18502. * @param distance The distance from the camera we want the position to be
  18503. * @returns the position
  18504. */
  18505. getFrontPosition(distance: number): Vector3;
  18506. /** @hidden */
  18507. _getLockedTargetPosition(): Nullable<Vector3>;
  18508. private _storedPosition;
  18509. private _storedRotation;
  18510. private _storedRotationQuaternion;
  18511. /**
  18512. * Store current camera state of the camera (fov, position, rotation, etc..)
  18513. * @returns the camera
  18514. */
  18515. storeState(): Camera;
  18516. /**
  18517. * Restored camera state. You must call storeState() first
  18518. * @returns whether it was successful or not
  18519. * @hidden
  18520. */
  18521. _restoreStateValues(): boolean;
  18522. /** @hidden */
  18523. _initCache(): void;
  18524. /** @hidden */
  18525. _updateCache(ignoreParentClass?: boolean): void;
  18526. /** @hidden */
  18527. _isSynchronizedViewMatrix(): boolean;
  18528. /** @hidden */
  18529. _computeLocalCameraSpeed(): number;
  18530. /**
  18531. * Defines the target the camera should look at.
  18532. * @param target Defines the new target as a Vector or a mesh
  18533. */
  18534. setTarget(target: Vector3): void;
  18535. /**
  18536. * Defines the target point of the camera.
  18537. * The camera looks towards it form the radius distance.
  18538. */
  18539. get target(): Vector3;
  18540. set target(value: Vector3);
  18541. /**
  18542. * Return the current target position of the camera. This value is expressed in local space.
  18543. * @returns the target position
  18544. */
  18545. getTarget(): Vector3;
  18546. /** @hidden */
  18547. _decideIfNeedsToMove(): boolean;
  18548. /** @hidden */
  18549. _updatePosition(): void;
  18550. /** @hidden */
  18551. _checkInputs(): void;
  18552. protected _updateCameraRotationMatrix(): void;
  18553. /**
  18554. * 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)
  18555. * @returns the current camera
  18556. */
  18557. private _rotateUpVectorWithCameraRotationMatrix;
  18558. private _cachedRotationZ;
  18559. private _cachedQuaternionRotationZ;
  18560. /** @hidden */
  18561. _getViewMatrix(): Matrix;
  18562. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18563. /**
  18564. * @hidden
  18565. */
  18566. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18567. /**
  18568. * @hidden
  18569. */
  18570. _updateRigCameras(): void;
  18571. private _getRigCamPositionAndTarget;
  18572. /**
  18573. * Gets the current object class name.
  18574. * @return the class name
  18575. */
  18576. getClassName(): string;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Gather the list of keyboard event types as constants.
  18582. */
  18583. export class KeyboardEventTypes {
  18584. /**
  18585. * The keydown event is fired when a key becomes active (pressed).
  18586. */
  18587. static readonly KEYDOWN: number;
  18588. /**
  18589. * The keyup event is fired when a key has been released.
  18590. */
  18591. static readonly KEYUP: number;
  18592. }
  18593. /**
  18594. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18595. */
  18596. export class KeyboardInfo {
  18597. /**
  18598. * Defines the type of event (KeyboardEventTypes)
  18599. */
  18600. type: number;
  18601. /**
  18602. * Defines the related dom event
  18603. */
  18604. event: KeyboardEvent;
  18605. /**
  18606. * Instantiates a new keyboard info.
  18607. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18608. * @param type Defines the type of event (KeyboardEventTypes)
  18609. * @param event Defines the related dom event
  18610. */
  18611. constructor(
  18612. /**
  18613. * Defines the type of event (KeyboardEventTypes)
  18614. */
  18615. type: number,
  18616. /**
  18617. * Defines the related dom event
  18618. */
  18619. event: KeyboardEvent);
  18620. }
  18621. /**
  18622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18623. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18624. */
  18625. export class KeyboardInfoPre extends KeyboardInfo {
  18626. /**
  18627. * Defines the type of event (KeyboardEventTypes)
  18628. */
  18629. type: number;
  18630. /**
  18631. * Defines the related dom event
  18632. */
  18633. event: KeyboardEvent;
  18634. /**
  18635. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18636. */
  18637. skipOnPointerObservable: boolean;
  18638. /**
  18639. * Instantiates a new keyboard pre info.
  18640. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18641. * @param type Defines the type of event (KeyboardEventTypes)
  18642. * @param event Defines the related dom event
  18643. */
  18644. constructor(
  18645. /**
  18646. * Defines the type of event (KeyboardEventTypes)
  18647. */
  18648. type: number,
  18649. /**
  18650. * Defines the related dom event
  18651. */
  18652. event: KeyboardEvent);
  18653. }
  18654. }
  18655. declare module BABYLON {
  18656. /**
  18657. * Manage the keyboard inputs to control the movement of a free camera.
  18658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18659. */
  18660. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18661. /**
  18662. * Defines the camera the input is attached to.
  18663. */
  18664. camera: FreeCamera;
  18665. /**
  18666. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18667. */
  18668. keysUp: number[];
  18669. /**
  18670. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18671. */
  18672. keysUpward: number[];
  18673. /**
  18674. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18675. */
  18676. keysDown: number[];
  18677. /**
  18678. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18679. */
  18680. keysDownward: number[];
  18681. /**
  18682. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18683. */
  18684. keysLeft: number[];
  18685. /**
  18686. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18687. */
  18688. keysRight: number[];
  18689. private _keys;
  18690. private _onCanvasBlurObserver;
  18691. private _onKeyboardObserver;
  18692. private _engine;
  18693. private _scene;
  18694. /**
  18695. * Attach the input controls to a specific dom element to get the input from.
  18696. * @param element Defines the element the controls should be listened from
  18697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18698. */
  18699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18700. /**
  18701. * Detach the current controls from the specified dom element.
  18702. * @param element Defines the element to stop listening the inputs from
  18703. */
  18704. detachControl(element: Nullable<HTMLElement>): void;
  18705. /**
  18706. * Update the current camera state depending on the inputs that have been used this frame.
  18707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18708. */
  18709. checkInputs(): void;
  18710. /**
  18711. * Gets the class name of the current intput.
  18712. * @returns the class name
  18713. */
  18714. getClassName(): string;
  18715. /** @hidden */
  18716. _onLostFocus(): void;
  18717. /**
  18718. * Get the friendly name associated with the input class.
  18719. * @returns the input friendly name
  18720. */
  18721. getSimpleName(): string;
  18722. }
  18723. }
  18724. declare module BABYLON {
  18725. /**
  18726. * Gather the list of pointer event types as constants.
  18727. */
  18728. export class PointerEventTypes {
  18729. /**
  18730. * 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.
  18731. */
  18732. static readonly POINTERDOWN: number;
  18733. /**
  18734. * The pointerup event is fired when a pointer is no longer active.
  18735. */
  18736. static readonly POINTERUP: number;
  18737. /**
  18738. * The pointermove event is fired when a pointer changes coordinates.
  18739. */
  18740. static readonly POINTERMOVE: number;
  18741. /**
  18742. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18743. */
  18744. static readonly POINTERWHEEL: number;
  18745. /**
  18746. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18747. */
  18748. static readonly POINTERPICK: number;
  18749. /**
  18750. * The pointertap event is fired when a the object has been touched and released without drag.
  18751. */
  18752. static readonly POINTERTAP: number;
  18753. /**
  18754. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18755. */
  18756. static readonly POINTERDOUBLETAP: number;
  18757. }
  18758. /**
  18759. * Base class of pointer info types.
  18760. */
  18761. export class PointerInfoBase {
  18762. /**
  18763. * Defines the type of event (PointerEventTypes)
  18764. */
  18765. type: number;
  18766. /**
  18767. * Defines the related dom event
  18768. */
  18769. event: PointerEvent | MouseWheelEvent;
  18770. /**
  18771. * Instantiates the base class of pointers info.
  18772. * @param type Defines the type of event (PointerEventTypes)
  18773. * @param event Defines the related dom event
  18774. */
  18775. constructor(
  18776. /**
  18777. * Defines the type of event (PointerEventTypes)
  18778. */
  18779. type: number,
  18780. /**
  18781. * Defines the related dom event
  18782. */
  18783. event: PointerEvent | MouseWheelEvent);
  18784. }
  18785. /**
  18786. * This class is used to store pointer related info for the onPrePointerObservable event.
  18787. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18788. */
  18789. export class PointerInfoPre extends PointerInfoBase {
  18790. /**
  18791. * Ray from a pointer if availible (eg. 6dof controller)
  18792. */
  18793. ray: Nullable<Ray>;
  18794. /**
  18795. * Defines the local position of the pointer on the canvas.
  18796. */
  18797. localPosition: Vector2;
  18798. /**
  18799. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18800. */
  18801. skipOnPointerObservable: boolean;
  18802. /**
  18803. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18804. * @param type Defines the type of event (PointerEventTypes)
  18805. * @param event Defines the related dom event
  18806. * @param localX Defines the local x coordinates of the pointer when the event occured
  18807. * @param localY Defines the local y coordinates of the pointer when the event occured
  18808. */
  18809. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18810. }
  18811. /**
  18812. * This type contains all the data related to a pointer event in Babylon.js.
  18813. * 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.
  18814. */
  18815. export class PointerInfo extends PointerInfoBase {
  18816. /**
  18817. * Defines the picking info associated to the info (if any)\
  18818. */
  18819. pickInfo: Nullable<PickingInfo>;
  18820. /**
  18821. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18822. * @param type Defines the type of event (PointerEventTypes)
  18823. * @param event Defines the related dom event
  18824. * @param pickInfo Defines the picking info associated to the info (if any)\
  18825. */
  18826. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18827. /**
  18828. * Defines the picking info associated to the info (if any)\
  18829. */
  18830. pickInfo: Nullable<PickingInfo>);
  18831. }
  18832. /**
  18833. * Data relating to a touch event on the screen.
  18834. */
  18835. export interface PointerTouch {
  18836. /**
  18837. * X coordinate of touch.
  18838. */
  18839. x: number;
  18840. /**
  18841. * Y coordinate of touch.
  18842. */
  18843. y: number;
  18844. /**
  18845. * Id of touch. Unique for each finger.
  18846. */
  18847. pointerId: number;
  18848. /**
  18849. * Event type passed from DOM.
  18850. */
  18851. type: any;
  18852. }
  18853. }
  18854. declare module BABYLON {
  18855. /**
  18856. * Manage the mouse inputs to control the movement of a free camera.
  18857. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18858. */
  18859. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18860. /**
  18861. * Define if touch is enabled in the mouse input
  18862. */
  18863. touchEnabled: boolean;
  18864. /**
  18865. * Defines the camera the input is attached to.
  18866. */
  18867. camera: FreeCamera;
  18868. /**
  18869. * Defines the buttons associated with the input to handle camera move.
  18870. */
  18871. buttons: number[];
  18872. /**
  18873. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18874. */
  18875. angularSensibility: number;
  18876. private _pointerInput;
  18877. private _onMouseMove;
  18878. private _observer;
  18879. private previousPosition;
  18880. /**
  18881. * Observable for when a pointer move event occurs containing the move offset
  18882. */
  18883. onPointerMovedObservable: Observable<{
  18884. offsetX: number;
  18885. offsetY: number;
  18886. }>;
  18887. /**
  18888. * @hidden
  18889. * If the camera should be rotated automatically based on pointer movement
  18890. */
  18891. _allowCameraRotation: boolean;
  18892. /**
  18893. * Manage the mouse inputs to control the movement of a free camera.
  18894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18895. * @param touchEnabled Defines if touch is enabled or not
  18896. */
  18897. constructor(
  18898. /**
  18899. * Define if touch is enabled in the mouse input
  18900. */
  18901. touchEnabled?: boolean);
  18902. /**
  18903. * Attach the input controls to a specific dom element to get the input from.
  18904. * @param element Defines the element the controls should be listened from
  18905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18906. */
  18907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18908. /**
  18909. * Called on JS contextmenu event.
  18910. * Override this method to provide functionality.
  18911. */
  18912. protected onContextMenu(evt: PointerEvent): void;
  18913. /**
  18914. * Detach the current controls from the specified dom element.
  18915. * @param element Defines the element to stop listening the inputs from
  18916. */
  18917. detachControl(element: Nullable<HTMLElement>): void;
  18918. /**
  18919. * Gets the class name of the current intput.
  18920. * @returns the class name
  18921. */
  18922. getClassName(): string;
  18923. /**
  18924. * Get the friendly name associated with the input class.
  18925. * @returns the input friendly name
  18926. */
  18927. getSimpleName(): string;
  18928. }
  18929. }
  18930. declare module BABYLON {
  18931. /**
  18932. * Manage the touch inputs to control the movement of a free camera.
  18933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18934. */
  18935. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18936. /**
  18937. * Define if mouse events can be treated as touch events
  18938. */
  18939. allowMouse: boolean;
  18940. /**
  18941. * Defines the camera the input is attached to.
  18942. */
  18943. camera: FreeCamera;
  18944. /**
  18945. * Defines the touch sensibility for rotation.
  18946. * The higher the faster.
  18947. */
  18948. touchAngularSensibility: number;
  18949. /**
  18950. * Defines the touch sensibility for move.
  18951. * The higher the faster.
  18952. */
  18953. touchMoveSensibility: number;
  18954. private _offsetX;
  18955. private _offsetY;
  18956. private _pointerPressed;
  18957. private _pointerInput;
  18958. private _observer;
  18959. private _onLostFocus;
  18960. /**
  18961. * Manage the touch inputs to control the movement of a free camera.
  18962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18963. * @param allowMouse Defines if mouse events can be treated as touch events
  18964. */
  18965. constructor(
  18966. /**
  18967. * Define if mouse events can be treated as touch events
  18968. */
  18969. allowMouse?: boolean);
  18970. /**
  18971. * Attach the input controls to a specific dom element to get the input from.
  18972. * @param element Defines the element the controls should be listened from
  18973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18974. */
  18975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18976. /**
  18977. * Detach the current controls from the specified dom element.
  18978. * @param element Defines the element to stop listening the inputs from
  18979. */
  18980. detachControl(element: Nullable<HTMLElement>): void;
  18981. /**
  18982. * Update the current camera state depending on the inputs that have been used this frame.
  18983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18984. */
  18985. checkInputs(): void;
  18986. /**
  18987. * Gets the class name of the current intput.
  18988. * @returns the class name
  18989. */
  18990. getClassName(): string;
  18991. /**
  18992. * Get the friendly name associated with the input class.
  18993. * @returns the input friendly name
  18994. */
  18995. getSimpleName(): string;
  18996. }
  18997. }
  18998. declare module BABYLON {
  18999. /**
  19000. * Default Inputs manager for the FreeCamera.
  19001. * It groups all the default supported inputs for ease of use.
  19002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19003. */
  19004. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19005. /**
  19006. * @hidden
  19007. */
  19008. _mouseInput: Nullable<FreeCameraMouseInput>;
  19009. /**
  19010. * Instantiates a new FreeCameraInputsManager.
  19011. * @param camera Defines the camera the inputs belong to
  19012. */
  19013. constructor(camera: FreeCamera);
  19014. /**
  19015. * Add keyboard input support to the input manager.
  19016. * @returns the current input manager
  19017. */
  19018. addKeyboard(): FreeCameraInputsManager;
  19019. /**
  19020. * Add mouse input support to the input manager.
  19021. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19022. * @returns the current input manager
  19023. */
  19024. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19025. /**
  19026. * Removes the mouse input support from the manager
  19027. * @returns the current input manager
  19028. */
  19029. removeMouse(): FreeCameraInputsManager;
  19030. /**
  19031. * Add touch input support to the input manager.
  19032. * @returns the current input manager
  19033. */
  19034. addTouch(): FreeCameraInputsManager;
  19035. /**
  19036. * Remove all attached input methods from a camera
  19037. */
  19038. clear(): void;
  19039. }
  19040. }
  19041. declare module BABYLON {
  19042. /**
  19043. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19044. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19045. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19046. */
  19047. export class FreeCamera extends TargetCamera {
  19048. /**
  19049. * Define the collision ellipsoid of the camera.
  19050. * This is helpful to simulate a camera body like the player body around the camera
  19051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19052. */
  19053. ellipsoid: Vector3;
  19054. /**
  19055. * Define an offset for the position of the ellipsoid around the camera.
  19056. * This can be helpful to determine the center of the body near the gravity center of the body
  19057. * instead of its head.
  19058. */
  19059. ellipsoidOffset: Vector3;
  19060. /**
  19061. * Enable or disable collisions of the camera with the rest of the scene objects.
  19062. */
  19063. checkCollisions: boolean;
  19064. /**
  19065. * Enable or disable gravity on the camera.
  19066. */
  19067. applyGravity: boolean;
  19068. /**
  19069. * Define the input manager associated to the camera.
  19070. */
  19071. inputs: FreeCameraInputsManager;
  19072. /**
  19073. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19074. * Higher values reduce sensitivity.
  19075. */
  19076. get angularSensibility(): number;
  19077. /**
  19078. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19079. * Higher values reduce sensitivity.
  19080. */
  19081. set angularSensibility(value: number);
  19082. /**
  19083. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19084. */
  19085. get keysUp(): number[];
  19086. set keysUp(value: number[]);
  19087. /**
  19088. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19089. */
  19090. get keysUpward(): number[];
  19091. set keysUpward(value: number[]);
  19092. /**
  19093. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19094. */
  19095. get keysDown(): number[];
  19096. set keysDown(value: number[]);
  19097. /**
  19098. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19099. */
  19100. get keysDownward(): number[];
  19101. set keysDownward(value: number[]);
  19102. /**
  19103. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19104. */
  19105. get keysLeft(): number[];
  19106. set keysLeft(value: number[]);
  19107. /**
  19108. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19109. */
  19110. get keysRight(): number[];
  19111. set keysRight(value: number[]);
  19112. /**
  19113. * Event raised when the camera collide with a mesh in the scene.
  19114. */
  19115. onCollide: (collidedMesh: AbstractMesh) => void;
  19116. private _collider;
  19117. private _needMoveForGravity;
  19118. private _oldPosition;
  19119. private _diffPosition;
  19120. private _newPosition;
  19121. /** @hidden */
  19122. _localDirection: Vector3;
  19123. /** @hidden */
  19124. _transformedDirection: Vector3;
  19125. /**
  19126. * Instantiates a Free Camera.
  19127. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19128. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19129. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19130. * @param name Define the name of the camera in the scene
  19131. * @param position Define the start position of the camera in the scene
  19132. * @param scene Define the scene the camera belongs to
  19133. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19134. */
  19135. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19136. /**
  19137. * Attached controls to the current camera.
  19138. * @param element Defines the element the controls should be listened from
  19139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19140. */
  19141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19142. /**
  19143. * Detach the current controls from the camera.
  19144. * The camera will stop reacting to inputs.
  19145. * @param element Defines the element to stop listening the inputs from
  19146. */
  19147. detachControl(element: HTMLElement): void;
  19148. private _collisionMask;
  19149. /**
  19150. * Define a collision mask to limit the list of object the camera can collide with
  19151. */
  19152. get collisionMask(): number;
  19153. set collisionMask(mask: number);
  19154. /** @hidden */
  19155. _collideWithWorld(displacement: Vector3): void;
  19156. private _onCollisionPositionChange;
  19157. /** @hidden */
  19158. _checkInputs(): void;
  19159. /** @hidden */
  19160. _decideIfNeedsToMove(): boolean;
  19161. /** @hidden */
  19162. _updatePosition(): void;
  19163. /**
  19164. * Destroy the camera and release the current resources hold by it.
  19165. */
  19166. dispose(): void;
  19167. /**
  19168. * Gets the current object class name.
  19169. * @return the class name
  19170. */
  19171. getClassName(): string;
  19172. }
  19173. }
  19174. declare module BABYLON {
  19175. /**
  19176. * Represents a gamepad control stick position
  19177. */
  19178. export class StickValues {
  19179. /**
  19180. * The x component of the control stick
  19181. */
  19182. x: number;
  19183. /**
  19184. * The y component of the control stick
  19185. */
  19186. y: number;
  19187. /**
  19188. * Initializes the gamepad x and y control stick values
  19189. * @param x The x component of the gamepad control stick value
  19190. * @param y The y component of the gamepad control stick value
  19191. */
  19192. constructor(
  19193. /**
  19194. * The x component of the control stick
  19195. */
  19196. x: number,
  19197. /**
  19198. * The y component of the control stick
  19199. */
  19200. y: number);
  19201. }
  19202. /**
  19203. * An interface which manages callbacks for gamepad button changes
  19204. */
  19205. export interface GamepadButtonChanges {
  19206. /**
  19207. * Called when a gamepad has been changed
  19208. */
  19209. changed: boolean;
  19210. /**
  19211. * Called when a gamepad press event has been triggered
  19212. */
  19213. pressChanged: boolean;
  19214. /**
  19215. * Called when a touch event has been triggered
  19216. */
  19217. touchChanged: boolean;
  19218. /**
  19219. * Called when a value has changed
  19220. */
  19221. valueChanged: boolean;
  19222. }
  19223. /**
  19224. * Represents a gamepad
  19225. */
  19226. export class Gamepad {
  19227. /**
  19228. * The id of the gamepad
  19229. */
  19230. id: string;
  19231. /**
  19232. * The index of the gamepad
  19233. */
  19234. index: number;
  19235. /**
  19236. * The browser gamepad
  19237. */
  19238. browserGamepad: any;
  19239. /**
  19240. * Specifies what type of gamepad this represents
  19241. */
  19242. type: number;
  19243. private _leftStick;
  19244. private _rightStick;
  19245. /** @hidden */
  19246. _isConnected: boolean;
  19247. private _leftStickAxisX;
  19248. private _leftStickAxisY;
  19249. private _rightStickAxisX;
  19250. private _rightStickAxisY;
  19251. /**
  19252. * Triggered when the left control stick has been changed
  19253. */
  19254. private _onleftstickchanged;
  19255. /**
  19256. * Triggered when the right control stick has been changed
  19257. */
  19258. private _onrightstickchanged;
  19259. /**
  19260. * Represents a gamepad controller
  19261. */
  19262. static GAMEPAD: number;
  19263. /**
  19264. * Represents a generic controller
  19265. */
  19266. static GENERIC: number;
  19267. /**
  19268. * Represents an XBox controller
  19269. */
  19270. static XBOX: number;
  19271. /**
  19272. * Represents a pose-enabled controller
  19273. */
  19274. static POSE_ENABLED: number;
  19275. /**
  19276. * Represents an Dual Shock controller
  19277. */
  19278. static DUALSHOCK: number;
  19279. /**
  19280. * Specifies whether the left control stick should be Y-inverted
  19281. */
  19282. protected _invertLeftStickY: boolean;
  19283. /**
  19284. * Specifies if the gamepad has been connected
  19285. */
  19286. get isConnected(): boolean;
  19287. /**
  19288. * Initializes the gamepad
  19289. * @param id The id of the gamepad
  19290. * @param index The index of the gamepad
  19291. * @param browserGamepad The browser gamepad
  19292. * @param leftStickX The x component of the left joystick
  19293. * @param leftStickY The y component of the left joystick
  19294. * @param rightStickX The x component of the right joystick
  19295. * @param rightStickY The y component of the right joystick
  19296. */
  19297. constructor(
  19298. /**
  19299. * The id of the gamepad
  19300. */
  19301. id: string,
  19302. /**
  19303. * The index of the gamepad
  19304. */
  19305. index: number,
  19306. /**
  19307. * The browser gamepad
  19308. */
  19309. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19310. /**
  19311. * Callback triggered when the left joystick has changed
  19312. * @param callback
  19313. */
  19314. onleftstickchanged(callback: (values: StickValues) => void): void;
  19315. /**
  19316. * Callback triggered when the right joystick has changed
  19317. * @param callback
  19318. */
  19319. onrightstickchanged(callback: (values: StickValues) => void): void;
  19320. /**
  19321. * Gets the left joystick
  19322. */
  19323. get leftStick(): StickValues;
  19324. /**
  19325. * Sets the left joystick values
  19326. */
  19327. set leftStick(newValues: StickValues);
  19328. /**
  19329. * Gets the right joystick
  19330. */
  19331. get rightStick(): StickValues;
  19332. /**
  19333. * Sets the right joystick value
  19334. */
  19335. set rightStick(newValues: StickValues);
  19336. /**
  19337. * Updates the gamepad joystick positions
  19338. */
  19339. update(): void;
  19340. /**
  19341. * Disposes the gamepad
  19342. */
  19343. dispose(): void;
  19344. }
  19345. /**
  19346. * Represents a generic gamepad
  19347. */
  19348. export class GenericPad extends Gamepad {
  19349. private _buttons;
  19350. private _onbuttondown;
  19351. private _onbuttonup;
  19352. /**
  19353. * Observable triggered when a button has been pressed
  19354. */
  19355. onButtonDownObservable: Observable<number>;
  19356. /**
  19357. * Observable triggered when a button has been released
  19358. */
  19359. onButtonUpObservable: Observable<number>;
  19360. /**
  19361. * Callback triggered when a button has been pressed
  19362. * @param callback Called when a button has been pressed
  19363. */
  19364. onbuttondown(callback: (buttonPressed: number) => void): void;
  19365. /**
  19366. * Callback triggered when a button has been released
  19367. * @param callback Called when a button has been released
  19368. */
  19369. onbuttonup(callback: (buttonReleased: number) => void): void;
  19370. /**
  19371. * Initializes the generic gamepad
  19372. * @param id The id of the generic gamepad
  19373. * @param index The index of the generic gamepad
  19374. * @param browserGamepad The browser gamepad
  19375. */
  19376. constructor(id: string, index: number, browserGamepad: any);
  19377. private _setButtonValue;
  19378. /**
  19379. * Updates the generic gamepad
  19380. */
  19381. update(): void;
  19382. /**
  19383. * Disposes the generic gamepad
  19384. */
  19385. dispose(): void;
  19386. }
  19387. }
  19388. declare module BABYLON {
  19389. /**
  19390. * Defines the types of pose enabled controllers that are supported
  19391. */
  19392. export enum PoseEnabledControllerType {
  19393. /**
  19394. * HTC Vive
  19395. */
  19396. VIVE = 0,
  19397. /**
  19398. * Oculus Rift
  19399. */
  19400. OCULUS = 1,
  19401. /**
  19402. * Windows mixed reality
  19403. */
  19404. WINDOWS = 2,
  19405. /**
  19406. * Samsung gear VR
  19407. */
  19408. GEAR_VR = 3,
  19409. /**
  19410. * Google Daydream
  19411. */
  19412. DAYDREAM = 4,
  19413. /**
  19414. * Generic
  19415. */
  19416. GENERIC = 5
  19417. }
  19418. /**
  19419. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19420. */
  19421. export interface MutableGamepadButton {
  19422. /**
  19423. * Value of the button/trigger
  19424. */
  19425. value: number;
  19426. /**
  19427. * If the button/trigger is currently touched
  19428. */
  19429. touched: boolean;
  19430. /**
  19431. * If the button/trigger is currently pressed
  19432. */
  19433. pressed: boolean;
  19434. }
  19435. /**
  19436. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19437. * @hidden
  19438. */
  19439. export interface ExtendedGamepadButton extends GamepadButton {
  19440. /**
  19441. * If the button/trigger is currently pressed
  19442. */
  19443. readonly pressed: boolean;
  19444. /**
  19445. * If the button/trigger is currently touched
  19446. */
  19447. readonly touched: boolean;
  19448. /**
  19449. * Value of the button/trigger
  19450. */
  19451. readonly value: number;
  19452. }
  19453. /** @hidden */
  19454. export interface _GamePadFactory {
  19455. /**
  19456. * Returns whether or not the current gamepad can be created for this type of controller.
  19457. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19458. * @returns true if it can be created, otherwise false
  19459. */
  19460. canCreate(gamepadInfo: any): boolean;
  19461. /**
  19462. * Creates a new instance of the Gamepad.
  19463. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19464. * @returns the new gamepad instance
  19465. */
  19466. create(gamepadInfo: any): Gamepad;
  19467. }
  19468. /**
  19469. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19470. */
  19471. export class PoseEnabledControllerHelper {
  19472. /** @hidden */
  19473. static _ControllerFactories: _GamePadFactory[];
  19474. /** @hidden */
  19475. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19476. /**
  19477. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19478. * @param vrGamepad the gamepad to initialized
  19479. * @returns a vr controller of the type the gamepad identified as
  19480. */
  19481. static InitiateController(vrGamepad: any): Gamepad;
  19482. }
  19483. /**
  19484. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19485. */
  19486. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19487. /**
  19488. * If the controller is used in a webXR session
  19489. */
  19490. isXR: boolean;
  19491. private _deviceRoomPosition;
  19492. private _deviceRoomRotationQuaternion;
  19493. /**
  19494. * The device position in babylon space
  19495. */
  19496. devicePosition: Vector3;
  19497. /**
  19498. * The device rotation in babylon space
  19499. */
  19500. deviceRotationQuaternion: Quaternion;
  19501. /**
  19502. * The scale factor of the device in babylon space
  19503. */
  19504. deviceScaleFactor: number;
  19505. /**
  19506. * (Likely devicePosition should be used instead) The device position in its room space
  19507. */
  19508. position: Vector3;
  19509. /**
  19510. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19511. */
  19512. rotationQuaternion: Quaternion;
  19513. /**
  19514. * The type of controller (Eg. Windows mixed reality)
  19515. */
  19516. controllerType: PoseEnabledControllerType;
  19517. protected _calculatedPosition: Vector3;
  19518. private _calculatedRotation;
  19519. /**
  19520. * The raw pose from the device
  19521. */
  19522. rawPose: DevicePose;
  19523. private _trackPosition;
  19524. private _maxRotationDistFromHeadset;
  19525. private _draggedRoomRotation;
  19526. /**
  19527. * @hidden
  19528. */
  19529. _disableTrackPosition(fixedPosition: Vector3): void;
  19530. /**
  19531. * Internal, the mesh attached to the controller
  19532. * @hidden
  19533. */
  19534. _mesh: Nullable<AbstractMesh>;
  19535. private _poseControlledCamera;
  19536. private _leftHandSystemQuaternion;
  19537. /**
  19538. * Internal, matrix used to convert room space to babylon space
  19539. * @hidden
  19540. */
  19541. _deviceToWorld: Matrix;
  19542. /**
  19543. * Node to be used when casting a ray from the controller
  19544. * @hidden
  19545. */
  19546. _pointingPoseNode: Nullable<TransformNode>;
  19547. /**
  19548. * Name of the child mesh that can be used to cast a ray from the controller
  19549. */
  19550. static readonly POINTING_POSE: string;
  19551. /**
  19552. * Creates a new PoseEnabledController from a gamepad
  19553. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19554. */
  19555. constructor(browserGamepad: any);
  19556. private _workingMatrix;
  19557. /**
  19558. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19559. */
  19560. update(): void;
  19561. /**
  19562. * Updates only the pose device and mesh without doing any button event checking
  19563. */
  19564. protected _updatePoseAndMesh(): void;
  19565. /**
  19566. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19567. * @param poseData raw pose fromthe device
  19568. */
  19569. updateFromDevice(poseData: DevicePose): void;
  19570. /**
  19571. * @hidden
  19572. */
  19573. _meshAttachedObservable: Observable<AbstractMesh>;
  19574. /**
  19575. * Attaches a mesh to the controller
  19576. * @param mesh the mesh to be attached
  19577. */
  19578. attachToMesh(mesh: AbstractMesh): void;
  19579. /**
  19580. * Attaches the controllers mesh to a camera
  19581. * @param camera the camera the mesh should be attached to
  19582. */
  19583. attachToPoseControlledCamera(camera: TargetCamera): void;
  19584. /**
  19585. * Disposes of the controller
  19586. */
  19587. dispose(): void;
  19588. /**
  19589. * The mesh that is attached to the controller
  19590. */
  19591. get mesh(): Nullable<AbstractMesh>;
  19592. /**
  19593. * Gets the ray of the controller in the direction the controller is pointing
  19594. * @param length the length the resulting ray should be
  19595. * @returns a ray in the direction the controller is pointing
  19596. */
  19597. getForwardRay(length?: number): Ray;
  19598. }
  19599. }
  19600. declare module BABYLON {
  19601. /**
  19602. * Defines the WebVRController object that represents controllers tracked in 3D space
  19603. */
  19604. export abstract class WebVRController extends PoseEnabledController {
  19605. /**
  19606. * Internal, the default controller model for the controller
  19607. */
  19608. protected _defaultModel: Nullable<AbstractMesh>;
  19609. /**
  19610. * Fired when the trigger state has changed
  19611. */
  19612. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19613. /**
  19614. * Fired when the main button state has changed
  19615. */
  19616. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19617. /**
  19618. * Fired when the secondary button state has changed
  19619. */
  19620. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19621. /**
  19622. * Fired when the pad state has changed
  19623. */
  19624. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19625. /**
  19626. * Fired when controllers stick values have changed
  19627. */
  19628. onPadValuesChangedObservable: Observable<StickValues>;
  19629. /**
  19630. * Array of button availible on the controller
  19631. */
  19632. protected _buttons: Array<MutableGamepadButton>;
  19633. private _onButtonStateChange;
  19634. /**
  19635. * Fired when a controller button's state has changed
  19636. * @param callback the callback containing the button that was modified
  19637. */
  19638. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19639. /**
  19640. * X and Y axis corresponding to the controllers joystick
  19641. */
  19642. pad: StickValues;
  19643. /**
  19644. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19645. */
  19646. hand: string;
  19647. /**
  19648. * The default controller model for the controller
  19649. */
  19650. get defaultModel(): Nullable<AbstractMesh>;
  19651. /**
  19652. * Creates a new WebVRController from a gamepad
  19653. * @param vrGamepad the gamepad that the WebVRController should be created from
  19654. */
  19655. constructor(vrGamepad: any);
  19656. /**
  19657. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19658. */
  19659. update(): void;
  19660. /**
  19661. * Function to be called when a button is modified
  19662. */
  19663. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19664. /**
  19665. * Loads a mesh and attaches it to the controller
  19666. * @param scene the scene the mesh should be added to
  19667. * @param meshLoaded callback for when the mesh has been loaded
  19668. */
  19669. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19670. private _setButtonValue;
  19671. private _changes;
  19672. private _checkChanges;
  19673. /**
  19674. * Disposes of th webVRCOntroller
  19675. */
  19676. dispose(): void;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /**
  19681. * The HemisphericLight simulates the ambient environment light,
  19682. * so the passed direction is the light reflection direction, not the incoming direction.
  19683. */
  19684. export class HemisphericLight extends Light {
  19685. /**
  19686. * The groundColor is the light in the opposite direction to the one specified during creation.
  19687. * 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.
  19688. */
  19689. groundColor: Color3;
  19690. /**
  19691. * The light reflection direction, not the incoming direction.
  19692. */
  19693. direction: Vector3;
  19694. /**
  19695. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19696. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19697. * The HemisphericLight can't cast shadows.
  19698. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19699. * @param name The friendly name of the light
  19700. * @param direction The direction of the light reflection
  19701. * @param scene The scene the light belongs to
  19702. */
  19703. constructor(name: string, direction: Vector3, scene: Scene);
  19704. protected _buildUniformLayout(): void;
  19705. /**
  19706. * Returns the string "HemisphericLight".
  19707. * @return The class name
  19708. */
  19709. getClassName(): string;
  19710. /**
  19711. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19712. * Returns the updated direction.
  19713. * @param target The target the direction should point to
  19714. * @return The computed direction
  19715. */
  19716. setDirectionToTarget(target: Vector3): Vector3;
  19717. /**
  19718. * Returns the shadow generator associated to the light.
  19719. * @returns Always null for hemispheric lights because it does not support shadows.
  19720. */
  19721. getShadowGenerator(): Nullable<IShadowGenerator>;
  19722. /**
  19723. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19724. * @param effect The effect to update
  19725. * @param lightIndex The index of the light in the effect to update
  19726. * @returns The hemispheric light
  19727. */
  19728. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19729. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19730. /**
  19731. * Computes the world matrix of the node
  19732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19733. * @param useWasUpdatedFlag defines a reserved property
  19734. * @returns the world matrix
  19735. */
  19736. computeWorldMatrix(): Matrix;
  19737. /**
  19738. * Returns the integer 3.
  19739. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19740. */
  19741. getTypeID(): number;
  19742. /**
  19743. * Prepares the list of defines specific to the light type.
  19744. * @param defines the list of defines
  19745. * @param lightIndex defines the index of the light for the effect
  19746. */
  19747. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19748. }
  19749. }
  19750. declare module BABYLON {
  19751. /** @hidden */
  19752. export var vrMultiviewToSingleviewPixelShader: {
  19753. name: string;
  19754. shader: string;
  19755. };
  19756. }
  19757. declare module BABYLON {
  19758. /**
  19759. * Renders to multiple views with a single draw call
  19760. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19761. */
  19762. export class MultiviewRenderTarget extends RenderTargetTexture {
  19763. /**
  19764. * Creates a multiview render target
  19765. * @param scene scene used with the render target
  19766. * @param size the size of the render target (used for each view)
  19767. */
  19768. constructor(scene: Scene, size?: number | {
  19769. width: number;
  19770. height: number;
  19771. } | {
  19772. ratio: number;
  19773. });
  19774. /**
  19775. * @hidden
  19776. * @param faceIndex the face index, if its a cube texture
  19777. */
  19778. _bindFrameBuffer(faceIndex?: number): void;
  19779. /**
  19780. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19781. * @returns the view count
  19782. */
  19783. getViewCount(): number;
  19784. }
  19785. }
  19786. declare module BABYLON {
  19787. interface Engine {
  19788. /**
  19789. * Creates a new multiview render target
  19790. * @param width defines the width of the texture
  19791. * @param height defines the height of the texture
  19792. * @returns the created multiview texture
  19793. */
  19794. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19795. /**
  19796. * Binds a multiview framebuffer to be drawn to
  19797. * @param multiviewTexture texture to bind
  19798. */
  19799. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19800. }
  19801. interface Camera {
  19802. /**
  19803. * @hidden
  19804. * 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)
  19805. */
  19806. _useMultiviewToSingleView: boolean;
  19807. /**
  19808. * @hidden
  19809. * 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)
  19810. */
  19811. _multiviewTexture: Nullable<RenderTargetTexture>;
  19812. /**
  19813. * @hidden
  19814. * ensures the multiview texture of the camera exists and has the specified width/height
  19815. * @param width height to set on the multiview texture
  19816. * @param height width to set on the multiview texture
  19817. */
  19818. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19819. }
  19820. interface Scene {
  19821. /** @hidden */
  19822. _transformMatrixR: Matrix;
  19823. /** @hidden */
  19824. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19825. /** @hidden */
  19826. _createMultiviewUbo(): void;
  19827. /** @hidden */
  19828. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19829. /** @hidden */
  19830. _renderMultiviewToSingleView(camera: Camera): void;
  19831. }
  19832. }
  19833. declare module BABYLON {
  19834. /**
  19835. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19836. * This will not be used for webXR as it supports displaying texture arrays directly
  19837. */
  19838. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19839. /**
  19840. * Gets a string identifying the name of the class
  19841. * @returns "VRMultiviewToSingleviewPostProcess" string
  19842. */
  19843. getClassName(): string;
  19844. /**
  19845. * Initializes a VRMultiviewToSingleview
  19846. * @param name name of the post process
  19847. * @param camera camera to be applied to
  19848. * @param scaleFactor scaling factor to the size of the output texture
  19849. */
  19850. constructor(name: string, camera: Camera, scaleFactor: number);
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /**
  19855. * Interface used to define additional presentation attributes
  19856. */
  19857. export interface IVRPresentationAttributes {
  19858. /**
  19859. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19860. */
  19861. highRefreshRate: boolean;
  19862. /**
  19863. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19864. */
  19865. foveationLevel: number;
  19866. }
  19867. interface Engine {
  19868. /** @hidden */
  19869. _vrDisplay: any;
  19870. /** @hidden */
  19871. _vrSupported: boolean;
  19872. /** @hidden */
  19873. _oldSize: Size;
  19874. /** @hidden */
  19875. _oldHardwareScaleFactor: number;
  19876. /** @hidden */
  19877. _vrExclusivePointerMode: boolean;
  19878. /** @hidden */
  19879. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19880. /** @hidden */
  19881. _onVRDisplayPointerRestricted: () => void;
  19882. /** @hidden */
  19883. _onVRDisplayPointerUnrestricted: () => void;
  19884. /** @hidden */
  19885. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19886. /** @hidden */
  19887. _onVrDisplayDisconnect: Nullable<() => void>;
  19888. /** @hidden */
  19889. _onVrDisplayPresentChange: Nullable<() => void>;
  19890. /**
  19891. * Observable signaled when VR display mode changes
  19892. */
  19893. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19894. /**
  19895. * Observable signaled when VR request present is complete
  19896. */
  19897. onVRRequestPresentComplete: Observable<boolean>;
  19898. /**
  19899. * Observable signaled when VR request present starts
  19900. */
  19901. onVRRequestPresentStart: Observable<Engine>;
  19902. /**
  19903. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19904. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19905. */
  19906. isInVRExclusivePointerMode: boolean;
  19907. /**
  19908. * Gets a boolean indicating if a webVR device was detected
  19909. * @returns true if a webVR device was detected
  19910. */
  19911. isVRDevicePresent(): boolean;
  19912. /**
  19913. * Gets the current webVR device
  19914. * @returns the current webVR device (or null)
  19915. */
  19916. getVRDevice(): any;
  19917. /**
  19918. * Initializes a webVR display and starts listening to display change events
  19919. * The onVRDisplayChangedObservable will be notified upon these changes
  19920. * @returns A promise containing a VRDisplay and if vr is supported
  19921. */
  19922. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19923. /** @hidden */
  19924. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19925. /**
  19926. * Gets or sets the presentation attributes used to configure VR rendering
  19927. */
  19928. vrPresentationAttributes?: IVRPresentationAttributes;
  19929. /**
  19930. * Call this function to switch to webVR mode
  19931. * Will do nothing if webVR is not supported or if there is no webVR device
  19932. * @param options the webvr options provided to the camera. mainly used for multiview
  19933. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19934. */
  19935. enableVR(options: WebVROptions): void;
  19936. /** @hidden */
  19937. _onVRFullScreenTriggered(): void;
  19938. }
  19939. }
  19940. declare module BABYLON {
  19941. /**
  19942. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19943. * IMPORTANT!! The data is right-hand data.
  19944. * @export
  19945. * @interface DevicePose
  19946. */
  19947. export interface DevicePose {
  19948. /**
  19949. * The position of the device, values in array are [x,y,z].
  19950. */
  19951. readonly position: Nullable<Float32Array>;
  19952. /**
  19953. * The linearVelocity of the device, values in array are [x,y,z].
  19954. */
  19955. readonly linearVelocity: Nullable<Float32Array>;
  19956. /**
  19957. * The linearAcceleration of the device, values in array are [x,y,z].
  19958. */
  19959. readonly linearAcceleration: Nullable<Float32Array>;
  19960. /**
  19961. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19962. */
  19963. readonly orientation: Nullable<Float32Array>;
  19964. /**
  19965. * The angularVelocity of the device, values in array are [x,y,z].
  19966. */
  19967. readonly angularVelocity: Nullable<Float32Array>;
  19968. /**
  19969. * The angularAcceleration of the device, values in array are [x,y,z].
  19970. */
  19971. readonly angularAcceleration: Nullable<Float32Array>;
  19972. }
  19973. /**
  19974. * Interface representing a pose controlled object in Babylon.
  19975. * A pose controlled object has both regular pose values as well as pose values
  19976. * from an external device such as a VR head mounted display
  19977. */
  19978. export interface PoseControlled {
  19979. /**
  19980. * The position of the object in babylon space.
  19981. */
  19982. position: Vector3;
  19983. /**
  19984. * The rotation quaternion of the object in babylon space.
  19985. */
  19986. rotationQuaternion: Quaternion;
  19987. /**
  19988. * The position of the device in babylon space.
  19989. */
  19990. devicePosition?: Vector3;
  19991. /**
  19992. * The rotation quaternion of the device in babylon space.
  19993. */
  19994. deviceRotationQuaternion: Quaternion;
  19995. /**
  19996. * The raw pose coming from the device.
  19997. */
  19998. rawPose: Nullable<DevicePose>;
  19999. /**
  20000. * The scale of the device to be used when translating from device space to babylon space.
  20001. */
  20002. deviceScaleFactor: number;
  20003. /**
  20004. * Updates the poseControlled values based on the input device pose.
  20005. * @param poseData the pose data to update the object with
  20006. */
  20007. updateFromDevice(poseData: DevicePose): void;
  20008. }
  20009. /**
  20010. * Set of options to customize the webVRCamera
  20011. */
  20012. export interface WebVROptions {
  20013. /**
  20014. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20015. */
  20016. trackPosition?: boolean;
  20017. /**
  20018. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20019. */
  20020. positionScale?: number;
  20021. /**
  20022. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20023. */
  20024. displayName?: string;
  20025. /**
  20026. * Should the native controller meshes be initialized. (default: true)
  20027. */
  20028. controllerMeshes?: boolean;
  20029. /**
  20030. * Creating a default HemiLight only on controllers. (default: true)
  20031. */
  20032. defaultLightingOnControllers?: boolean;
  20033. /**
  20034. * If you don't want to use the default VR button of the helper. (default: false)
  20035. */
  20036. useCustomVRButton?: boolean;
  20037. /**
  20038. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20039. */
  20040. customVRButton?: HTMLButtonElement;
  20041. /**
  20042. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20043. */
  20044. rayLength?: number;
  20045. /**
  20046. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20047. */
  20048. defaultHeight?: number;
  20049. /**
  20050. * If multiview should be used if availible (default: false)
  20051. */
  20052. useMultiview?: boolean;
  20053. }
  20054. /**
  20055. * This represents a WebVR camera.
  20056. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20057. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20058. */
  20059. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20060. private webVROptions;
  20061. /**
  20062. * @hidden
  20063. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20064. */
  20065. _vrDevice: any;
  20066. /**
  20067. * The rawPose of the vrDevice.
  20068. */
  20069. rawPose: Nullable<DevicePose>;
  20070. private _onVREnabled;
  20071. private _specsVersion;
  20072. private _attached;
  20073. private _frameData;
  20074. protected _descendants: Array<Node>;
  20075. private _deviceRoomPosition;
  20076. /** @hidden */
  20077. _deviceRoomRotationQuaternion: Quaternion;
  20078. private _standingMatrix;
  20079. /**
  20080. * Represents device position in babylon space.
  20081. */
  20082. devicePosition: Vector3;
  20083. /**
  20084. * Represents device rotation in babylon space.
  20085. */
  20086. deviceRotationQuaternion: Quaternion;
  20087. /**
  20088. * The scale of the device to be used when translating from device space to babylon space.
  20089. */
  20090. deviceScaleFactor: number;
  20091. private _deviceToWorld;
  20092. private _worldToDevice;
  20093. /**
  20094. * References to the webVR controllers for the vrDevice.
  20095. */
  20096. controllers: Array<WebVRController>;
  20097. /**
  20098. * Emits an event when a controller is attached.
  20099. */
  20100. onControllersAttachedObservable: Observable<WebVRController[]>;
  20101. /**
  20102. * Emits an event when a controller's mesh has been loaded;
  20103. */
  20104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20105. /**
  20106. * Emits an event when the HMD's pose has been updated.
  20107. */
  20108. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20109. private _poseSet;
  20110. /**
  20111. * If the rig cameras be used as parent instead of this camera.
  20112. */
  20113. rigParenting: boolean;
  20114. private _lightOnControllers;
  20115. private _defaultHeight?;
  20116. /**
  20117. * Instantiates a WebVRFreeCamera.
  20118. * @param name The name of the WebVRFreeCamera
  20119. * @param position The starting anchor position for the camera
  20120. * @param scene The scene the camera belongs to
  20121. * @param webVROptions a set of customizable options for the webVRCamera
  20122. */
  20123. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20124. /**
  20125. * Gets the device distance from the ground in meters.
  20126. * @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.
  20127. */
  20128. deviceDistanceToRoomGround(): number;
  20129. /**
  20130. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20131. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20132. */
  20133. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20134. /**
  20135. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20136. * @returns A promise with a boolean set to if the standing matrix is supported.
  20137. */
  20138. useStandingMatrixAsync(): Promise<boolean>;
  20139. /**
  20140. * Disposes the camera
  20141. */
  20142. dispose(): void;
  20143. /**
  20144. * Gets a vrController by name.
  20145. * @param name The name of the controller to retreive
  20146. * @returns the controller matching the name specified or null if not found
  20147. */
  20148. getControllerByName(name: string): Nullable<WebVRController>;
  20149. private _leftController;
  20150. /**
  20151. * The controller corresponding to the users left hand.
  20152. */
  20153. get leftController(): Nullable<WebVRController>;
  20154. private _rightController;
  20155. /**
  20156. * The controller corresponding to the users right hand.
  20157. */
  20158. get rightController(): Nullable<WebVRController>;
  20159. /**
  20160. * Casts a ray forward from the vrCamera's gaze.
  20161. * @param length Length of the ray (default: 100)
  20162. * @returns the ray corresponding to the gaze
  20163. */
  20164. getForwardRay(length?: number): Ray;
  20165. /**
  20166. * @hidden
  20167. * Updates the camera based on device's frame data
  20168. */
  20169. _checkInputs(): void;
  20170. /**
  20171. * Updates the poseControlled values based on the input device pose.
  20172. * @param poseData Pose coming from the device
  20173. */
  20174. updateFromDevice(poseData: DevicePose): void;
  20175. private _htmlElementAttached;
  20176. private _detachIfAttached;
  20177. /**
  20178. * WebVR's attach control will start broadcasting frames to the device.
  20179. * Note that in certain browsers (chrome for example) this function must be called
  20180. * within a user-interaction callback. Example:
  20181. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20182. *
  20183. * @param element html element to attach the vrDevice to
  20184. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20185. */
  20186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20187. /**
  20188. * Detaches the camera from the html element and disables VR
  20189. *
  20190. * @param element html element to detach from
  20191. */
  20192. detachControl(element: HTMLElement): void;
  20193. /**
  20194. * @returns the name of this class
  20195. */
  20196. getClassName(): string;
  20197. /**
  20198. * Calls resetPose on the vrDisplay
  20199. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20200. */
  20201. resetToCurrentRotation(): void;
  20202. /**
  20203. * @hidden
  20204. * Updates the rig cameras (left and right eye)
  20205. */
  20206. _updateRigCameras(): void;
  20207. private _workingVector;
  20208. private _oneVector;
  20209. private _workingMatrix;
  20210. private updateCacheCalled;
  20211. private _correctPositionIfNotTrackPosition;
  20212. /**
  20213. * @hidden
  20214. * Updates the cached values of the camera
  20215. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20216. */
  20217. _updateCache(ignoreParentClass?: boolean): void;
  20218. /**
  20219. * @hidden
  20220. * Get current device position in babylon world
  20221. */
  20222. _computeDevicePosition(): void;
  20223. /**
  20224. * Updates the current device position and rotation in the babylon world
  20225. */
  20226. update(): void;
  20227. /**
  20228. * @hidden
  20229. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20230. * @returns an identity matrix
  20231. */
  20232. _getViewMatrix(): Matrix;
  20233. private _tmpMatrix;
  20234. /**
  20235. * This function is called by the two RIG cameras.
  20236. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20237. * @hidden
  20238. */
  20239. _getWebVRViewMatrix(): Matrix;
  20240. /** @hidden */
  20241. _getWebVRProjectionMatrix(): Matrix;
  20242. private _onGamepadConnectedObserver;
  20243. private _onGamepadDisconnectedObserver;
  20244. private _updateCacheWhenTrackingDisabledObserver;
  20245. /**
  20246. * Initializes the controllers and their meshes
  20247. */
  20248. initControllers(): void;
  20249. }
  20250. }
  20251. declare module BABYLON {
  20252. /**
  20253. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20254. *
  20255. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20256. *
  20257. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20258. */
  20259. export class MaterialHelper {
  20260. /**
  20261. * Bind the current view position to an effect.
  20262. * @param effect The effect to be bound
  20263. * @param scene The scene the eyes position is used from
  20264. * @param variableName name of the shader variable that will hold the eye position
  20265. */
  20266. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20267. /**
  20268. * Helps preparing the defines values about the UVs in used in the effect.
  20269. * UVs are shared as much as we can accross channels in the shaders.
  20270. * @param texture The texture we are preparing the UVs for
  20271. * @param defines The defines to update
  20272. * @param key The channel key "diffuse", "specular"... used in the shader
  20273. */
  20274. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20275. /**
  20276. * Binds a texture matrix value to its corrsponding uniform
  20277. * @param texture The texture to bind the matrix for
  20278. * @param uniformBuffer The uniform buffer receivin the data
  20279. * @param key The channel key "diffuse", "specular"... used in the shader
  20280. */
  20281. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20282. /**
  20283. * Gets the current status of the fog (should it be enabled?)
  20284. * @param mesh defines the mesh to evaluate for fog support
  20285. * @param scene defines the hosting scene
  20286. * @returns true if fog must be enabled
  20287. */
  20288. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20289. /**
  20290. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20291. * @param mesh defines the current mesh
  20292. * @param scene defines the current scene
  20293. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20294. * @param pointsCloud defines if point cloud rendering has to be turned on
  20295. * @param fogEnabled defines if fog has to be turned on
  20296. * @param alphaTest defines if alpha testing has to be turned on
  20297. * @param defines defines the current list of defines
  20298. */
  20299. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20300. /**
  20301. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20302. * @param scene defines the current scene
  20303. * @param engine defines the current engine
  20304. * @param defines specifies the list of active defines
  20305. * @param useInstances defines if instances have to be turned on
  20306. * @param useClipPlane defines if clip plane have to be turned on
  20307. * @param useInstances defines if instances have to be turned on
  20308. * @param useThinInstances defines if thin instances have to be turned on
  20309. */
  20310. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20311. /**
  20312. * Prepares the defines for bones
  20313. * @param mesh The mesh containing the geometry data we will draw
  20314. * @param defines The defines to update
  20315. */
  20316. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20317. /**
  20318. * Prepares the defines for morph targets
  20319. * @param mesh The mesh containing the geometry data we will draw
  20320. * @param defines The defines to update
  20321. */
  20322. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20323. /**
  20324. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20325. * @param mesh The mesh containing the geometry data we will draw
  20326. * @param defines The defines to update
  20327. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20328. * @param useBones Precise whether bones should be used or not (override mesh info)
  20329. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20330. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20331. * @returns false if defines are considered not dirty and have not been checked
  20332. */
  20333. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20334. /**
  20335. * Prepares the defines related to multiview
  20336. * @param scene The scene we are intending to draw
  20337. * @param defines The defines to update
  20338. */
  20339. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20340. /**
  20341. * Prepares the defines related to the prepass
  20342. * @param scene The scene we are intending to draw
  20343. * @param defines The defines to update
  20344. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20345. */
  20346. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20347. /**
  20348. * Prepares the defines related to the light information passed in parameter
  20349. * @param scene The scene we are intending to draw
  20350. * @param mesh The mesh the effect is compiling for
  20351. * @param light The light the effect is compiling for
  20352. * @param lightIndex The index of the light
  20353. * @param defines The defines to update
  20354. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20355. * @param state Defines the current state regarding what is needed (normals, etc...)
  20356. */
  20357. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20358. needNormals: boolean;
  20359. needRebuild: boolean;
  20360. shadowEnabled: boolean;
  20361. specularEnabled: boolean;
  20362. lightmapMode: boolean;
  20363. }): void;
  20364. /**
  20365. * Prepares the defines related to the light information passed in parameter
  20366. * @param scene The scene we are intending to draw
  20367. * @param mesh The mesh the effect is compiling for
  20368. * @param defines The defines to update
  20369. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20370. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20371. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20372. * @returns true if normals will be required for the rest of the effect
  20373. */
  20374. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20375. /**
  20376. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20377. * @param lightIndex defines the light index
  20378. * @param uniformsList The uniform list
  20379. * @param samplersList The sampler list
  20380. * @param projectedLightTexture defines if projected texture must be used
  20381. * @param uniformBuffersList defines an optional list of uniform buffers
  20382. */
  20383. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20384. /**
  20385. * Prepares the uniforms and samplers list to be used in the effect
  20386. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20387. * @param samplersList The sampler list
  20388. * @param defines The defines helping in the list generation
  20389. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20390. */
  20391. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20392. /**
  20393. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20394. * @param defines The defines to update while falling back
  20395. * @param fallbacks The authorized effect fallbacks
  20396. * @param maxSimultaneousLights The maximum number of lights allowed
  20397. * @param rank the current rank of the Effect
  20398. * @returns The newly affected rank
  20399. */
  20400. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20401. private static _TmpMorphInfluencers;
  20402. /**
  20403. * Prepares the list of attributes required for morph targets according to the effect defines.
  20404. * @param attribs The current list of supported attribs
  20405. * @param mesh The mesh to prepare the morph targets attributes for
  20406. * @param influencers The number of influencers
  20407. */
  20408. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20409. /**
  20410. * Prepares the list of attributes required for morph targets according to the effect defines.
  20411. * @param attribs The current list of supported attribs
  20412. * @param mesh The mesh to prepare the morph targets attributes for
  20413. * @param defines The current Defines of the effect
  20414. */
  20415. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20416. /**
  20417. * Prepares the list of attributes required for bones according to the effect defines.
  20418. * @param attribs The current list of supported attribs
  20419. * @param mesh The mesh to prepare the bones attributes for
  20420. * @param defines The current Defines of the effect
  20421. * @param fallbacks The current efffect fallback strategy
  20422. */
  20423. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20424. /**
  20425. * Check and prepare the list of attributes required for instances according to the effect defines.
  20426. * @param attribs The current list of supported attribs
  20427. * @param defines The current MaterialDefines of the effect
  20428. */
  20429. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20430. /**
  20431. * Add the list of attributes required for instances to the attribs array.
  20432. * @param attribs The current list of supported attribs
  20433. */
  20434. static PushAttributesForInstances(attribs: string[]): void;
  20435. /**
  20436. * Binds the light information to the effect.
  20437. * @param light The light containing the generator
  20438. * @param effect The effect we are binding the data to
  20439. * @param lightIndex The light index in the effect used to render
  20440. */
  20441. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20442. /**
  20443. * Binds the lights information from the scene to the effect for the given mesh.
  20444. * @param light Light to bind
  20445. * @param lightIndex Light index
  20446. * @param scene The scene where the light belongs to
  20447. * @param effect The effect we are binding the data to
  20448. * @param useSpecular Defines if specular is supported
  20449. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20450. */
  20451. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20452. /**
  20453. * Binds the lights information from the scene to the effect for the given mesh.
  20454. * @param scene The scene the lights belongs to
  20455. * @param mesh The mesh we are binding the information to render
  20456. * @param effect The effect we are binding the data to
  20457. * @param defines The generated defines for the effect
  20458. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20459. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20460. */
  20461. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20462. private static _tempFogColor;
  20463. /**
  20464. * Binds the fog information from the scene to the effect for the given mesh.
  20465. * @param scene The scene the lights belongs to
  20466. * @param mesh The mesh we are binding the information to render
  20467. * @param effect The effect we are binding the data to
  20468. * @param linearSpace Defines if the fog effect is applied in linear space
  20469. */
  20470. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20471. /**
  20472. * Binds the bones information from the mesh to the effect.
  20473. * @param mesh The mesh we are binding the information to render
  20474. * @param effect The effect we are binding the data to
  20475. */
  20476. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20477. /**
  20478. * Binds the morph targets information from the mesh to the effect.
  20479. * @param abstractMesh The mesh we are binding the information to render
  20480. * @param effect The effect we are binding the data to
  20481. */
  20482. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20483. /**
  20484. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20485. * @param defines The generated defines used in the effect
  20486. * @param effect The effect we are binding the data to
  20487. * @param scene The scene we are willing to render with logarithmic scale for
  20488. */
  20489. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20490. /**
  20491. * Binds the clip plane information from the scene to the effect.
  20492. * @param scene The scene the clip plane information are extracted from
  20493. * @param effect The effect we are binding the data to
  20494. */
  20495. static BindClipPlane(effect: Effect, scene: Scene): void;
  20496. }
  20497. }
  20498. declare module BABYLON {
  20499. /**
  20500. * Block used to expose an input value
  20501. */
  20502. export class InputBlock extends NodeMaterialBlock {
  20503. private _mode;
  20504. private _associatedVariableName;
  20505. private _storedValue;
  20506. private _valueCallback;
  20507. private _type;
  20508. private _animationType;
  20509. /** Gets or set a value used to limit the range of float values */
  20510. min: number;
  20511. /** Gets or set a value used to limit the range of float values */
  20512. max: number;
  20513. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20514. isBoolean: boolean;
  20515. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20516. matrixMode: number;
  20517. /** @hidden */
  20518. _systemValue: Nullable<NodeMaterialSystemValues>;
  20519. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20520. isConstant: boolean;
  20521. /** Gets or sets the group to use to display this block in the Inspector */
  20522. groupInInspector: string;
  20523. /** Gets an observable raised when the value is changed */
  20524. onValueChangedObservable: Observable<InputBlock>;
  20525. /**
  20526. * Gets or sets the connection point type (default is float)
  20527. */
  20528. get type(): NodeMaterialBlockConnectionPointTypes;
  20529. /**
  20530. * Creates a new InputBlock
  20531. * @param name defines the block name
  20532. * @param target defines the target of that block (Vertex by default)
  20533. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20534. */
  20535. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20536. /**
  20537. * Validates if a name is a reserve word.
  20538. * @param newName the new name to be given to the node.
  20539. * @returns false if the name is a reserve word, else true.
  20540. */
  20541. validateBlockName(newName: string): boolean;
  20542. /**
  20543. * Gets the output component
  20544. */
  20545. get output(): NodeMaterialConnectionPoint;
  20546. /**
  20547. * Set the source of this connection point to a vertex attribute
  20548. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20549. * @returns the current connection point
  20550. */
  20551. setAsAttribute(attributeName?: string): InputBlock;
  20552. /**
  20553. * Set the source of this connection point to a system value
  20554. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20555. * @returns the current connection point
  20556. */
  20557. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20558. /**
  20559. * Gets or sets the value of that point.
  20560. * Please note that this value will be ignored if valueCallback is defined
  20561. */
  20562. get value(): any;
  20563. set value(value: any);
  20564. /**
  20565. * Gets or sets a callback used to get the value of that point.
  20566. * Please note that setting this value will force the connection point to ignore the value property
  20567. */
  20568. get valueCallback(): () => any;
  20569. set valueCallback(value: () => any);
  20570. /**
  20571. * Gets or sets the associated variable name in the shader
  20572. */
  20573. get associatedVariableName(): string;
  20574. set associatedVariableName(value: string);
  20575. /** Gets or sets the type of animation applied to the input */
  20576. get animationType(): AnimatedInputBlockTypes;
  20577. set animationType(value: AnimatedInputBlockTypes);
  20578. /**
  20579. * Gets a boolean indicating that this connection point not defined yet
  20580. */
  20581. get isUndefined(): boolean;
  20582. /**
  20583. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20584. * In this case the connection point name must be the name of the uniform to use.
  20585. * Can only be set on inputs
  20586. */
  20587. get isUniform(): boolean;
  20588. set isUniform(value: boolean);
  20589. /**
  20590. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20591. * In this case the connection point name must be the name of the attribute to use
  20592. * Can only be set on inputs
  20593. */
  20594. get isAttribute(): boolean;
  20595. set isAttribute(value: boolean);
  20596. /**
  20597. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20598. * Can only be set on exit points
  20599. */
  20600. get isVarying(): boolean;
  20601. set isVarying(value: boolean);
  20602. /**
  20603. * Gets a boolean indicating that the current connection point is a system value
  20604. */
  20605. get isSystemValue(): boolean;
  20606. /**
  20607. * Gets or sets the current well known value or null if not defined as a system value
  20608. */
  20609. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20610. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20611. /**
  20612. * Gets the current class name
  20613. * @returns the class name
  20614. */
  20615. getClassName(): string;
  20616. /**
  20617. * Animate the input if animationType !== None
  20618. * @param scene defines the rendering scene
  20619. */
  20620. animate(scene: Scene): void;
  20621. private _emitDefine;
  20622. initialize(state: NodeMaterialBuildState): void;
  20623. /**
  20624. * Set the input block to its default value (based on its type)
  20625. */
  20626. setDefaultValue(): void;
  20627. private _emitConstant;
  20628. /** @hidden */
  20629. get _noContextSwitch(): boolean;
  20630. private _emit;
  20631. /** @hidden */
  20632. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20633. /** @hidden */
  20634. _transmit(effect: Effect, scene: Scene): void;
  20635. protected _buildBlock(state: NodeMaterialBuildState): void;
  20636. protected _dumpPropertiesCode(): string;
  20637. dispose(): void;
  20638. serialize(): any;
  20639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20640. }
  20641. }
  20642. declare module BABYLON {
  20643. /**
  20644. * Enum used to define the compatibility state between two connection points
  20645. */
  20646. export enum NodeMaterialConnectionPointCompatibilityStates {
  20647. /** Points are compatibles */
  20648. Compatible = 0,
  20649. /** Points are incompatible because of their types */
  20650. TypeIncompatible = 1,
  20651. /** Points are incompatible because of their targets (vertex vs fragment) */
  20652. TargetIncompatible = 2
  20653. }
  20654. /**
  20655. * Defines the direction of a connection point
  20656. */
  20657. export enum NodeMaterialConnectionPointDirection {
  20658. /** Input */
  20659. Input = 0,
  20660. /** Output */
  20661. Output = 1
  20662. }
  20663. /**
  20664. * Defines a connection point for a block
  20665. */
  20666. export class NodeMaterialConnectionPoint {
  20667. /** @hidden */
  20668. _ownerBlock: NodeMaterialBlock;
  20669. /** @hidden */
  20670. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20671. private _endpoints;
  20672. private _associatedVariableName;
  20673. private _direction;
  20674. /** @hidden */
  20675. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20676. /** @hidden */
  20677. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20678. private _type;
  20679. /** @hidden */
  20680. _enforceAssociatedVariableName: boolean;
  20681. /** Gets the direction of the point */
  20682. get direction(): NodeMaterialConnectionPointDirection;
  20683. /** Indicates that this connection point needs dual validation before being connected to another point */
  20684. needDualDirectionValidation: boolean;
  20685. /**
  20686. * Gets or sets the additional types supported by this connection point
  20687. */
  20688. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20689. /**
  20690. * Gets or sets the additional types excluded by this connection point
  20691. */
  20692. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20693. /**
  20694. * Observable triggered when this point is connected
  20695. */
  20696. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20697. /**
  20698. * Gets or sets the associated variable name in the shader
  20699. */
  20700. get associatedVariableName(): string;
  20701. set associatedVariableName(value: string);
  20702. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20703. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20704. /**
  20705. * Gets or sets the connection point type (default is float)
  20706. */
  20707. get type(): NodeMaterialBlockConnectionPointTypes;
  20708. set type(value: NodeMaterialBlockConnectionPointTypes);
  20709. /**
  20710. * Gets or sets the connection point name
  20711. */
  20712. name: string;
  20713. /**
  20714. * Gets or sets the connection point name
  20715. */
  20716. displayName: string;
  20717. /**
  20718. * Gets or sets a boolean indicating that this connection point can be omitted
  20719. */
  20720. isOptional: boolean;
  20721. /**
  20722. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20723. */
  20724. isExposedOnFrame: boolean;
  20725. /**
  20726. * Gets or sets number indicating the position that the port is exposed to on a frame
  20727. */
  20728. exposedPortPosition: number;
  20729. /**
  20730. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20731. */
  20732. define: string;
  20733. /** @hidden */
  20734. _prioritizeVertex: boolean;
  20735. private _target;
  20736. /** Gets or sets the target of that connection point */
  20737. get target(): NodeMaterialBlockTargets;
  20738. set target(value: NodeMaterialBlockTargets);
  20739. /**
  20740. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20741. */
  20742. get isConnected(): boolean;
  20743. /**
  20744. * Gets a boolean indicating that the current point is connected to an input block
  20745. */
  20746. get isConnectedToInputBlock(): boolean;
  20747. /**
  20748. * Gets a the connected input block (if any)
  20749. */
  20750. get connectInputBlock(): Nullable<InputBlock>;
  20751. /** Get the other side of the connection (if any) */
  20752. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20753. /** Get the block that owns this connection point */
  20754. get ownerBlock(): NodeMaterialBlock;
  20755. /** Get the block connected on the other side of this connection (if any) */
  20756. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20757. /** Get the block connected on the endpoints of this connection (if any) */
  20758. get connectedBlocks(): Array<NodeMaterialBlock>;
  20759. /** Gets the list of connected endpoints */
  20760. get endpoints(): NodeMaterialConnectionPoint[];
  20761. /** Gets a boolean indicating if that output point is connected to at least one input */
  20762. get hasEndpoints(): boolean;
  20763. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20764. get isConnectedInVertexShader(): boolean;
  20765. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20766. get isConnectedInFragmentShader(): boolean;
  20767. /**
  20768. * Creates a block suitable to be used as an input for this input point.
  20769. * If null is returned, a block based on the point type will be created.
  20770. * @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
  20771. */
  20772. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20773. /**
  20774. * Creates a new connection point
  20775. * @param name defines the connection point name
  20776. * @param ownerBlock defines the block hosting this connection point
  20777. * @param direction defines the direction of the connection point
  20778. */
  20779. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20780. /**
  20781. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20782. * @returns the class name
  20783. */
  20784. getClassName(): string;
  20785. /**
  20786. * Gets a boolean indicating if the current point can be connected to another point
  20787. * @param connectionPoint defines the other connection point
  20788. * @returns a boolean
  20789. */
  20790. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20791. /**
  20792. * Gets a number indicating if the current point can be connected to another point
  20793. * @param connectionPoint defines the other connection point
  20794. * @returns a number defining the compatibility state
  20795. */
  20796. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20797. /**
  20798. * Connect this point to another connection point
  20799. * @param connectionPoint defines the other connection point
  20800. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20801. * @returns the current connection point
  20802. */
  20803. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Disconnect this point from one of his endpoint
  20806. * @param endpoint defines the other connection point
  20807. * @returns the current connection point
  20808. */
  20809. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20810. /**
  20811. * Serializes this point in a JSON representation
  20812. * @param isInput defines if the connection point is an input (default is true)
  20813. * @returns the serialized point object
  20814. */
  20815. serialize(isInput?: boolean): any;
  20816. /**
  20817. * Release resources
  20818. */
  20819. dispose(): void;
  20820. }
  20821. }
  20822. declare module BABYLON {
  20823. /**
  20824. * Enum used to define the material modes
  20825. */
  20826. export enum NodeMaterialModes {
  20827. /** Regular material */
  20828. Material = 0,
  20829. /** For post process */
  20830. PostProcess = 1,
  20831. /** For particle system */
  20832. Particle = 2,
  20833. /** For procedural texture */
  20834. ProceduralTexture = 3
  20835. }
  20836. }
  20837. declare module BABYLON {
  20838. /**
  20839. * Block used to read a texture from a sampler
  20840. */
  20841. export class TextureBlock extends NodeMaterialBlock {
  20842. private _defineName;
  20843. private _linearDefineName;
  20844. private _gammaDefineName;
  20845. private _tempTextureRead;
  20846. private _samplerName;
  20847. private _transformedUVName;
  20848. private _textureTransformName;
  20849. private _textureInfoName;
  20850. private _mainUVName;
  20851. private _mainUVDefineName;
  20852. private _fragmentOnly;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<Texture>;
  20857. /**
  20858. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20859. */
  20860. convertToGammaSpace: boolean;
  20861. /**
  20862. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20863. */
  20864. convertToLinearSpace: boolean;
  20865. /**
  20866. * Create a new TextureBlock
  20867. * @param name defines the block name
  20868. */
  20869. constructor(name: string, fragmentOnly?: boolean);
  20870. /**
  20871. * Gets the current class name
  20872. * @returns the class name
  20873. */
  20874. getClassName(): string;
  20875. /**
  20876. * Gets the uv input component
  20877. */
  20878. get uv(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the rgba output component
  20881. */
  20882. get rgba(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the rgb output component
  20885. */
  20886. get rgb(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Gets the r output component
  20889. */
  20890. get r(): NodeMaterialConnectionPoint;
  20891. /**
  20892. * Gets the g output component
  20893. */
  20894. get g(): NodeMaterialConnectionPoint;
  20895. /**
  20896. * Gets the b output component
  20897. */
  20898. get b(): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Gets the a output component
  20901. */
  20902. get a(): NodeMaterialConnectionPoint;
  20903. get target(): NodeMaterialBlockTargets;
  20904. autoConfigure(material: NodeMaterial): void;
  20905. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20907. isReady(): boolean;
  20908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20909. private get _isMixed();
  20910. private _injectVertexCode;
  20911. private _writeTextureRead;
  20912. private _writeOutput;
  20913. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20914. protected _dumpPropertiesCode(): string;
  20915. serialize(): any;
  20916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20917. }
  20918. }
  20919. declare module BABYLON {
  20920. /** @hidden */
  20921. export var reflectionFunction: {
  20922. name: string;
  20923. shader: string;
  20924. };
  20925. }
  20926. declare module BABYLON {
  20927. /**
  20928. * Base block used to read a reflection texture from a sampler
  20929. */
  20930. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20931. /** @hidden */
  20932. _define3DName: string;
  20933. /** @hidden */
  20934. _defineCubicName: string;
  20935. /** @hidden */
  20936. _defineExplicitName: string;
  20937. /** @hidden */
  20938. _defineProjectionName: string;
  20939. /** @hidden */
  20940. _defineLocalCubicName: string;
  20941. /** @hidden */
  20942. _defineSphericalName: string;
  20943. /** @hidden */
  20944. _definePlanarName: string;
  20945. /** @hidden */
  20946. _defineEquirectangularName: string;
  20947. /** @hidden */
  20948. _defineMirroredEquirectangularFixedName: string;
  20949. /** @hidden */
  20950. _defineEquirectangularFixedName: string;
  20951. /** @hidden */
  20952. _defineSkyboxName: string;
  20953. /** @hidden */
  20954. _defineOppositeZ: string;
  20955. /** @hidden */
  20956. _cubeSamplerName: string;
  20957. /** @hidden */
  20958. _2DSamplerName: string;
  20959. protected _positionUVWName: string;
  20960. protected _directionWName: string;
  20961. protected _reflectionVectorName: string;
  20962. /** @hidden */
  20963. _reflectionCoordsName: string;
  20964. /** @hidden */
  20965. _reflectionMatrixName: string;
  20966. protected _reflectionColorName: string;
  20967. /**
  20968. * Gets or sets the texture associated with the node
  20969. */
  20970. texture: Nullable<BaseTexture>;
  20971. /**
  20972. * Create a new ReflectionTextureBaseBlock
  20973. * @param name defines the block name
  20974. */
  20975. constructor(name: string);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Gets the world position input component
  20983. */
  20984. abstract get position(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the world position input component
  20987. */
  20988. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the world normal input component
  20991. */
  20992. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the world input component
  20995. */
  20996. abstract get world(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the camera (or eye) position component
  20999. */
  21000. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Gets the view input component
  21003. */
  21004. abstract get view(): NodeMaterialConnectionPoint;
  21005. protected _getTexture(): Nullable<BaseTexture>;
  21006. autoConfigure(material: NodeMaterial): void;
  21007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21008. isReady(): boolean;
  21009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21010. /**
  21011. * Gets the code to inject in the vertex shader
  21012. * @param state current state of the node material building
  21013. * @returns the shader code
  21014. */
  21015. handleVertexSide(state: NodeMaterialBuildState): string;
  21016. /**
  21017. * Handles the inits for the fragment code path
  21018. * @param state node material build state
  21019. */
  21020. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21021. /**
  21022. * Generates the reflection coords code for the fragment code path
  21023. * @param worldNormalVarName name of the world normal variable
  21024. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21025. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21026. * @returns the shader code
  21027. */
  21028. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21029. /**
  21030. * Generates the reflection color code for the fragment code path
  21031. * @param lodVarName name of the lod variable
  21032. * @param swizzleLookupTexture swizzle to use for the final color variable
  21033. * @returns the shader code
  21034. */
  21035. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21036. /**
  21037. * Generates the code corresponding to the connected output points
  21038. * @param state node material build state
  21039. * @param varName name of the variable to output
  21040. * @returns the shader code
  21041. */
  21042. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21043. protected _buildBlock(state: NodeMaterialBuildState): this;
  21044. protected _dumpPropertiesCode(): string;
  21045. serialize(): any;
  21046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21047. }
  21048. }
  21049. declare module BABYLON {
  21050. /**
  21051. * Defines a connection point to be used for points with a custom object type
  21052. */
  21053. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21054. private _blockType;
  21055. private _blockName;
  21056. private _nameForCheking?;
  21057. /**
  21058. * Creates a new connection point
  21059. * @param name defines the connection point name
  21060. * @param ownerBlock defines the block hosting this connection point
  21061. * @param direction defines the direction of the connection point
  21062. */
  21063. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21064. /**
  21065. * Gets a number indicating if the current point can be connected to another point
  21066. * @param connectionPoint defines the other connection point
  21067. * @returns a number defining the compatibility state
  21068. */
  21069. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21070. /**
  21071. * Creates a block suitable to be used as an input for this input point.
  21072. * If null is returned, a block based on the point type will be created.
  21073. * @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
  21074. */
  21075. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21076. }
  21077. }
  21078. declare module BABYLON {
  21079. /**
  21080. * Enum defining the type of properties that can be edited in the property pages in the NME
  21081. */
  21082. export enum PropertyTypeForEdition {
  21083. /** property is a boolean */
  21084. Boolean = 0,
  21085. /** property is a float */
  21086. Float = 1,
  21087. /** property is a Vector2 */
  21088. Vector2 = 2,
  21089. /** property is a list of values */
  21090. List = 3
  21091. }
  21092. /**
  21093. * Interface that defines an option in a variable of type list
  21094. */
  21095. export interface IEditablePropertyListOption {
  21096. /** label of the option */
  21097. "label": string;
  21098. /** value of the option */
  21099. "value": number;
  21100. }
  21101. /**
  21102. * Interface that defines the options available for an editable property
  21103. */
  21104. export interface IEditablePropertyOption {
  21105. /** min value */
  21106. "min"?: number;
  21107. /** max value */
  21108. "max"?: number;
  21109. /** notifiers: indicates which actions to take when the property is changed */
  21110. "notifiers"?: {
  21111. /** the material should be rebuilt */
  21112. "rebuild"?: boolean;
  21113. /** the preview should be updated */
  21114. "update"?: boolean;
  21115. };
  21116. /** list of the options for a variable of type list */
  21117. "options"?: IEditablePropertyListOption[];
  21118. }
  21119. /**
  21120. * Interface that describes an editable property
  21121. */
  21122. export interface IPropertyDescriptionForEdition {
  21123. /** name of the property */
  21124. "propertyName": string;
  21125. /** display name of the property */
  21126. "displayName": string;
  21127. /** type of the property */
  21128. "type": PropertyTypeForEdition;
  21129. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21130. "groupName": string;
  21131. /** options for the property */
  21132. "options": IEditablePropertyOption;
  21133. }
  21134. /**
  21135. * Decorator that flags a property in a node material block as being editable
  21136. */
  21137. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21138. }
  21139. declare module BABYLON {
  21140. /**
  21141. * Block used to implement the refraction part of the sub surface module of the PBR material
  21142. */
  21143. export class RefractionBlock extends NodeMaterialBlock {
  21144. /** @hidden */
  21145. _define3DName: string;
  21146. /** @hidden */
  21147. _refractionMatrixName: string;
  21148. /** @hidden */
  21149. _defineLODRefractionAlpha: string;
  21150. /** @hidden */
  21151. _defineLinearSpecularRefraction: string;
  21152. /** @hidden */
  21153. _defineOppositeZ: string;
  21154. /** @hidden */
  21155. _cubeSamplerName: string;
  21156. /** @hidden */
  21157. _2DSamplerName: string;
  21158. /** @hidden */
  21159. _vRefractionMicrosurfaceInfosName: string;
  21160. /** @hidden */
  21161. _vRefractionInfosName: string;
  21162. private _scene;
  21163. /**
  21164. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21165. * Materials half opaque for instance using refraction could benefit from this control.
  21166. */
  21167. linkRefractionWithTransparency: boolean;
  21168. /**
  21169. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21170. */
  21171. invertRefractionY: boolean;
  21172. /**
  21173. * Gets or sets the texture associated with the node
  21174. */
  21175. texture: Nullable<BaseTexture>;
  21176. /**
  21177. * Create a new RefractionBlock
  21178. * @param name defines the block name
  21179. */
  21180. constructor(name: string);
  21181. /**
  21182. * Gets the current class name
  21183. * @returns the class name
  21184. */
  21185. getClassName(): string;
  21186. /**
  21187. * Gets the intensity input component
  21188. */
  21189. get intensity(): NodeMaterialConnectionPoint;
  21190. /**
  21191. * Gets the index of refraction input component
  21192. */
  21193. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21194. /**
  21195. * Gets the tint at distance input component
  21196. */
  21197. get tintAtDistance(): NodeMaterialConnectionPoint;
  21198. /**
  21199. * Gets the view input component
  21200. */
  21201. get view(): NodeMaterialConnectionPoint;
  21202. /**
  21203. * Gets the refraction object output component
  21204. */
  21205. get refraction(): NodeMaterialConnectionPoint;
  21206. /**
  21207. * Returns true if the block has a texture
  21208. */
  21209. get hasTexture(): boolean;
  21210. protected _getTexture(): Nullable<BaseTexture>;
  21211. autoConfigure(material: NodeMaterial): void;
  21212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21213. isReady(): boolean;
  21214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21215. /**
  21216. * Gets the main code of the block (fragment side)
  21217. * @param state current state of the node material building
  21218. * @returns the shader code
  21219. */
  21220. getCode(state: NodeMaterialBuildState): string;
  21221. protected _buildBlock(state: NodeMaterialBuildState): this;
  21222. protected _dumpPropertiesCode(): string;
  21223. serialize(): any;
  21224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21225. }
  21226. }
  21227. declare module BABYLON {
  21228. /**
  21229. * Base block used as input for post process
  21230. */
  21231. export class CurrentScreenBlock extends NodeMaterialBlock {
  21232. private _samplerName;
  21233. private _linearDefineName;
  21234. private _gammaDefineName;
  21235. private _mainUVName;
  21236. private _tempTextureRead;
  21237. /**
  21238. * Gets or sets the texture associated with the node
  21239. */
  21240. texture: Nullable<BaseTexture>;
  21241. /**
  21242. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21243. */
  21244. convertToGammaSpace: boolean;
  21245. /**
  21246. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21247. */
  21248. convertToLinearSpace: boolean;
  21249. /**
  21250. * Create a new CurrentScreenBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the uv input component
  21261. */
  21262. get uv(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the rgba output component
  21265. */
  21266. get rgba(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the rgb output component
  21269. */
  21270. get rgb(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the r output component
  21273. */
  21274. get r(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the g output component
  21277. */
  21278. get g(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the b output component
  21281. */
  21282. get b(): NodeMaterialConnectionPoint;
  21283. /**
  21284. * Gets the a output component
  21285. */
  21286. get a(): NodeMaterialConnectionPoint;
  21287. /**
  21288. * Initialize the block and prepare the context for build
  21289. * @param state defines the state that will be used for the build
  21290. */
  21291. initialize(state: NodeMaterialBuildState): void;
  21292. get target(): NodeMaterialBlockTargets;
  21293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21294. isReady(): boolean;
  21295. private _injectVertexCode;
  21296. private _writeTextureRead;
  21297. private _writeOutput;
  21298. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21299. serialize(): any;
  21300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21301. }
  21302. }
  21303. declare module BABYLON {
  21304. /**
  21305. * Base block used for the particle texture
  21306. */
  21307. export class ParticleTextureBlock extends NodeMaterialBlock {
  21308. private _samplerName;
  21309. private _linearDefineName;
  21310. private _gammaDefineName;
  21311. private _tempTextureRead;
  21312. /**
  21313. * Gets or sets the texture associated with the node
  21314. */
  21315. texture: Nullable<BaseTexture>;
  21316. /**
  21317. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21318. */
  21319. convertToGammaSpace: boolean;
  21320. /**
  21321. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21322. */
  21323. convertToLinearSpace: boolean;
  21324. /**
  21325. * Create a new ParticleTextureBlock
  21326. * @param name defines the block name
  21327. */
  21328. constructor(name: string);
  21329. /**
  21330. * Gets the current class name
  21331. * @returns the class name
  21332. */
  21333. getClassName(): string;
  21334. /**
  21335. * Gets the uv input component
  21336. */
  21337. get uv(): NodeMaterialConnectionPoint;
  21338. /**
  21339. * Gets the rgba output component
  21340. */
  21341. get rgba(): NodeMaterialConnectionPoint;
  21342. /**
  21343. * Gets the rgb output component
  21344. */
  21345. get rgb(): NodeMaterialConnectionPoint;
  21346. /**
  21347. * Gets the r output component
  21348. */
  21349. get r(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the g output component
  21352. */
  21353. get g(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the b output component
  21356. */
  21357. get b(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the a output component
  21360. */
  21361. get a(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Initialize the block and prepare the context for build
  21364. * @param state defines the state that will be used for the build
  21365. */
  21366. initialize(state: NodeMaterialBuildState): void;
  21367. autoConfigure(material: NodeMaterial): void;
  21368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21369. isReady(): boolean;
  21370. private _writeOutput;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21372. serialize(): any;
  21373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21374. }
  21375. }
  21376. declare module BABYLON {
  21377. /**
  21378. * Class used to store shared data between 2 NodeMaterialBuildState
  21379. */
  21380. export class NodeMaterialBuildStateSharedData {
  21381. /**
  21382. * Gets the list of emitted varyings
  21383. */
  21384. temps: string[];
  21385. /**
  21386. * Gets the list of emitted varyings
  21387. */
  21388. varyings: string[];
  21389. /**
  21390. * Gets the varying declaration string
  21391. */
  21392. varyingDeclaration: string;
  21393. /**
  21394. * Input blocks
  21395. */
  21396. inputBlocks: InputBlock[];
  21397. /**
  21398. * Input blocks
  21399. */
  21400. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21401. /**
  21402. * Bindable blocks (Blocks that need to set data to the effect)
  21403. */
  21404. bindableBlocks: NodeMaterialBlock[];
  21405. /**
  21406. * List of blocks that can provide a compilation fallback
  21407. */
  21408. blocksWithFallbacks: NodeMaterialBlock[];
  21409. /**
  21410. * List of blocks that can provide a define update
  21411. */
  21412. blocksWithDefines: NodeMaterialBlock[];
  21413. /**
  21414. * List of blocks that can provide a repeatable content
  21415. */
  21416. repeatableContentBlocks: NodeMaterialBlock[];
  21417. /**
  21418. * List of blocks that can provide a dynamic list of uniforms
  21419. */
  21420. dynamicUniformBlocks: NodeMaterialBlock[];
  21421. /**
  21422. * List of blocks that can block the isReady function for the material
  21423. */
  21424. blockingBlocks: NodeMaterialBlock[];
  21425. /**
  21426. * Gets the list of animated inputs
  21427. */
  21428. animatedInputs: InputBlock[];
  21429. /**
  21430. * Build Id used to avoid multiple recompilations
  21431. */
  21432. buildId: number;
  21433. /** List of emitted variables */
  21434. variableNames: {
  21435. [key: string]: number;
  21436. };
  21437. /** List of emitted defines */
  21438. defineNames: {
  21439. [key: string]: number;
  21440. };
  21441. /** Should emit comments? */
  21442. emitComments: boolean;
  21443. /** Emit build activity */
  21444. verbose: boolean;
  21445. /** Gets or sets the hosting scene */
  21446. scene: Scene;
  21447. /**
  21448. * Gets the compilation hints emitted at compilation time
  21449. */
  21450. hints: {
  21451. needWorldViewMatrix: boolean;
  21452. needWorldViewProjectionMatrix: boolean;
  21453. needAlphaBlending: boolean;
  21454. needAlphaTesting: boolean;
  21455. };
  21456. /**
  21457. * List of compilation checks
  21458. */
  21459. checks: {
  21460. emitVertex: boolean;
  21461. emitFragment: boolean;
  21462. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21463. };
  21464. /**
  21465. * Is vertex program allowed to be empty?
  21466. */
  21467. allowEmptyVertexProgram: boolean;
  21468. /** Creates a new shared data */
  21469. constructor();
  21470. /**
  21471. * Emits console errors and exceptions if there is a failing check
  21472. */
  21473. emitErrors(): void;
  21474. }
  21475. }
  21476. declare module BABYLON {
  21477. /**
  21478. * Class used to store node based material build state
  21479. */
  21480. export class NodeMaterialBuildState {
  21481. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21482. supportUniformBuffers: boolean;
  21483. /**
  21484. * Gets the list of emitted attributes
  21485. */
  21486. attributes: string[];
  21487. /**
  21488. * Gets the list of emitted uniforms
  21489. */
  21490. uniforms: string[];
  21491. /**
  21492. * Gets the list of emitted constants
  21493. */
  21494. constants: string[];
  21495. /**
  21496. * Gets the list of emitted samplers
  21497. */
  21498. samplers: string[];
  21499. /**
  21500. * Gets the list of emitted functions
  21501. */
  21502. functions: {
  21503. [key: string]: string;
  21504. };
  21505. /**
  21506. * Gets the list of emitted extensions
  21507. */
  21508. extensions: {
  21509. [key: string]: string;
  21510. };
  21511. /**
  21512. * Gets the target of the compilation state
  21513. */
  21514. target: NodeMaterialBlockTargets;
  21515. /**
  21516. * Gets the list of emitted counters
  21517. */
  21518. counters: {
  21519. [key: string]: number;
  21520. };
  21521. /**
  21522. * Shared data between multiple NodeMaterialBuildState instances
  21523. */
  21524. sharedData: NodeMaterialBuildStateSharedData;
  21525. /** @hidden */
  21526. _vertexState: NodeMaterialBuildState;
  21527. /** @hidden */
  21528. _attributeDeclaration: string;
  21529. /** @hidden */
  21530. _uniformDeclaration: string;
  21531. /** @hidden */
  21532. _constantDeclaration: string;
  21533. /** @hidden */
  21534. _samplerDeclaration: string;
  21535. /** @hidden */
  21536. _varyingTransfer: string;
  21537. /** @hidden */
  21538. _injectAtEnd: string;
  21539. private _repeatableContentAnchorIndex;
  21540. /** @hidden */
  21541. _builtCompilationString: string;
  21542. /**
  21543. * Gets the emitted compilation strings
  21544. */
  21545. compilationString: string;
  21546. /**
  21547. * Finalize the compilation strings
  21548. * @param state defines the current compilation state
  21549. */
  21550. finalize(state: NodeMaterialBuildState): void;
  21551. /** @hidden */
  21552. get _repeatableContentAnchor(): string;
  21553. /** @hidden */
  21554. _getFreeVariableName(prefix: string): string;
  21555. /** @hidden */
  21556. _getFreeDefineName(prefix: string): string;
  21557. /** @hidden */
  21558. _excludeVariableName(name: string): void;
  21559. /** @hidden */
  21560. _emit2DSampler(name: string): void;
  21561. /** @hidden */
  21562. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21563. /** @hidden */
  21564. _emitExtension(name: string, extension: string, define?: string): void;
  21565. /** @hidden */
  21566. _emitFunction(name: string, code: string, comments: string): void;
  21567. /** @hidden */
  21568. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21569. replaceStrings?: {
  21570. search: RegExp;
  21571. replace: string;
  21572. }[];
  21573. repeatKey?: string;
  21574. }): string;
  21575. /** @hidden */
  21576. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21577. repeatKey?: string;
  21578. removeAttributes?: boolean;
  21579. removeUniforms?: boolean;
  21580. removeVaryings?: boolean;
  21581. removeIfDef?: boolean;
  21582. replaceStrings?: {
  21583. search: RegExp;
  21584. replace: string;
  21585. }[];
  21586. }, storeKey?: string): void;
  21587. /** @hidden */
  21588. _registerTempVariable(name: string): boolean;
  21589. /** @hidden */
  21590. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21591. /** @hidden */
  21592. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21593. /** @hidden */
  21594. _emitFloat(value: number): string;
  21595. }
  21596. }
  21597. declare module BABYLON {
  21598. /**
  21599. * Helper class used to generate session unique ID
  21600. */
  21601. export class UniqueIdGenerator {
  21602. private static _UniqueIdCounter;
  21603. /**
  21604. * Gets an unique (relatively to the current scene) Id
  21605. */
  21606. static get UniqueId(): number;
  21607. }
  21608. }
  21609. declare module BABYLON {
  21610. /**
  21611. * Defines a block that can be used inside a node based material
  21612. */
  21613. export class NodeMaterialBlock {
  21614. private _buildId;
  21615. private _buildTarget;
  21616. private _target;
  21617. private _isFinalMerger;
  21618. private _isInput;
  21619. private _name;
  21620. protected _isUnique: boolean;
  21621. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21622. inputsAreExclusive: boolean;
  21623. /** @hidden */
  21624. _codeVariableName: string;
  21625. /** @hidden */
  21626. _inputs: NodeMaterialConnectionPoint[];
  21627. /** @hidden */
  21628. _outputs: NodeMaterialConnectionPoint[];
  21629. /** @hidden */
  21630. _preparationId: number;
  21631. /**
  21632. * Gets the name of the block
  21633. */
  21634. get name(): string;
  21635. /**
  21636. * Sets the name of the block. Will check if the name is valid.
  21637. */
  21638. set name(newName: string);
  21639. /**
  21640. * Gets or sets the unique id of the node
  21641. */
  21642. uniqueId: number;
  21643. /**
  21644. * Gets or sets the comments associated with this block
  21645. */
  21646. comments: string;
  21647. /**
  21648. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21649. */
  21650. get isUnique(): boolean;
  21651. /**
  21652. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21653. */
  21654. get isFinalMerger(): boolean;
  21655. /**
  21656. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21657. */
  21658. get isInput(): boolean;
  21659. /**
  21660. * Gets or sets the build Id
  21661. */
  21662. get buildId(): number;
  21663. set buildId(value: number);
  21664. /**
  21665. * Gets or sets the target of the block
  21666. */
  21667. get target(): NodeMaterialBlockTargets;
  21668. set target(value: NodeMaterialBlockTargets);
  21669. /**
  21670. * Gets the list of input points
  21671. */
  21672. get inputs(): NodeMaterialConnectionPoint[];
  21673. /** Gets the list of output points */
  21674. get outputs(): NodeMaterialConnectionPoint[];
  21675. /**
  21676. * Find an input by its name
  21677. * @param name defines the name of the input to look for
  21678. * @returns the input or null if not found
  21679. */
  21680. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21681. /**
  21682. * Find an output by its name
  21683. * @param name defines the name of the outputto look for
  21684. * @returns the output or null if not found
  21685. */
  21686. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21687. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21688. visibleInInspector: boolean;
  21689. /**
  21690. * Creates a new NodeMaterialBlock
  21691. * @param name defines the block name
  21692. * @param target defines the target of that block (Vertex by default)
  21693. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21694. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21695. */
  21696. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21697. /**
  21698. * Initialize the block and prepare the context for build
  21699. * @param state defines the state that will be used for the build
  21700. */
  21701. initialize(state: NodeMaterialBuildState): void;
  21702. /**
  21703. * Bind data to effect. Will only be called for blocks with isBindable === true
  21704. * @param effect defines the effect to bind data to
  21705. * @param nodeMaterial defines the hosting NodeMaterial
  21706. * @param mesh defines the mesh that will be rendered
  21707. * @param subMesh defines the submesh that will be rendered
  21708. */
  21709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21710. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21711. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21712. protected _writeFloat(value: number): string;
  21713. /**
  21714. * Gets the current class name e.g. "NodeMaterialBlock"
  21715. * @returns the class name
  21716. */
  21717. getClassName(): string;
  21718. /**
  21719. * Register a new input. Must be called inside a block constructor
  21720. * @param name defines the connection point name
  21721. * @param type defines the connection point type
  21722. * @param isOptional defines a boolean indicating that this input can be omitted
  21723. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21724. * @param point an already created connection point. If not provided, create a new one
  21725. * @returns the current block
  21726. */
  21727. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21728. /**
  21729. * Register a new output. Must be called inside a block constructor
  21730. * @param name defines the connection point name
  21731. * @param type defines the connection point type
  21732. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21733. * @param point an already created connection point. If not provided, create a new one
  21734. * @returns the current block
  21735. */
  21736. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21737. /**
  21738. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21739. * @param forOutput defines an optional connection point to check compatibility with
  21740. * @returns the first available input or null
  21741. */
  21742. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21743. /**
  21744. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21745. * @param forBlock defines an optional block to check compatibility with
  21746. * @returns the first available input or null
  21747. */
  21748. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21749. /**
  21750. * Gets the sibling of the given output
  21751. * @param current defines the current output
  21752. * @returns the next output in the list or null
  21753. */
  21754. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21755. /**
  21756. * Connect current block with another block
  21757. * @param other defines the block to connect with
  21758. * @param options define the various options to help pick the right connections
  21759. * @returns the current block
  21760. */
  21761. connectTo(other: NodeMaterialBlock, options?: {
  21762. input?: string;
  21763. output?: string;
  21764. outputSwizzle?: string;
  21765. }): this | undefined;
  21766. protected _buildBlock(state: NodeMaterialBuildState): void;
  21767. /**
  21768. * Add uniforms, samplers and uniform buffers at compilation time
  21769. * @param state defines the state to update
  21770. * @param nodeMaterial defines the node material requesting the update
  21771. * @param defines defines the material defines to update
  21772. * @param uniformBuffers defines the list of uniform buffer names
  21773. */
  21774. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21775. /**
  21776. * Add potential fallbacks if shader compilation fails
  21777. * @param mesh defines the mesh to be rendered
  21778. * @param fallbacks defines the current prioritized list of fallbacks
  21779. */
  21780. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21781. /**
  21782. * Initialize defines for shader compilation
  21783. * @param mesh defines the mesh to be rendered
  21784. * @param nodeMaterial defines the node material requesting the update
  21785. * @param defines defines the material defines to update
  21786. * @param useInstances specifies that instances should be used
  21787. */
  21788. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21789. /**
  21790. * Update defines for shader compilation
  21791. * @param mesh defines the mesh to be rendered
  21792. * @param nodeMaterial defines the node material requesting the update
  21793. * @param defines defines the material defines to update
  21794. * @param useInstances specifies that instances should be used
  21795. * @param subMesh defines which submesh to render
  21796. */
  21797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21798. /**
  21799. * Lets the block try to connect some inputs automatically
  21800. * @param material defines the hosting NodeMaterial
  21801. */
  21802. autoConfigure(material: NodeMaterial): void;
  21803. /**
  21804. * Function called when a block is declared as repeatable content generator
  21805. * @param vertexShaderState defines the current compilation state for the vertex shader
  21806. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21807. * @param mesh defines the mesh to be rendered
  21808. * @param defines defines the material defines to update
  21809. */
  21810. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21811. /**
  21812. * Checks if the block is ready
  21813. * @param mesh defines the mesh to be rendered
  21814. * @param nodeMaterial defines the node material requesting the update
  21815. * @param defines defines the material defines to update
  21816. * @param useInstances specifies that instances should be used
  21817. * @returns true if the block is ready
  21818. */
  21819. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21820. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21821. private _processBuild;
  21822. /**
  21823. * Validates the new name for the block node.
  21824. * @param newName the new name to be given to the node.
  21825. * @returns false if the name is a reserve word, else true.
  21826. */
  21827. validateBlockName(newName: string): boolean;
  21828. /**
  21829. * Compile the current node and generate the shader code
  21830. * @param state defines the current compilation state (uniforms, samplers, current string)
  21831. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21832. * @returns true if already built
  21833. */
  21834. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21835. protected _inputRename(name: string): string;
  21836. protected _outputRename(name: string): string;
  21837. protected _dumpPropertiesCode(): string;
  21838. /** @hidden */
  21839. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21840. /** @hidden */
  21841. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21842. /**
  21843. * Clone the current block to a new identical block
  21844. * @param scene defines the hosting scene
  21845. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21846. * @returns a copy of the current block
  21847. */
  21848. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21849. /**
  21850. * Serializes this block in a JSON representation
  21851. * @returns the serialized block object
  21852. */
  21853. serialize(): any;
  21854. /** @hidden */
  21855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21856. private _deserializePortDisplayNamesAndExposedOnFrame;
  21857. /**
  21858. * Release resources
  21859. */
  21860. dispose(): void;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * Base class of materials working in push mode in babylon JS
  21866. * @hidden
  21867. */
  21868. export class PushMaterial extends Material {
  21869. protected _activeEffect: Effect;
  21870. protected _normalMatrix: Matrix;
  21871. constructor(name: string, scene: Scene);
  21872. getEffect(): Effect;
  21873. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21874. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21875. /**
  21876. * Binds the given world matrix to the active effect
  21877. *
  21878. * @param world the matrix to bind
  21879. */
  21880. bindOnlyWorldMatrix(world: Matrix): void;
  21881. /**
  21882. * Binds the given normal matrix to the active effect
  21883. *
  21884. * @param normalMatrix the matrix to bind
  21885. */
  21886. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21887. bind(world: Matrix, mesh?: Mesh): void;
  21888. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21889. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21890. }
  21891. }
  21892. declare module BABYLON {
  21893. /**
  21894. * Root class for all node material optimizers
  21895. */
  21896. export class NodeMaterialOptimizer {
  21897. /**
  21898. * Function used to optimize a NodeMaterial graph
  21899. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21900. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21901. */
  21902. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21903. }
  21904. }
  21905. declare module BABYLON {
  21906. /**
  21907. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21908. */
  21909. export class TransformBlock extends NodeMaterialBlock {
  21910. /**
  21911. * Defines the value to use to complement W value to transform it to a Vector4
  21912. */
  21913. complementW: number;
  21914. /**
  21915. * Defines the value to use to complement z value to transform it to a Vector4
  21916. */
  21917. complementZ: number;
  21918. /**
  21919. * Creates a new TransformBlock
  21920. * @param name defines the block name
  21921. */
  21922. constructor(name: string);
  21923. /**
  21924. * Gets the current class name
  21925. * @returns the class name
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Gets the vector input
  21930. */
  21931. get vector(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the output component
  21934. */
  21935. get output(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the xyz output component
  21938. */
  21939. get xyz(): NodeMaterialConnectionPoint;
  21940. /**
  21941. * Gets the matrix transform input
  21942. */
  21943. get transform(): NodeMaterialConnectionPoint;
  21944. protected _buildBlock(state: NodeMaterialBuildState): this;
  21945. /**
  21946. * Update defines for shader compilation
  21947. * @param mesh defines the mesh to be rendered
  21948. * @param nodeMaterial defines the node material requesting the update
  21949. * @param defines defines the material defines to update
  21950. * @param useInstances specifies that instances should be used
  21951. * @param subMesh defines which submesh to render
  21952. */
  21953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21954. serialize(): any;
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. protected _dumpPropertiesCode(): string;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Block used to output the vertex position
  21962. */
  21963. export class VertexOutputBlock extends NodeMaterialBlock {
  21964. /**
  21965. * Creates a new VertexOutputBlock
  21966. * @param name defines the block name
  21967. */
  21968. constructor(name: string);
  21969. /**
  21970. * Gets the current class name
  21971. * @returns the class name
  21972. */
  21973. getClassName(): string;
  21974. /**
  21975. * Gets the vector input component
  21976. */
  21977. get vector(): NodeMaterialConnectionPoint;
  21978. protected _buildBlock(state: NodeMaterialBuildState): this;
  21979. }
  21980. }
  21981. declare module BABYLON {
  21982. /**
  21983. * Block used to output the final color
  21984. */
  21985. export class FragmentOutputBlock extends NodeMaterialBlock {
  21986. /**
  21987. * Create a new FragmentOutputBlock
  21988. * @param name defines the block name
  21989. */
  21990. constructor(name: string);
  21991. /**
  21992. * Gets the current class name
  21993. * @returns the class name
  21994. */
  21995. getClassName(): string;
  21996. /**
  21997. * Gets the rgba input component
  21998. */
  21999. get rgba(): NodeMaterialConnectionPoint;
  22000. /**
  22001. * Gets the rgb input component
  22002. */
  22003. get rgb(): NodeMaterialConnectionPoint;
  22004. /**
  22005. * Gets the a input component
  22006. */
  22007. get a(): NodeMaterialConnectionPoint;
  22008. protected _buildBlock(state: NodeMaterialBuildState): this;
  22009. }
  22010. }
  22011. declare module BABYLON {
  22012. /**
  22013. * Block used for the particle ramp gradient section
  22014. */
  22015. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22016. /**
  22017. * Create a new ParticleRampGradientBlock
  22018. * @param name defines the block name
  22019. */
  22020. constructor(name: string);
  22021. /**
  22022. * Gets the current class name
  22023. * @returns the class name
  22024. */
  22025. getClassName(): string;
  22026. /**
  22027. * Gets the color input component
  22028. */
  22029. get color(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the rampColor output component
  22032. */
  22033. get rampColor(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Initialize the block and prepare the context for build
  22036. * @param state defines the state that will be used for the build
  22037. */
  22038. initialize(state: NodeMaterialBuildState): void;
  22039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22040. }
  22041. }
  22042. declare module BABYLON {
  22043. /**
  22044. * Block used for the particle blend multiply section
  22045. */
  22046. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22047. /**
  22048. * Create a new ParticleBlendMultiplyBlock
  22049. * @param name defines the block name
  22050. */
  22051. constructor(name: string);
  22052. /**
  22053. * Gets the current class name
  22054. * @returns the class name
  22055. */
  22056. getClassName(): string;
  22057. /**
  22058. * Gets the color input component
  22059. */
  22060. get color(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the alphaTexture input component
  22063. */
  22064. get alphaTexture(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Gets the alphaColor input component
  22067. */
  22068. get alphaColor(): NodeMaterialConnectionPoint;
  22069. /**
  22070. * Gets the blendColor output component
  22071. */
  22072. get blendColor(): NodeMaterialConnectionPoint;
  22073. /**
  22074. * Initialize the block and prepare the context for build
  22075. * @param state defines the state that will be used for the build
  22076. */
  22077. initialize(state: NodeMaterialBuildState): void;
  22078. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. /**
  22083. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22084. */
  22085. export class VectorMergerBlock extends NodeMaterialBlock {
  22086. /**
  22087. * Create a new VectorMergerBlock
  22088. * @param name defines the block name
  22089. */
  22090. constructor(name: string);
  22091. /**
  22092. * Gets the current class name
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Gets the xyz component (input)
  22098. */
  22099. get xyzIn(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the xy component (input)
  22102. */
  22103. get xyIn(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the x component (input)
  22106. */
  22107. get x(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the y component (input)
  22110. */
  22111. get y(): NodeMaterialConnectionPoint;
  22112. /**
  22113. * Gets the z component (input)
  22114. */
  22115. get z(): NodeMaterialConnectionPoint;
  22116. /**
  22117. * Gets the w component (input)
  22118. */
  22119. get w(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the xyzw component (output)
  22122. */
  22123. get xyzw(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the xyz component (output)
  22126. */
  22127. get xyzOut(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Gets the xy component (output)
  22130. */
  22131. get xyOut(): NodeMaterialConnectionPoint;
  22132. /**
  22133. * Gets the xy component (output)
  22134. * @deprecated Please use xyOut instead.
  22135. */
  22136. get xy(): NodeMaterialConnectionPoint;
  22137. /**
  22138. * Gets the xyz component (output)
  22139. * @deprecated Please use xyzOut instead.
  22140. */
  22141. get xyz(): NodeMaterialConnectionPoint;
  22142. protected _buildBlock(state: NodeMaterialBuildState): this;
  22143. }
  22144. }
  22145. declare module BABYLON {
  22146. /**
  22147. * Block used to remap a float from a range to a new one
  22148. */
  22149. export class RemapBlock extends NodeMaterialBlock {
  22150. /**
  22151. * Gets or sets the source range
  22152. */
  22153. sourceRange: Vector2;
  22154. /**
  22155. * Gets or sets the target range
  22156. */
  22157. targetRange: Vector2;
  22158. /**
  22159. * Creates a new RemapBlock
  22160. * @param name defines the block name
  22161. */
  22162. constructor(name: string);
  22163. /**
  22164. * Gets the current class name
  22165. * @returns the class name
  22166. */
  22167. getClassName(): string;
  22168. /**
  22169. * Gets the input component
  22170. */
  22171. get input(): NodeMaterialConnectionPoint;
  22172. /**
  22173. * Gets the source min input component
  22174. */
  22175. get sourceMin(): NodeMaterialConnectionPoint;
  22176. /**
  22177. * Gets the source max input component
  22178. */
  22179. get sourceMax(): NodeMaterialConnectionPoint;
  22180. /**
  22181. * Gets the target min input component
  22182. */
  22183. get targetMin(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the target max input component
  22186. */
  22187. get targetMax(): NodeMaterialConnectionPoint;
  22188. /**
  22189. * Gets the output component
  22190. */
  22191. get output(): NodeMaterialConnectionPoint;
  22192. protected _buildBlock(state: NodeMaterialBuildState): this;
  22193. protected _dumpPropertiesCode(): string;
  22194. serialize(): any;
  22195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22196. }
  22197. }
  22198. declare module BABYLON {
  22199. /**
  22200. * Block used to multiply 2 values
  22201. */
  22202. export class MultiplyBlock extends NodeMaterialBlock {
  22203. /**
  22204. * Creates a new MultiplyBlock
  22205. * @param name defines the block name
  22206. */
  22207. constructor(name: string);
  22208. /**
  22209. * Gets the current class name
  22210. * @returns the class name
  22211. */
  22212. getClassName(): string;
  22213. /**
  22214. * Gets the left operand input component
  22215. */
  22216. get left(): NodeMaterialConnectionPoint;
  22217. /**
  22218. * Gets the right operand input component
  22219. */
  22220. get right(): NodeMaterialConnectionPoint;
  22221. /**
  22222. * Gets the output component
  22223. */
  22224. get output(): NodeMaterialConnectionPoint;
  22225. protected _buildBlock(state: NodeMaterialBuildState): this;
  22226. }
  22227. }
  22228. declare module BABYLON {
  22229. /**
  22230. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22231. */
  22232. export class ColorSplitterBlock extends NodeMaterialBlock {
  22233. /**
  22234. * Create a new ColorSplitterBlock
  22235. * @param name defines the block name
  22236. */
  22237. constructor(name: string);
  22238. /**
  22239. * Gets the current class name
  22240. * @returns the class name
  22241. */
  22242. getClassName(): string;
  22243. /**
  22244. * Gets the rgba component (input)
  22245. */
  22246. get rgba(): NodeMaterialConnectionPoint;
  22247. /**
  22248. * Gets the rgb component (input)
  22249. */
  22250. get rgbIn(): NodeMaterialConnectionPoint;
  22251. /**
  22252. * Gets the rgb component (output)
  22253. */
  22254. get rgbOut(): NodeMaterialConnectionPoint;
  22255. /**
  22256. * Gets the r component (output)
  22257. */
  22258. get r(): NodeMaterialConnectionPoint;
  22259. /**
  22260. * Gets the g component (output)
  22261. */
  22262. get g(): NodeMaterialConnectionPoint;
  22263. /**
  22264. * Gets the b component (output)
  22265. */
  22266. get b(): NodeMaterialConnectionPoint;
  22267. /**
  22268. * Gets the a component (output)
  22269. */
  22270. get a(): NodeMaterialConnectionPoint;
  22271. protected _inputRename(name: string): string;
  22272. protected _outputRename(name: string): string;
  22273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22274. }
  22275. }
  22276. declare module BABYLON {
  22277. /**
  22278. * Operations supported by the Trigonometry block
  22279. */
  22280. export enum TrigonometryBlockOperations {
  22281. /** Cos */
  22282. Cos = 0,
  22283. /** Sin */
  22284. Sin = 1,
  22285. /** Abs */
  22286. Abs = 2,
  22287. /** Exp */
  22288. Exp = 3,
  22289. /** Exp2 */
  22290. Exp2 = 4,
  22291. /** Round */
  22292. Round = 5,
  22293. /** Floor */
  22294. Floor = 6,
  22295. /** Ceiling */
  22296. Ceiling = 7,
  22297. /** Square root */
  22298. Sqrt = 8,
  22299. /** Log */
  22300. Log = 9,
  22301. /** Tangent */
  22302. Tan = 10,
  22303. /** Arc tangent */
  22304. ArcTan = 11,
  22305. /** Arc cosinus */
  22306. ArcCos = 12,
  22307. /** Arc sinus */
  22308. ArcSin = 13,
  22309. /** Fraction */
  22310. Fract = 14,
  22311. /** Sign */
  22312. Sign = 15,
  22313. /** To radians (from degrees) */
  22314. Radians = 16,
  22315. /** To degrees (from radians) */
  22316. Degrees = 17
  22317. }
  22318. /**
  22319. * Block used to apply trigonometry operation to floats
  22320. */
  22321. export class TrigonometryBlock extends NodeMaterialBlock {
  22322. /**
  22323. * Gets or sets the operation applied by the block
  22324. */
  22325. operation: TrigonometryBlockOperations;
  22326. /**
  22327. * Creates a new TrigonometryBlock
  22328. * @param name defines the block name
  22329. */
  22330. constructor(name: string);
  22331. /**
  22332. * Gets the current class name
  22333. * @returns the class name
  22334. */
  22335. getClassName(): string;
  22336. /**
  22337. * Gets the input component
  22338. */
  22339. get input(): NodeMaterialConnectionPoint;
  22340. /**
  22341. * Gets the output component
  22342. */
  22343. get output(): NodeMaterialConnectionPoint;
  22344. protected _buildBlock(state: NodeMaterialBuildState): this;
  22345. serialize(): any;
  22346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22347. protected _dumpPropertiesCode(): string;
  22348. }
  22349. }
  22350. declare module BABYLON {
  22351. /**
  22352. * Interface used to configure the node material editor
  22353. */
  22354. export interface INodeMaterialEditorOptions {
  22355. /** Define the URl to load node editor script */
  22356. editorURL?: string;
  22357. }
  22358. /** @hidden */
  22359. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22360. NORMAL: boolean;
  22361. TANGENT: boolean;
  22362. UV1: boolean;
  22363. /** BONES */
  22364. NUM_BONE_INFLUENCERS: number;
  22365. BonesPerMesh: number;
  22366. BONETEXTURE: boolean;
  22367. /** MORPH TARGETS */
  22368. MORPHTARGETS: boolean;
  22369. MORPHTARGETS_NORMAL: boolean;
  22370. MORPHTARGETS_TANGENT: boolean;
  22371. MORPHTARGETS_UV: boolean;
  22372. NUM_MORPH_INFLUENCERS: number;
  22373. /** IMAGE PROCESSING */
  22374. IMAGEPROCESSING: boolean;
  22375. VIGNETTE: boolean;
  22376. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22377. VIGNETTEBLENDMODEOPAQUE: boolean;
  22378. TONEMAPPING: boolean;
  22379. TONEMAPPING_ACES: boolean;
  22380. CONTRAST: boolean;
  22381. EXPOSURE: boolean;
  22382. COLORCURVES: boolean;
  22383. COLORGRADING: boolean;
  22384. COLORGRADING3D: boolean;
  22385. SAMPLER3DGREENDEPTH: boolean;
  22386. SAMPLER3DBGRMAP: boolean;
  22387. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22388. /** MISC. */
  22389. BUMPDIRECTUV: number;
  22390. constructor();
  22391. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22392. }
  22393. /**
  22394. * Class used to configure NodeMaterial
  22395. */
  22396. export interface INodeMaterialOptions {
  22397. /**
  22398. * Defines if blocks should emit comments
  22399. */
  22400. emitComments: boolean;
  22401. }
  22402. /**
  22403. * Class used to create a node based material built by assembling shader blocks
  22404. */
  22405. export class NodeMaterial extends PushMaterial {
  22406. private static _BuildIdGenerator;
  22407. private _options;
  22408. private _vertexCompilationState;
  22409. private _fragmentCompilationState;
  22410. private _sharedData;
  22411. private _buildId;
  22412. private _buildWasSuccessful;
  22413. private _cachedWorldViewMatrix;
  22414. private _cachedWorldViewProjectionMatrix;
  22415. private _optimizers;
  22416. private _animationFrame;
  22417. /** Define the Url to load node editor script */
  22418. static EditorURL: string;
  22419. /** Define the Url to load snippets */
  22420. static SnippetUrl: string;
  22421. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22422. static IgnoreTexturesAtLoadTime: boolean;
  22423. private BJSNODEMATERIALEDITOR;
  22424. /** Get the inspector from bundle or global */
  22425. private _getGlobalNodeMaterialEditor;
  22426. /**
  22427. * Snippet ID if the material was created from the snippet server
  22428. */
  22429. snippetId: string;
  22430. /**
  22431. * Gets or sets data used by visual editor
  22432. * @see https://nme.babylonjs.com
  22433. */
  22434. editorData: any;
  22435. /**
  22436. * 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)
  22437. */
  22438. ignoreAlpha: boolean;
  22439. /**
  22440. * Defines the maximum number of lights that can be used in the material
  22441. */
  22442. maxSimultaneousLights: number;
  22443. /**
  22444. * Observable raised when the material is built
  22445. */
  22446. onBuildObservable: Observable<NodeMaterial>;
  22447. /**
  22448. * Gets or sets the root nodes of the material vertex shader
  22449. */
  22450. _vertexOutputNodes: NodeMaterialBlock[];
  22451. /**
  22452. * Gets or sets the root nodes of the material fragment (pixel) shader
  22453. */
  22454. _fragmentOutputNodes: NodeMaterialBlock[];
  22455. /** Gets or sets options to control the node material overall behavior */
  22456. get options(): INodeMaterialOptions;
  22457. set options(options: INodeMaterialOptions);
  22458. /**
  22459. * Default configuration related to image processing available in the standard Material.
  22460. */
  22461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22462. /**
  22463. * Gets the image processing configuration used either in this material.
  22464. */
  22465. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22466. /**
  22467. * Sets the Default image processing configuration used either in the this material.
  22468. *
  22469. * If sets to null, the scene one is in use.
  22470. */
  22471. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22472. /**
  22473. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22474. */
  22475. attachedBlocks: NodeMaterialBlock[];
  22476. /**
  22477. * Specifies the mode of the node material
  22478. * @hidden
  22479. */
  22480. _mode: NodeMaterialModes;
  22481. /**
  22482. * Gets the mode property
  22483. */
  22484. get mode(): NodeMaterialModes;
  22485. /**
  22486. * Create a new node based material
  22487. * @param name defines the material name
  22488. * @param scene defines the hosting scene
  22489. * @param options defines creation option
  22490. */
  22491. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22492. /**
  22493. * Gets the current class name of the material e.g. "NodeMaterial"
  22494. * @returns the class name
  22495. */
  22496. getClassName(): string;
  22497. /**
  22498. * Keep track of the image processing observer to allow dispose and replace.
  22499. */
  22500. private _imageProcessingObserver;
  22501. /**
  22502. * Attaches a new image processing configuration to the Standard Material.
  22503. * @param configuration
  22504. */
  22505. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22506. /**
  22507. * Get a block by its name
  22508. * @param name defines the name of the block to retrieve
  22509. * @returns the required block or null if not found
  22510. */
  22511. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22512. /**
  22513. * Get a block by its name
  22514. * @param predicate defines the predicate used to find the good candidate
  22515. * @returns the required block or null if not found
  22516. */
  22517. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22518. /**
  22519. * Get an input block by its name
  22520. * @param predicate defines the predicate used to find the good candidate
  22521. * @returns the required input block or null if not found
  22522. */
  22523. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22524. /**
  22525. * Gets the list of input blocks attached to this material
  22526. * @returns an array of InputBlocks
  22527. */
  22528. getInputBlocks(): InputBlock[];
  22529. /**
  22530. * Adds a new optimizer to the list of optimizers
  22531. * @param optimizer defines the optimizers to add
  22532. * @returns the current material
  22533. */
  22534. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22535. /**
  22536. * Remove an optimizer from the list of optimizers
  22537. * @param optimizer defines the optimizers to remove
  22538. * @returns the current material
  22539. */
  22540. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22541. /**
  22542. * Add a new block to the list of output nodes
  22543. * @param node defines the node to add
  22544. * @returns the current material
  22545. */
  22546. addOutputNode(node: NodeMaterialBlock): this;
  22547. /**
  22548. * Remove a block from the list of root nodes
  22549. * @param node defines the node to remove
  22550. * @returns the current material
  22551. */
  22552. removeOutputNode(node: NodeMaterialBlock): this;
  22553. private _addVertexOutputNode;
  22554. private _removeVertexOutputNode;
  22555. private _addFragmentOutputNode;
  22556. private _removeFragmentOutputNode;
  22557. /**
  22558. * Specifies if the material will require alpha blending
  22559. * @returns a boolean specifying if alpha blending is needed
  22560. */
  22561. needAlphaBlending(): boolean;
  22562. /**
  22563. * Specifies if this material should be rendered in alpha test mode
  22564. * @returns a boolean specifying if an alpha test is needed.
  22565. */
  22566. needAlphaTesting(): boolean;
  22567. private _initializeBlock;
  22568. private _resetDualBlocks;
  22569. /**
  22570. * Remove a block from the current node material
  22571. * @param block defines the block to remove
  22572. */
  22573. removeBlock(block: NodeMaterialBlock): void;
  22574. /**
  22575. * Build the material and generates the inner effect
  22576. * @param verbose defines if the build should log activity
  22577. */
  22578. build(verbose?: boolean): void;
  22579. /**
  22580. * Runs an otpimization phase to try to improve the shader code
  22581. */
  22582. optimize(): void;
  22583. private _prepareDefinesForAttributes;
  22584. /**
  22585. * Create a post process from the material
  22586. * @param camera The camera to apply the render pass to.
  22587. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22589. * @param engine The engine which the post process will be applied. (default: current engine)
  22590. * @param reusable If the post process can be reused on the same frame. (default: false)
  22591. * @param textureType Type of textures used when performing the post process. (default: 0)
  22592. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22593. * @returns the post process created
  22594. */
  22595. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22596. /**
  22597. * Create the post process effect from the material
  22598. * @param postProcess The post process to create the effect for
  22599. */
  22600. createEffectForPostProcess(postProcess: PostProcess): void;
  22601. private _createEffectForPostProcess;
  22602. /**
  22603. * Create a new procedural texture based on this node material
  22604. * @param size defines the size of the texture
  22605. * @param scene defines the hosting scene
  22606. * @returns the new procedural texture attached to this node material
  22607. */
  22608. createProceduralTexture(size: number | {
  22609. width: number;
  22610. height: number;
  22611. layers?: number;
  22612. }, scene: Scene): Nullable<ProceduralTexture>;
  22613. private _createEffectForParticles;
  22614. private _checkInternals;
  22615. /**
  22616. * Create the effect to be used as the custom effect for a particle system
  22617. * @param particleSystem Particle system to create the effect for
  22618. * @param onCompiled defines a function to call when the effect creation is successful
  22619. * @param onError defines a function to call when the effect creation has failed
  22620. */
  22621. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22622. private _processDefines;
  22623. /**
  22624. * Get if the submesh is ready to be used and all its information available.
  22625. * Child classes can use it to update shaders
  22626. * @param mesh defines the mesh to check
  22627. * @param subMesh defines which submesh to check
  22628. * @param useInstances specifies that instances should be used
  22629. * @returns a boolean indicating that the submesh is ready or not
  22630. */
  22631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22632. /**
  22633. * Get a string representing the shaders built by the current node graph
  22634. */
  22635. get compiledShaders(): string;
  22636. /**
  22637. * Binds the world matrix to the material
  22638. * @param world defines the world transformation matrix
  22639. */
  22640. bindOnlyWorldMatrix(world: Matrix): void;
  22641. /**
  22642. * Binds the submesh to this material by preparing the effect and shader to draw
  22643. * @param world defines the world transformation matrix
  22644. * @param mesh defines the mesh containing the submesh
  22645. * @param subMesh defines the submesh to bind the material to
  22646. */
  22647. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22648. /**
  22649. * Gets the active textures from the material
  22650. * @returns an array of textures
  22651. */
  22652. getActiveTextures(): BaseTexture[];
  22653. /**
  22654. * Gets the list of texture blocks
  22655. * @returns an array of texture blocks
  22656. */
  22657. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22658. /**
  22659. * Specifies if the material uses a texture
  22660. * @param texture defines the texture to check against the material
  22661. * @returns a boolean specifying if the material uses the texture
  22662. */
  22663. hasTexture(texture: BaseTexture): boolean;
  22664. /**
  22665. * Disposes the material
  22666. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22667. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22668. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22669. */
  22670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22671. /** Creates the node editor window. */
  22672. private _createNodeEditor;
  22673. /**
  22674. * Launch the node material editor
  22675. * @param config Define the configuration of the editor
  22676. * @return a promise fulfilled when the node editor is visible
  22677. */
  22678. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22679. /**
  22680. * Clear the current material
  22681. */
  22682. clear(): void;
  22683. /**
  22684. * Clear the current material and set it to a default state
  22685. */
  22686. setToDefault(): void;
  22687. /**
  22688. * Clear the current material and set it to a default state for post process
  22689. */
  22690. setToDefaultPostProcess(): void;
  22691. /**
  22692. * Clear the current material and set it to a default state for procedural texture
  22693. */
  22694. setToDefaultProceduralTexture(): void;
  22695. /**
  22696. * Clear the current material and set it to a default state for particle
  22697. */
  22698. setToDefaultParticle(): void;
  22699. /**
  22700. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22701. * @param url defines the url to load from
  22702. * @returns a promise that will fullfil when the material is fully loaded
  22703. */
  22704. loadAsync(url: string): Promise<void>;
  22705. private _gatherBlocks;
  22706. /**
  22707. * Generate a string containing the code declaration required to create an equivalent of this material
  22708. * @returns a string
  22709. */
  22710. generateCode(): string;
  22711. /**
  22712. * Serializes this material in a JSON representation
  22713. * @returns the serialized material object
  22714. */
  22715. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22716. private _restoreConnections;
  22717. /**
  22718. * Clear the current graph and load a new one from a serialization object
  22719. * @param source defines the JSON representation of the material
  22720. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22721. * @param merge defines whether or not the source must be merged or replace the current content
  22722. */
  22723. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22724. /**
  22725. * Makes a duplicate of the current material.
  22726. * @param name - name to use for the new material.
  22727. */
  22728. clone(name: string): NodeMaterial;
  22729. /**
  22730. * Creates a node material from parsed material data
  22731. * @param source defines the JSON representation of the material
  22732. * @param scene defines the hosting scene
  22733. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22734. * @returns a new node material
  22735. */
  22736. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22737. /**
  22738. * Creates a node material from a snippet saved in a remote file
  22739. * @param name defines the name of the material to create
  22740. * @param url defines the url to load from
  22741. * @param scene defines the hosting scene
  22742. * @returns a promise that will resolve to the new node material
  22743. */
  22744. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22745. /**
  22746. * Creates a node material from a snippet saved by the node material editor
  22747. * @param snippetId defines the snippet to load
  22748. * @param scene defines the hosting scene
  22749. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22750. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22751. * @returns a promise that will resolve to the new node material
  22752. */
  22753. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22754. /**
  22755. * Creates a new node material set to default basic configuration
  22756. * @param name defines the name of the material
  22757. * @param scene defines the hosting scene
  22758. * @returns a new NodeMaterial
  22759. */
  22760. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22761. }
  22762. }
  22763. declare module BABYLON {
  22764. /**
  22765. * Size options for a post process
  22766. */
  22767. export type PostProcessOptions = {
  22768. width: number;
  22769. height: number;
  22770. };
  22771. /**
  22772. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22773. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22774. */
  22775. export class PostProcess {
  22776. /**
  22777. * Gets or sets the unique id of the post process
  22778. */
  22779. uniqueId: number;
  22780. /** Name of the PostProcess. */
  22781. name: string;
  22782. /**
  22783. * Width of the texture to apply the post process on
  22784. */
  22785. width: number;
  22786. /**
  22787. * Height of the texture to apply the post process on
  22788. */
  22789. height: number;
  22790. /**
  22791. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22792. */
  22793. nodeMaterialSource: Nullable<NodeMaterial>;
  22794. /**
  22795. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22796. * @hidden
  22797. */
  22798. _outputTexture: Nullable<InternalTexture>;
  22799. /**
  22800. * Sampling mode used by the shader
  22801. * See https://doc.babylonjs.com/classes/3.1/texture
  22802. */
  22803. renderTargetSamplingMode: number;
  22804. /**
  22805. * Clear color to use when screen clearing
  22806. */
  22807. clearColor: Color4;
  22808. /**
  22809. * If the buffer needs to be cleared before applying the post process. (default: true)
  22810. * Should be set to false if shader will overwrite all previous pixels.
  22811. */
  22812. autoClear: boolean;
  22813. /**
  22814. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22815. */
  22816. alphaMode: number;
  22817. /**
  22818. * Sets the setAlphaBlendConstants of the babylon engine
  22819. */
  22820. alphaConstants: Color4;
  22821. /**
  22822. * Animations to be used for the post processing
  22823. */
  22824. animations: Animation[];
  22825. /**
  22826. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22827. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22828. */
  22829. enablePixelPerfectMode: boolean;
  22830. /**
  22831. * Force the postprocess to be applied without taking in account viewport
  22832. */
  22833. forceFullscreenViewport: boolean;
  22834. /**
  22835. * List of inspectable custom properties (used by the Inspector)
  22836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22837. */
  22838. inspectableCustomProperties: IInspectable[];
  22839. /**
  22840. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22841. *
  22842. * | Value | Type | Description |
  22843. * | ----- | ----------------------------------- | ----------- |
  22844. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22845. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22846. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22847. *
  22848. */
  22849. scaleMode: number;
  22850. /**
  22851. * Force textures to be a power of two (default: false)
  22852. */
  22853. alwaysForcePOT: boolean;
  22854. private _samples;
  22855. /**
  22856. * Number of sample textures (default: 1)
  22857. */
  22858. get samples(): number;
  22859. set samples(n: number);
  22860. /**
  22861. * Modify the scale of the post process to be the same as the viewport (default: false)
  22862. */
  22863. adaptScaleToCurrentViewport: boolean;
  22864. private _camera;
  22865. protected _scene: Scene;
  22866. private _engine;
  22867. private _options;
  22868. private _reusable;
  22869. private _textureType;
  22870. private _textureFormat;
  22871. /**
  22872. * Smart array of input and output textures for the post process.
  22873. * @hidden
  22874. */
  22875. _textures: SmartArray<InternalTexture>;
  22876. /**
  22877. * The index in _textures that corresponds to the output texture.
  22878. * @hidden
  22879. */
  22880. _currentRenderTextureInd: number;
  22881. private _effect;
  22882. private _samplers;
  22883. private _fragmentUrl;
  22884. private _vertexUrl;
  22885. private _parameters;
  22886. private _scaleRatio;
  22887. protected _indexParameters: any;
  22888. private _shareOutputWithPostProcess;
  22889. private _texelSize;
  22890. private _forcedOutputTexture;
  22891. /**
  22892. * Returns the fragment url or shader name used in the post process.
  22893. * @returns the fragment url or name in the shader store.
  22894. */
  22895. getEffectName(): string;
  22896. /**
  22897. * An event triggered when the postprocess is activated.
  22898. */
  22899. onActivateObservable: Observable<Camera>;
  22900. private _onActivateObserver;
  22901. /**
  22902. * A function that is added to the onActivateObservable
  22903. */
  22904. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22905. /**
  22906. * An event triggered when the postprocess changes its size.
  22907. */
  22908. onSizeChangedObservable: Observable<PostProcess>;
  22909. private _onSizeChangedObserver;
  22910. /**
  22911. * A function that is added to the onSizeChangedObservable
  22912. */
  22913. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22914. /**
  22915. * An event triggered when the postprocess applies its effect.
  22916. */
  22917. onApplyObservable: Observable<Effect>;
  22918. private _onApplyObserver;
  22919. /**
  22920. * A function that is added to the onApplyObservable
  22921. */
  22922. set onApply(callback: (effect: Effect) => void);
  22923. /**
  22924. * An event triggered before rendering the postprocess
  22925. */
  22926. onBeforeRenderObservable: Observable<Effect>;
  22927. private _onBeforeRenderObserver;
  22928. /**
  22929. * A function that is added to the onBeforeRenderObservable
  22930. */
  22931. set onBeforeRender(callback: (effect: Effect) => void);
  22932. /**
  22933. * An event triggered after rendering the postprocess
  22934. */
  22935. onAfterRenderObservable: Observable<Effect>;
  22936. private _onAfterRenderObserver;
  22937. /**
  22938. * A function that is added to the onAfterRenderObservable
  22939. */
  22940. set onAfterRender(callback: (efect: Effect) => void);
  22941. /**
  22942. * 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
  22943. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22944. */
  22945. get inputTexture(): InternalTexture;
  22946. set inputTexture(value: InternalTexture);
  22947. /**
  22948. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22949. * the only way to unset it is to use this function to restore its internal state
  22950. */
  22951. restoreDefaultInputTexture(): void;
  22952. /**
  22953. * Gets the camera which post process is applied to.
  22954. * @returns The camera the post process is applied to.
  22955. */
  22956. getCamera(): Camera;
  22957. /**
  22958. * Gets the texel size of the postprocess.
  22959. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22960. */
  22961. get texelSize(): Vector2;
  22962. /**
  22963. * Creates a new instance PostProcess
  22964. * @param name The name of the PostProcess.
  22965. * @param fragmentUrl The url of the fragment shader to be used.
  22966. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22967. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22968. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22969. * @param camera The camera to apply the render pass to.
  22970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22971. * @param engine The engine which the post process will be applied. (default: current engine)
  22972. * @param reusable If the post process can be reused on the same frame. (default: false)
  22973. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22974. * @param textureType Type of textures used when performing the post process. (default: 0)
  22975. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22976. * @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
  22977. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22978. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22979. */
  22980. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22981. /**
  22982. * Gets a string identifying the name of the class
  22983. * @returns "PostProcess" string
  22984. */
  22985. getClassName(): string;
  22986. /**
  22987. * Gets the engine which this post process belongs to.
  22988. * @returns The engine the post process was enabled with.
  22989. */
  22990. getEngine(): Engine;
  22991. /**
  22992. * The effect that is created when initializing the post process.
  22993. * @returns The created effect corresponding the the postprocess.
  22994. */
  22995. getEffect(): Effect;
  22996. /**
  22997. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22998. * @param postProcess The post process to share the output with.
  22999. * @returns This post process.
  23000. */
  23001. shareOutputWith(postProcess: PostProcess): PostProcess;
  23002. /**
  23003. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23004. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23005. */
  23006. useOwnOutput(): void;
  23007. /**
  23008. * Updates the effect with the current post process compile time values and recompiles the shader.
  23009. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23010. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23011. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23012. * @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
  23013. * @param onCompiled Called when the shader has been compiled.
  23014. * @param onError Called if there is an error when compiling a shader.
  23015. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23016. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23017. */
  23018. 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;
  23019. /**
  23020. * The post process is reusable if it can be used multiple times within one frame.
  23021. * @returns If the post process is reusable
  23022. */
  23023. isReusable(): boolean;
  23024. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23025. markTextureDirty(): void;
  23026. /**
  23027. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23028. * 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.
  23029. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23030. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23031. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23032. * @returns The target texture that was bound to be written to.
  23033. */
  23034. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23035. /**
  23036. * If the post process is supported.
  23037. */
  23038. get isSupported(): boolean;
  23039. /**
  23040. * The aspect ratio of the output texture.
  23041. */
  23042. get aspectRatio(): number;
  23043. /**
  23044. * Get a value indicating if the post-process is ready to be used
  23045. * @returns true if the post-process is ready (shader is compiled)
  23046. */
  23047. isReady(): boolean;
  23048. /**
  23049. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23050. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23051. */
  23052. apply(): Nullable<Effect>;
  23053. private _disposeTextures;
  23054. /**
  23055. * Disposes the post process.
  23056. * @param camera The camera to dispose the post process on.
  23057. */
  23058. dispose(camera?: Camera): void;
  23059. /**
  23060. * Serializes the particle system to a JSON object
  23061. * @returns the JSON object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Creates a material from parsed material data
  23066. * @param parsedPostProcess defines parsed post process data
  23067. * @param scene defines the hosting scene
  23068. * @param rootUrl defines the root URL to use to load textures
  23069. * @returns a new post process
  23070. */
  23071. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23072. }
  23073. }
  23074. declare module BABYLON {
  23075. /** @hidden */
  23076. export var kernelBlurVaryingDeclaration: {
  23077. name: string;
  23078. shader: string;
  23079. };
  23080. }
  23081. declare module BABYLON {
  23082. /** @hidden */
  23083. export var kernelBlurFragment: {
  23084. name: string;
  23085. shader: string;
  23086. };
  23087. }
  23088. declare module BABYLON {
  23089. /** @hidden */
  23090. export var kernelBlurFragment2: {
  23091. name: string;
  23092. shader: string;
  23093. };
  23094. }
  23095. declare module BABYLON {
  23096. /** @hidden */
  23097. export var kernelBlurPixelShader: {
  23098. name: string;
  23099. shader: string;
  23100. };
  23101. }
  23102. declare module BABYLON {
  23103. /** @hidden */
  23104. export var kernelBlurVertex: {
  23105. name: string;
  23106. shader: string;
  23107. };
  23108. }
  23109. declare module BABYLON {
  23110. /** @hidden */
  23111. export var kernelBlurVertexShader: {
  23112. name: string;
  23113. shader: string;
  23114. };
  23115. }
  23116. declare module BABYLON {
  23117. /**
  23118. * The Blur Post Process which blurs an image based on a kernel and direction.
  23119. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23120. */
  23121. export class BlurPostProcess extends PostProcess {
  23122. private blockCompilation;
  23123. protected _kernel: number;
  23124. protected _idealKernel: number;
  23125. protected _packedFloat: boolean;
  23126. private _staticDefines;
  23127. /** The direction in which to blur the image. */
  23128. direction: Vector2;
  23129. /**
  23130. * Sets the length in pixels of the blur sample region
  23131. */
  23132. set kernel(v: number);
  23133. /**
  23134. * Gets the length in pixels of the blur sample region
  23135. */
  23136. get kernel(): number;
  23137. /**
  23138. * Sets wether or not the blur needs to unpack/repack floats
  23139. */
  23140. set packedFloat(v: boolean);
  23141. /**
  23142. * Gets wether or not the blur is unpacking/repacking floats
  23143. */
  23144. get packedFloat(): boolean;
  23145. /**
  23146. * Gets a string identifying the name of the class
  23147. * @returns "BlurPostProcess" string
  23148. */
  23149. getClassName(): string;
  23150. /**
  23151. * Creates a new instance BlurPostProcess
  23152. * @param name The name of the effect.
  23153. * @param direction The direction in which to blur the image.
  23154. * @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.
  23155. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23156. * @param camera The camera to apply the render pass to.
  23157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23158. * @param engine The engine which the post process will be applied. (default: current engine)
  23159. * @param reusable If the post process can be reused on the same frame. (default: false)
  23160. * @param textureType Type of textures used when performing the post process. (default: 0)
  23161. * @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)
  23162. */
  23163. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23164. /**
  23165. * Updates the effect with the current post process compile time values and recompiles the shader.
  23166. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23167. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23168. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23169. * @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
  23170. * @param onCompiled Called when the shader has been compiled.
  23171. * @param onError Called if there is an error when compiling a shader.
  23172. */
  23173. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23174. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23175. /**
  23176. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23177. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23178. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23179. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23180. * The gaps between physical kernels are compensated for in the weighting of the samples
  23181. * @param idealKernel Ideal blur kernel.
  23182. * @return Nearest best kernel.
  23183. */
  23184. protected _nearestBestKernel(idealKernel: number): number;
  23185. /**
  23186. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23187. * @param x The point on the Gaussian distribution to sample.
  23188. * @return the value of the Gaussian function at x.
  23189. */
  23190. protected _gaussianWeight(x: number): number;
  23191. /**
  23192. * Generates a string that can be used as a floating point number in GLSL.
  23193. * @param x Value to print.
  23194. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23195. * @return GLSL float string.
  23196. */
  23197. protected _glslFloat(x: number, decimalFigures?: number): string;
  23198. /** @hidden */
  23199. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23200. }
  23201. }
  23202. declare module BABYLON {
  23203. /**
  23204. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23205. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23206. * You can then easily use it as a reflectionTexture on a flat surface.
  23207. * In case the surface is not a plane, please consider relying on reflection probes.
  23208. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23209. */
  23210. export class MirrorTexture extends RenderTargetTexture {
  23211. private scene;
  23212. /**
  23213. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23214. * 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.
  23215. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23216. */
  23217. mirrorPlane: Plane;
  23218. /**
  23219. * Define the blur ratio used to blur the reflection if needed.
  23220. */
  23221. set blurRatio(value: number);
  23222. get blurRatio(): number;
  23223. /**
  23224. * Define the adaptive blur kernel used to blur the reflection if needed.
  23225. * This will autocompute the closest best match for the `blurKernel`
  23226. */
  23227. set adaptiveBlurKernel(value: number);
  23228. /**
  23229. * Define the blur kernel used to blur the reflection if needed.
  23230. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23231. */
  23232. set blurKernel(value: number);
  23233. /**
  23234. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23235. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23236. */
  23237. set blurKernelX(value: number);
  23238. get blurKernelX(): number;
  23239. /**
  23240. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23241. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23242. */
  23243. set blurKernelY(value: number);
  23244. get blurKernelY(): number;
  23245. private _autoComputeBlurKernel;
  23246. protected _onRatioRescale(): void;
  23247. private _updateGammaSpace;
  23248. private _imageProcessingConfigChangeObserver;
  23249. private _transformMatrix;
  23250. private _mirrorMatrix;
  23251. private _savedViewMatrix;
  23252. private _blurX;
  23253. private _blurY;
  23254. private _adaptiveBlurKernel;
  23255. private _blurKernelX;
  23256. private _blurKernelY;
  23257. private _blurRatio;
  23258. /**
  23259. * Instantiates a Mirror Texture.
  23260. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23261. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23262. * You can then easily use it as a reflectionTexture on a flat surface.
  23263. * In case the surface is not a plane, please consider relying on reflection probes.
  23264. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23265. * @param name
  23266. * @param size
  23267. * @param scene
  23268. * @param generateMipMaps
  23269. * @param type
  23270. * @param samplingMode
  23271. * @param generateDepthBuffer
  23272. */
  23273. constructor(name: string, size: number | {
  23274. width: number;
  23275. height: number;
  23276. } | {
  23277. ratio: number;
  23278. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23279. private _preparePostProcesses;
  23280. /**
  23281. * Clone the mirror texture.
  23282. * @returns the cloned texture
  23283. */
  23284. clone(): MirrorTexture;
  23285. /**
  23286. * Serialize the texture to a JSON representation you could use in Parse later on
  23287. * @returns the serialized JSON representation
  23288. */
  23289. serialize(): any;
  23290. /**
  23291. * Dispose the texture and release its associated resources.
  23292. */
  23293. dispose(): void;
  23294. }
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23299. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23300. */
  23301. export class Texture extends BaseTexture {
  23302. /**
  23303. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23304. */
  23305. static SerializeBuffers: boolean;
  23306. /** @hidden */
  23307. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23308. /** @hidden */
  23309. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23310. /** @hidden */
  23311. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23312. /** nearest is mag = nearest and min = nearest and mip = linear */
  23313. static readonly NEAREST_SAMPLINGMODE: number;
  23314. /** nearest is mag = nearest and min = nearest and mip = linear */
  23315. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23316. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23317. static readonly BILINEAR_SAMPLINGMODE: number;
  23318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23319. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23320. /** Trilinear is mag = linear and min = linear and mip = linear */
  23321. static readonly TRILINEAR_SAMPLINGMODE: number;
  23322. /** Trilinear is mag = linear and min = linear and mip = linear */
  23323. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23324. /** mag = nearest and min = nearest and mip = nearest */
  23325. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23326. /** mag = nearest and min = linear and mip = nearest */
  23327. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23328. /** mag = nearest and min = linear and mip = linear */
  23329. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23330. /** mag = nearest and min = linear and mip = none */
  23331. static readonly NEAREST_LINEAR: number;
  23332. /** mag = nearest and min = nearest and mip = none */
  23333. static readonly NEAREST_NEAREST: number;
  23334. /** mag = linear and min = nearest and mip = nearest */
  23335. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23336. /** mag = linear and min = nearest and mip = linear */
  23337. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23338. /** mag = linear and min = linear and mip = none */
  23339. static readonly LINEAR_LINEAR: number;
  23340. /** mag = linear and min = nearest and mip = none */
  23341. static readonly LINEAR_NEAREST: number;
  23342. /** Explicit coordinates mode */
  23343. static readonly EXPLICIT_MODE: number;
  23344. /** Spherical coordinates mode */
  23345. static readonly SPHERICAL_MODE: number;
  23346. /** Planar coordinates mode */
  23347. static readonly PLANAR_MODE: number;
  23348. /** Cubic coordinates mode */
  23349. static readonly CUBIC_MODE: number;
  23350. /** Projection coordinates mode */
  23351. static readonly PROJECTION_MODE: number;
  23352. /** Inverse Cubic coordinates mode */
  23353. static readonly SKYBOX_MODE: number;
  23354. /** Inverse Cubic coordinates mode */
  23355. static readonly INVCUBIC_MODE: number;
  23356. /** Equirectangular coordinates mode */
  23357. static readonly EQUIRECTANGULAR_MODE: number;
  23358. /** Equirectangular Fixed coordinates mode */
  23359. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23360. /** Equirectangular Fixed Mirrored coordinates mode */
  23361. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23362. /** Texture is not repeating outside of 0..1 UVs */
  23363. static readonly CLAMP_ADDRESSMODE: number;
  23364. /** Texture is repeating outside of 0..1 UVs */
  23365. static readonly WRAP_ADDRESSMODE: number;
  23366. /** Texture is repeating and mirrored */
  23367. static readonly MIRROR_ADDRESSMODE: number;
  23368. /**
  23369. * 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
  23370. */
  23371. static UseSerializedUrlIfAny: boolean;
  23372. /**
  23373. * Define the url of the texture.
  23374. */
  23375. url: Nullable<string>;
  23376. /**
  23377. * Define an offset on the texture to offset the u coordinates of the UVs
  23378. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23379. */
  23380. uOffset: number;
  23381. /**
  23382. * Define an offset on the texture to offset the v coordinates of the UVs
  23383. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23384. */
  23385. vOffset: number;
  23386. /**
  23387. * Define an offset on the texture to scale the u coordinates of the UVs
  23388. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23389. */
  23390. uScale: number;
  23391. /**
  23392. * Define an offset on the texture to scale the v coordinates of the UVs
  23393. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23394. */
  23395. vScale: number;
  23396. /**
  23397. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23398. * @see https://doc.babylonjs.com/how_to/more_materials
  23399. */
  23400. uAng: number;
  23401. /**
  23402. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23403. * @see https://doc.babylonjs.com/how_to/more_materials
  23404. */
  23405. vAng: number;
  23406. /**
  23407. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23408. * @see https://doc.babylonjs.com/how_to/more_materials
  23409. */
  23410. wAng: number;
  23411. /**
  23412. * Defines the center of rotation (U)
  23413. */
  23414. uRotationCenter: number;
  23415. /**
  23416. * Defines the center of rotation (V)
  23417. */
  23418. vRotationCenter: number;
  23419. /**
  23420. * Defines the center of rotation (W)
  23421. */
  23422. wRotationCenter: number;
  23423. /**
  23424. * Are mip maps generated for this texture or not.
  23425. */
  23426. get noMipmap(): boolean;
  23427. /**
  23428. * List of inspectable custom properties (used by the Inspector)
  23429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23430. */
  23431. inspectableCustomProperties: Nullable<IInspectable[]>;
  23432. private _noMipmap;
  23433. /** @hidden */
  23434. _invertY: boolean;
  23435. private _rowGenerationMatrix;
  23436. private _cachedTextureMatrix;
  23437. private _projectionModeMatrix;
  23438. private _t0;
  23439. private _t1;
  23440. private _t2;
  23441. private _cachedUOffset;
  23442. private _cachedVOffset;
  23443. private _cachedUScale;
  23444. private _cachedVScale;
  23445. private _cachedUAng;
  23446. private _cachedVAng;
  23447. private _cachedWAng;
  23448. private _cachedProjectionMatrixId;
  23449. private _cachedCoordinatesMode;
  23450. /** @hidden */
  23451. protected _initialSamplingMode: number;
  23452. /** @hidden */
  23453. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23454. private _deleteBuffer;
  23455. protected _format: Nullable<number>;
  23456. private _delayedOnLoad;
  23457. private _delayedOnError;
  23458. private _mimeType?;
  23459. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23460. get mimeType(): string | undefined;
  23461. /**
  23462. * Observable triggered once the texture has been loaded.
  23463. */
  23464. onLoadObservable: Observable<Texture>;
  23465. protected _isBlocking: boolean;
  23466. /**
  23467. * Is the texture preventing material to render while loading.
  23468. * If false, a default texture will be used instead of the loading one during the preparation step.
  23469. */
  23470. set isBlocking(value: boolean);
  23471. get isBlocking(): boolean;
  23472. /**
  23473. * Get the current sampling mode associated with the texture.
  23474. */
  23475. get samplingMode(): number;
  23476. /**
  23477. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23478. */
  23479. get invertY(): boolean;
  23480. /**
  23481. * Instantiates a new texture.
  23482. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23483. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23484. * @param url defines the url of the picture to load as a texture
  23485. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23486. * @param noMipmap defines if the texture will require mip maps or not
  23487. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23488. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23489. * @param onLoad defines a callback triggered when the texture has been loaded
  23490. * @param onError defines a callback triggered when an error occurred during the loading session
  23491. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23492. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23493. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23494. * @param mimeType defines an optional mime type information
  23495. */
  23496. 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);
  23497. /**
  23498. * Update the url (and optional buffer) of this texture if url was null during construction.
  23499. * @param url the url of the texture
  23500. * @param buffer the buffer of the texture (defaults to null)
  23501. * @param onLoad callback called when the texture is loaded (defaults to null)
  23502. */
  23503. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23504. /**
  23505. * Finish the loading sequence of a texture flagged as delayed load.
  23506. * @hidden
  23507. */
  23508. delayLoad(): void;
  23509. private _prepareRowForTextureGeneration;
  23510. /**
  23511. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23512. * @returns the transform matrix of the texture.
  23513. */
  23514. getTextureMatrix(uBase?: number): Matrix;
  23515. /**
  23516. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23517. * @returns The reflection texture transform
  23518. */
  23519. getReflectionTextureMatrix(): Matrix;
  23520. /**
  23521. * Clones the texture.
  23522. * @returns the cloned texture
  23523. */
  23524. clone(): Texture;
  23525. /**
  23526. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23527. * @returns The JSON representation of the texture
  23528. */
  23529. serialize(): any;
  23530. /**
  23531. * Get the current class name of the texture useful for serialization or dynamic coding.
  23532. * @returns "Texture"
  23533. */
  23534. getClassName(): string;
  23535. /**
  23536. * Dispose the texture and release its associated resources.
  23537. */
  23538. dispose(): void;
  23539. /**
  23540. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23541. * @param parsedTexture Define the JSON representation of the texture
  23542. * @param scene Define the scene the parsed texture should be instantiated in
  23543. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23544. * @returns The parsed texture if successful
  23545. */
  23546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23547. /**
  23548. * Creates a texture from its base 64 representation.
  23549. * @param data Define the base64 payload without the data: prefix
  23550. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23551. * @param scene Define the scene the texture should belong to
  23552. * @param noMipmap Forces the texture to not create mip map information if true
  23553. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23554. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23555. * @param onLoad define a callback triggered when the texture has been loaded
  23556. * @param onError define a callback triggered when an error occurred during the loading session
  23557. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23558. * @returns the created texture
  23559. */
  23560. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23561. /**
  23562. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23563. * @param data Define the base64 payload without the data: prefix
  23564. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23565. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23566. * @param scene Define the scene the texture should belong to
  23567. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23568. * @param noMipmap Forces the texture to not create mip map information if true
  23569. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23570. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23571. * @param onLoad define a callback triggered when the texture has been loaded
  23572. * @param onError define a callback triggered when an error occurred during the loading session
  23573. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23574. * @returns the created texture
  23575. */
  23576. 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;
  23577. }
  23578. }
  23579. declare module BABYLON {
  23580. /**
  23581. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23583. */
  23584. export class PostProcessManager {
  23585. private _scene;
  23586. private _indexBuffer;
  23587. private _vertexBuffers;
  23588. /**
  23589. * Creates a new instance PostProcess
  23590. * @param scene The scene that the post process is associated with.
  23591. */
  23592. constructor(scene: Scene);
  23593. private _prepareBuffers;
  23594. private _buildIndexBuffer;
  23595. /**
  23596. * Rebuilds the vertex buffers of the manager.
  23597. * @hidden
  23598. */
  23599. _rebuild(): void;
  23600. /**
  23601. * Prepares a frame to be run through a post process.
  23602. * @param sourceTexture The input texture to the post procesess. (default: null)
  23603. * @param postProcesses An array of post processes to be run. (default: null)
  23604. * @returns True if the post processes were able to be run.
  23605. * @hidden
  23606. */
  23607. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23608. /**
  23609. * Manually render a set of post processes to a texture.
  23610. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23611. * @param postProcesses An array of post processes to be run.
  23612. * @param targetTexture The target texture to render to.
  23613. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23614. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23615. * @param lodLevel defines which lod of the texture to render to
  23616. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23617. */
  23618. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23619. /**
  23620. * Finalize the result of the output of the postprocesses.
  23621. * @param doNotPresent If true the result will not be displayed to the screen.
  23622. * @param targetTexture The target texture to render to.
  23623. * @param faceIndex The index of the face to bind the target texture to.
  23624. * @param postProcesses The array of post processes to render.
  23625. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23626. * @hidden
  23627. */
  23628. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23629. /**
  23630. * Disposes of the post process manager.
  23631. */
  23632. dispose(): void;
  23633. }
  23634. }
  23635. declare module BABYLON {
  23636. /**
  23637. * This Helps creating a texture that will be created from a camera in your scene.
  23638. * It is basically a dynamic texture that could be used to create special effects for instance.
  23639. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23640. */
  23641. export class RenderTargetTexture extends Texture {
  23642. /**
  23643. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23644. */
  23645. static readonly REFRESHRATE_RENDER_ONCE: number;
  23646. /**
  23647. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23648. */
  23649. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23650. /**
  23651. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23652. * the central point of your effect and can save a lot of performances.
  23653. */
  23654. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23655. /**
  23656. * Use this predicate to dynamically define the list of mesh you want to render.
  23657. * If set, the renderList property will be overwritten.
  23658. */
  23659. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23660. private _renderList;
  23661. /**
  23662. * Use this list to define the list of mesh you want to render.
  23663. */
  23664. get renderList(): Nullable<Array<AbstractMesh>>;
  23665. set renderList(value: Nullable<Array<AbstractMesh>>);
  23666. /**
  23667. * Use this function to overload the renderList array at rendering time.
  23668. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23669. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23670. * the cube (if the RTT is a cube, else layerOrFace=0).
  23671. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23672. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23673. * hold dummy elements!
  23674. */
  23675. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23676. private _hookArray;
  23677. /**
  23678. * Define if particles should be rendered in your texture.
  23679. */
  23680. renderParticles: boolean;
  23681. /**
  23682. * Define if sprites should be rendered in your texture.
  23683. */
  23684. renderSprites: boolean;
  23685. /**
  23686. * Define the camera used to render the texture.
  23687. */
  23688. activeCamera: Nullable<Camera>;
  23689. /**
  23690. * Override the mesh isReady function with your own one.
  23691. */
  23692. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23693. /**
  23694. * Override the render function of the texture with your own one.
  23695. */
  23696. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23697. /**
  23698. * Define if camera post processes should be use while rendering the texture.
  23699. */
  23700. useCameraPostProcesses: boolean;
  23701. /**
  23702. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23703. */
  23704. ignoreCameraViewport: boolean;
  23705. private _postProcessManager;
  23706. private _postProcesses;
  23707. private _resizeObserver;
  23708. /**
  23709. * An event triggered when the texture is unbind.
  23710. */
  23711. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23712. /**
  23713. * An event triggered when the texture is unbind.
  23714. */
  23715. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23716. private _onAfterUnbindObserver;
  23717. /**
  23718. * Set a after unbind callback in the texture.
  23719. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23720. */
  23721. set onAfterUnbind(callback: () => void);
  23722. /**
  23723. * An event triggered before rendering the texture
  23724. */
  23725. onBeforeRenderObservable: Observable<number>;
  23726. private _onBeforeRenderObserver;
  23727. /**
  23728. * Set a before render callback in the texture.
  23729. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23730. */
  23731. set onBeforeRender(callback: (faceIndex: number) => void);
  23732. /**
  23733. * An event triggered after rendering the texture
  23734. */
  23735. onAfterRenderObservable: Observable<number>;
  23736. private _onAfterRenderObserver;
  23737. /**
  23738. * Set a after render callback in the texture.
  23739. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23740. */
  23741. set onAfterRender(callback: (faceIndex: number) => void);
  23742. /**
  23743. * An event triggered after the texture clear
  23744. */
  23745. onClearObservable: Observable<Engine>;
  23746. private _onClearObserver;
  23747. /**
  23748. * Set a clear callback in the texture.
  23749. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23750. */
  23751. set onClear(callback: (Engine: Engine) => void);
  23752. /**
  23753. * An event triggered when the texture is resized.
  23754. */
  23755. onResizeObservable: Observable<RenderTargetTexture>;
  23756. /**
  23757. * Define the clear color of the Render Target if it should be different from the scene.
  23758. */
  23759. clearColor: Color4;
  23760. protected _size: number | {
  23761. width: number;
  23762. height: number;
  23763. layers?: number;
  23764. };
  23765. protected _initialSizeParameter: number | {
  23766. width: number;
  23767. height: number;
  23768. } | {
  23769. ratio: number;
  23770. };
  23771. protected _sizeRatio: Nullable<number>;
  23772. /** @hidden */
  23773. _generateMipMaps: boolean;
  23774. protected _renderingManager: RenderingManager;
  23775. /** @hidden */
  23776. _waitingRenderList?: string[];
  23777. protected _doNotChangeAspectRatio: boolean;
  23778. protected _currentRefreshId: number;
  23779. protected _refreshRate: number;
  23780. protected _textureMatrix: Matrix;
  23781. protected _samples: number;
  23782. protected _renderTargetOptions: RenderTargetCreationOptions;
  23783. /**
  23784. * Gets render target creation options that were used.
  23785. */
  23786. get renderTargetOptions(): RenderTargetCreationOptions;
  23787. protected _onRatioRescale(): void;
  23788. /**
  23789. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23790. * It must define where the camera used to render the texture is set
  23791. */
  23792. boundingBoxPosition: Vector3;
  23793. private _boundingBoxSize;
  23794. /**
  23795. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23796. * When defined, the cubemap will switch to local mode
  23797. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23798. * @example https://www.babylonjs-playground.com/#RNASML
  23799. */
  23800. set boundingBoxSize(value: Vector3);
  23801. get boundingBoxSize(): Vector3;
  23802. /**
  23803. * In case the RTT has been created with a depth texture, get the associated
  23804. * depth texture.
  23805. * Otherwise, return null.
  23806. */
  23807. get depthStencilTexture(): Nullable<InternalTexture>;
  23808. /**
  23809. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23810. * or used a shadow, depth texture...
  23811. * @param name The friendly name of the texture
  23812. * @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)
  23813. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23814. * @param generateMipMaps True if mip maps need to be generated after render.
  23815. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23816. * @param type The type of the buffer in the RTT (int, half float, float...)
  23817. * @param isCube True if a cube texture needs to be created
  23818. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23819. * @param generateDepthBuffer True to generate a depth buffer
  23820. * @param generateStencilBuffer True to generate a stencil buffer
  23821. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23822. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23823. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23824. */
  23825. constructor(name: string, size: number | {
  23826. width: number;
  23827. height: number;
  23828. layers?: number;
  23829. } | {
  23830. ratio: number;
  23831. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23832. /**
  23833. * Creates a depth stencil texture.
  23834. * This is only available in WebGL 2 or with the depth texture extension available.
  23835. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23836. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23837. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23838. */
  23839. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23840. private _processSizeParameter;
  23841. /**
  23842. * Define the number of samples to use in case of MSAA.
  23843. * It defaults to one meaning no MSAA has been enabled.
  23844. */
  23845. get samples(): number;
  23846. set samples(value: number);
  23847. /**
  23848. * Resets the refresh counter of the texture and start bak from scratch.
  23849. * Could be useful to regenerate the texture if it is setup to render only once.
  23850. */
  23851. resetRefreshCounter(): void;
  23852. /**
  23853. * Define the refresh rate of the texture or the rendering frequency.
  23854. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23855. */
  23856. get refreshRate(): number;
  23857. set refreshRate(value: number);
  23858. /**
  23859. * Adds a post process to the render target rendering passes.
  23860. * @param postProcess define the post process to add
  23861. */
  23862. addPostProcess(postProcess: PostProcess): void;
  23863. /**
  23864. * Clear all the post processes attached to the render target
  23865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23866. */
  23867. clearPostProcesses(dispose?: boolean): void;
  23868. /**
  23869. * Remove one of the post process from the list of attached post processes to the texture
  23870. * @param postProcess define the post process to remove from the list
  23871. */
  23872. removePostProcess(postProcess: PostProcess): void;
  23873. /** @hidden */
  23874. _shouldRender(): boolean;
  23875. /**
  23876. * Gets the actual render size of the texture.
  23877. * @returns the width of the render size
  23878. */
  23879. getRenderSize(): number;
  23880. /**
  23881. * Gets the actual render width of the texture.
  23882. * @returns the width of the render size
  23883. */
  23884. getRenderWidth(): number;
  23885. /**
  23886. * Gets the actual render height of the texture.
  23887. * @returns the height of the render size
  23888. */
  23889. getRenderHeight(): number;
  23890. /**
  23891. * Gets the actual number of layers of the texture.
  23892. * @returns the number of layers
  23893. */
  23894. getRenderLayers(): number;
  23895. /**
  23896. * Get if the texture can be rescaled or not.
  23897. */
  23898. get canRescale(): boolean;
  23899. /**
  23900. * Resize the texture using a ratio.
  23901. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23902. */
  23903. scale(ratio: number): void;
  23904. /**
  23905. * Get the texture reflection matrix used to rotate/transform the reflection.
  23906. * @returns the reflection matrix
  23907. */
  23908. getReflectionTextureMatrix(): Matrix;
  23909. /**
  23910. * Resize the texture to a new desired size.
  23911. * Be carrefull as it will recreate all the data in the new texture.
  23912. * @param size Define the new size. It can be:
  23913. * - a number for squared texture,
  23914. * - an object containing { width: number, height: number }
  23915. * - or an object containing a ratio { ratio: number }
  23916. */
  23917. resize(size: number | {
  23918. width: number;
  23919. height: number;
  23920. } | {
  23921. ratio: number;
  23922. }): void;
  23923. private _defaultRenderListPrepared;
  23924. /**
  23925. * Renders all the objects from the render list into the texture.
  23926. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23927. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23928. */
  23929. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23930. private _bestReflectionRenderTargetDimension;
  23931. private _prepareRenderingManager;
  23932. /**
  23933. * @hidden
  23934. * @param faceIndex face index to bind to if this is a cubetexture
  23935. * @param layer defines the index of the texture to bind in the array
  23936. */
  23937. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23938. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23939. private renderToTarget;
  23940. /**
  23941. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23942. * This allowed control for front to back rendering or reversly depending of the special needs.
  23943. *
  23944. * @param renderingGroupId The rendering group id corresponding to its index
  23945. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23946. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23947. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23948. */
  23949. 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;
  23950. /**
  23951. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23952. *
  23953. * @param renderingGroupId The rendering group id corresponding to its index
  23954. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23955. */
  23956. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23957. /**
  23958. * Clones the texture.
  23959. * @returns the cloned texture
  23960. */
  23961. clone(): RenderTargetTexture;
  23962. /**
  23963. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23964. * @returns The JSON representation of the texture
  23965. */
  23966. serialize(): any;
  23967. /**
  23968. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23969. */
  23970. disposeFramebufferObjects(): void;
  23971. /**
  23972. * Dispose the texture and release its associated resources.
  23973. */
  23974. dispose(): void;
  23975. /** @hidden */
  23976. _rebuild(): void;
  23977. /**
  23978. * Clear the info related to rendering groups preventing retention point in material dispose.
  23979. */
  23980. freeRenderingGroups(): void;
  23981. /**
  23982. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23983. * @returns the view count
  23984. */
  23985. getViewCount(): number;
  23986. }
  23987. }
  23988. declare module BABYLON {
  23989. /**
  23990. * Class used to manipulate GUIDs
  23991. */
  23992. export class GUID {
  23993. /**
  23994. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23995. * Be aware Math.random() could cause collisions, but:
  23996. * "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"
  23997. * @returns a pseudo random id
  23998. */
  23999. static RandomId(): string;
  24000. }
  24001. }
  24002. declare module BABYLON {
  24003. /**
  24004. * Options to be used when creating a shadow depth material
  24005. */
  24006. export interface IIOptionShadowDepthMaterial {
  24007. /** Variables in the vertex shader code that need to have their names remapped.
  24008. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24009. * "var_name" should be either: worldPos or vNormalW
  24010. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24011. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24012. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24013. */
  24014. remappedVariables?: string[];
  24015. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24016. standalone?: boolean;
  24017. }
  24018. /**
  24019. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24020. */
  24021. export class ShadowDepthWrapper {
  24022. private _scene;
  24023. private _options?;
  24024. private _baseMaterial;
  24025. private _onEffectCreatedObserver;
  24026. private _subMeshToEffect;
  24027. private _subMeshToDepthEffect;
  24028. private _meshes;
  24029. /** @hidden */
  24030. _matriceNames: any;
  24031. /** Gets the standalone status of the wrapper */
  24032. get standalone(): boolean;
  24033. /** Gets the base material the wrapper is built upon */
  24034. get baseMaterial(): Material;
  24035. /**
  24036. * Instantiate a new shadow depth wrapper.
  24037. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24038. * generate the shadow depth map. For more information, please refer to the documentation:
  24039. * https://doc.babylonjs.com/babylon101/shadows
  24040. * @param baseMaterial Material to wrap
  24041. * @param scene Define the scene the material belongs to
  24042. * @param options Options used to create the wrapper
  24043. */
  24044. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24045. /**
  24046. * Gets the effect to use to generate the depth map
  24047. * @param subMesh subMesh to get the effect for
  24048. * @param shadowGenerator shadow generator to get the effect for
  24049. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24050. */
  24051. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24052. /**
  24053. * Specifies that the submesh is ready to be used for depth rendering
  24054. * @param subMesh submesh to check
  24055. * @param defines the list of defines to take into account when checking the effect
  24056. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24057. * @param useInstances specifies that instances should be used
  24058. * @returns a boolean indicating that the submesh is ready or not
  24059. */
  24060. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24061. /**
  24062. * Disposes the resources
  24063. */
  24064. dispose(): void;
  24065. private _makeEffect;
  24066. }
  24067. }
  24068. declare module BABYLON {
  24069. interface ThinEngine {
  24070. /**
  24071. * Unbind a list of render target textures from the webGL context
  24072. * This is used only when drawBuffer extension or webGL2 are active
  24073. * @param textures defines the render target textures to unbind
  24074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24076. */
  24077. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24078. /**
  24079. * Create a multi render target texture
  24080. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24081. * @param size defines the size of the texture
  24082. * @param options defines the creation options
  24083. * @returns the cube texture as an InternalTexture
  24084. */
  24085. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24086. /**
  24087. * Update the sample count for a given multiple render target texture
  24088. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24089. * @param textures defines the textures to update
  24090. * @param samples defines the sample count to set
  24091. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24092. */
  24093. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24094. /**
  24095. * Select a subsets of attachments to draw to.
  24096. * @param attachments gl attachments
  24097. */
  24098. bindAttachments(attachments: number[]): void;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Creation options of the multi render target texture.
  24104. */
  24105. export interface IMultiRenderTargetOptions {
  24106. /**
  24107. * Define if the texture needs to create mip maps after render.
  24108. */
  24109. generateMipMaps?: boolean;
  24110. /**
  24111. * Define the types of all the draw buffers we want to create
  24112. */
  24113. types?: number[];
  24114. /**
  24115. * Define the sampling modes of all the draw buffers we want to create
  24116. */
  24117. samplingModes?: number[];
  24118. /**
  24119. * Define if a depth buffer is required
  24120. */
  24121. generateDepthBuffer?: boolean;
  24122. /**
  24123. * Define if a stencil buffer is required
  24124. */
  24125. generateStencilBuffer?: boolean;
  24126. /**
  24127. * Define if a depth texture is required instead of a depth buffer
  24128. */
  24129. generateDepthTexture?: boolean;
  24130. /**
  24131. * Define the number of desired draw buffers
  24132. */
  24133. textureCount?: number;
  24134. /**
  24135. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24136. */
  24137. doNotChangeAspectRatio?: boolean;
  24138. /**
  24139. * Define the default type of the buffers we are creating
  24140. */
  24141. defaultType?: number;
  24142. }
  24143. /**
  24144. * A multi render target, like a render target provides the ability to render to a texture.
  24145. * Unlike the render target, it can render to several draw buffers in one draw.
  24146. * This is specially interesting in deferred rendering or for any effects requiring more than
  24147. * just one color from a single pass.
  24148. */
  24149. export class MultiRenderTarget extends RenderTargetTexture {
  24150. private _internalTextures;
  24151. private _textures;
  24152. private _multiRenderTargetOptions;
  24153. private _count;
  24154. /**
  24155. * Get if draw buffers are currently supported by the used hardware and browser.
  24156. */
  24157. get isSupported(): boolean;
  24158. /**
  24159. * Get the list of textures generated by the multi render target.
  24160. */
  24161. get textures(): Texture[];
  24162. /**
  24163. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24164. */
  24165. get count(): number;
  24166. /**
  24167. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24168. */
  24169. get depthTexture(): Texture;
  24170. /**
  24171. * Set the wrapping mode on U of all the textures we are rendering to.
  24172. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24173. */
  24174. set wrapU(wrap: number);
  24175. /**
  24176. * Set the wrapping mode on V of all the textures we are rendering to.
  24177. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24178. */
  24179. set wrapV(wrap: number);
  24180. /**
  24181. * Instantiate a new multi render target texture.
  24182. * A multi render target, like a render target provides the ability to render to a texture.
  24183. * Unlike the render target, it can render to several draw buffers in one draw.
  24184. * This is specially interesting in deferred rendering or for any effects requiring more than
  24185. * just one color from a single pass.
  24186. * @param name Define the name of the texture
  24187. * @param size Define the size of the buffers to render to
  24188. * @param count Define the number of target we are rendering into
  24189. * @param scene Define the scene the texture belongs to
  24190. * @param options Define the options used to create the multi render target
  24191. */
  24192. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24193. private _initTypes;
  24194. /** @hidden */
  24195. _rebuild(forceFullRebuild?: boolean): void;
  24196. private _createInternalTextures;
  24197. private _createTextures;
  24198. /**
  24199. * Define the number of samples used if MSAA is enabled.
  24200. */
  24201. get samples(): number;
  24202. set samples(value: number);
  24203. /**
  24204. * Resize all the textures in the multi render target.
  24205. * Be careful as it will recreate all the data in the new texture.
  24206. * @param size Define the new size
  24207. */
  24208. resize(size: any): void;
  24209. /**
  24210. * Changes the number of render targets in this MRT
  24211. * Be careful as it will recreate all the data in the new texture.
  24212. * @param count new texture count
  24213. * @param options Specifies texture types and sampling modes for new textures
  24214. */
  24215. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24217. /**
  24218. * Dispose the render targets and their associated resources
  24219. */
  24220. dispose(): void;
  24221. /**
  24222. * Release all the underlying texture used as draw buffers.
  24223. */
  24224. releaseInternalTextures(): void;
  24225. }
  24226. }
  24227. declare module BABYLON {
  24228. /** @hidden */
  24229. export var imageProcessingPixelShader: {
  24230. name: string;
  24231. shader: string;
  24232. };
  24233. }
  24234. declare module BABYLON {
  24235. /**
  24236. * ImageProcessingPostProcess
  24237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24238. */
  24239. export class ImageProcessingPostProcess extends PostProcess {
  24240. /**
  24241. * Default configuration related to image processing available in the PBR Material.
  24242. */
  24243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24244. /**
  24245. * Gets the image processing configuration used either in this material.
  24246. */
  24247. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24248. /**
  24249. * Sets the Default image processing configuration used either in the this material.
  24250. *
  24251. * If sets to null, the scene one is in use.
  24252. */
  24253. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24254. /**
  24255. * Keep track of the image processing observer to allow dispose and replace.
  24256. */
  24257. private _imageProcessingObserver;
  24258. /**
  24259. * Attaches a new image processing configuration to the PBR Material.
  24260. * @param configuration
  24261. */
  24262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24263. /**
  24264. * If the post process is supported.
  24265. */
  24266. get isSupported(): boolean;
  24267. /**
  24268. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24269. */
  24270. get colorCurves(): Nullable<ColorCurves>;
  24271. /**
  24272. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24273. */
  24274. set colorCurves(value: Nullable<ColorCurves>);
  24275. /**
  24276. * Gets wether the color curves effect is enabled.
  24277. */
  24278. get colorCurvesEnabled(): boolean;
  24279. /**
  24280. * Sets wether the color curves effect is enabled.
  24281. */
  24282. set colorCurvesEnabled(value: boolean);
  24283. /**
  24284. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24285. */
  24286. get colorGradingTexture(): Nullable<BaseTexture>;
  24287. /**
  24288. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24289. */
  24290. set colorGradingTexture(value: Nullable<BaseTexture>);
  24291. /**
  24292. * Gets wether the color grading effect is enabled.
  24293. */
  24294. get colorGradingEnabled(): boolean;
  24295. /**
  24296. * Gets wether the color grading effect is enabled.
  24297. */
  24298. set colorGradingEnabled(value: boolean);
  24299. /**
  24300. * Gets exposure used in the effect.
  24301. */
  24302. get exposure(): number;
  24303. /**
  24304. * Sets exposure used in the effect.
  24305. */
  24306. set exposure(value: number);
  24307. /**
  24308. * Gets wether tonemapping is enabled or not.
  24309. */
  24310. get toneMappingEnabled(): boolean;
  24311. /**
  24312. * Sets wether tonemapping is enabled or not
  24313. */
  24314. set toneMappingEnabled(value: boolean);
  24315. /**
  24316. * Gets the type of tone mapping effect.
  24317. */
  24318. get toneMappingType(): number;
  24319. /**
  24320. * Sets the type of tone mapping effect.
  24321. */
  24322. set toneMappingType(value: number);
  24323. /**
  24324. * Gets contrast used in the effect.
  24325. */
  24326. get contrast(): number;
  24327. /**
  24328. * Sets contrast used in the effect.
  24329. */
  24330. set contrast(value: number);
  24331. /**
  24332. * Gets Vignette stretch size.
  24333. */
  24334. get vignetteStretch(): number;
  24335. /**
  24336. * Sets Vignette stretch size.
  24337. */
  24338. set vignetteStretch(value: number);
  24339. /**
  24340. * Gets Vignette centre X Offset.
  24341. */
  24342. get vignetteCentreX(): number;
  24343. /**
  24344. * Sets Vignette centre X Offset.
  24345. */
  24346. set vignetteCentreX(value: number);
  24347. /**
  24348. * Gets Vignette centre Y Offset.
  24349. */
  24350. get vignetteCentreY(): number;
  24351. /**
  24352. * Sets Vignette centre Y Offset.
  24353. */
  24354. set vignetteCentreY(value: number);
  24355. /**
  24356. * Gets Vignette weight or intensity of the vignette effect.
  24357. */
  24358. get vignetteWeight(): number;
  24359. /**
  24360. * Sets Vignette weight or intensity of the vignette effect.
  24361. */
  24362. set vignetteWeight(value: number);
  24363. /**
  24364. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24365. * if vignetteEnabled is set to true.
  24366. */
  24367. get vignetteColor(): Color4;
  24368. /**
  24369. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24370. * if vignetteEnabled is set to true.
  24371. */
  24372. set vignetteColor(value: Color4);
  24373. /**
  24374. * Gets Camera field of view used by the Vignette effect.
  24375. */
  24376. get vignetteCameraFov(): number;
  24377. /**
  24378. * Sets Camera field of view used by the Vignette effect.
  24379. */
  24380. set vignetteCameraFov(value: number);
  24381. /**
  24382. * Gets the vignette blend mode allowing different kind of effect.
  24383. */
  24384. get vignetteBlendMode(): number;
  24385. /**
  24386. * Sets the vignette blend mode allowing different kind of effect.
  24387. */
  24388. set vignetteBlendMode(value: number);
  24389. /**
  24390. * Gets wether the vignette effect is enabled.
  24391. */
  24392. get vignetteEnabled(): boolean;
  24393. /**
  24394. * Sets wether the vignette effect is enabled.
  24395. */
  24396. set vignetteEnabled(value: boolean);
  24397. private _fromLinearSpace;
  24398. /**
  24399. * Gets wether the input of the processing is in Gamma or Linear Space.
  24400. */
  24401. get fromLinearSpace(): boolean;
  24402. /**
  24403. * Sets wether the input of the processing is in Gamma or Linear Space.
  24404. */
  24405. set fromLinearSpace(value: boolean);
  24406. /**
  24407. * Defines cache preventing GC.
  24408. */
  24409. private _defines;
  24410. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24411. /**
  24412. * "ImageProcessingPostProcess"
  24413. * @returns "ImageProcessingPostProcess"
  24414. */
  24415. getClassName(): string;
  24416. /**
  24417. * @hidden
  24418. */
  24419. _updateParameters(): void;
  24420. dispose(camera?: Camera): void;
  24421. }
  24422. }
  24423. declare module BABYLON {
  24424. /**
  24425. * Interface for defining prepass effects in the prepass post-process pipeline
  24426. */
  24427. export interface PrePassEffectConfiguration {
  24428. /**
  24429. * Name of the effect
  24430. */
  24431. name: string;
  24432. /**
  24433. * Post process to attach for this effect
  24434. */
  24435. postProcess?: PostProcess;
  24436. /**
  24437. * Textures required in the MRT
  24438. */
  24439. texturesRequired: number[];
  24440. /**
  24441. * Is the effect enabled
  24442. */
  24443. enabled: boolean;
  24444. /**
  24445. * Disposes the effect configuration
  24446. */
  24447. dispose(): void;
  24448. /**
  24449. * Creates the associated post process
  24450. */
  24451. createPostProcess?: () => PostProcess;
  24452. }
  24453. }
  24454. declare module BABYLON {
  24455. /**
  24456. * Renders a pre pass of the scene
  24457. * This means every mesh in the scene will be rendered to a render target texture
  24458. * And then this texture will be composited to the rendering canvas with post processes
  24459. * It is necessary for effects like subsurface scattering or deferred shading
  24460. */
  24461. export class PrePassRenderer {
  24462. /** @hidden */
  24463. static _SceneComponentInitialization: (scene: Scene) => void;
  24464. private _textureFormats;
  24465. private _textureIndices;
  24466. private _scene;
  24467. private _engine;
  24468. private _isDirty;
  24469. /**
  24470. * Number of textures in the multi render target texture where the scene is directly rendered
  24471. */
  24472. mrtCount: number;
  24473. /**
  24474. * The render target where the scene is directly rendered
  24475. */
  24476. prePassRT: MultiRenderTarget;
  24477. private _multiRenderAttachments;
  24478. private _defaultAttachments;
  24479. private _clearAttachments;
  24480. private _postProcesses;
  24481. private readonly _clearColor;
  24482. /**
  24483. * Image processing post process for composition
  24484. */
  24485. imageProcessingPostProcess: ImageProcessingPostProcess;
  24486. /**
  24487. * Configuration for prepass effects
  24488. */
  24489. private _effectConfigurations;
  24490. /**
  24491. * Should materials render their geometry on the MRT
  24492. */
  24493. materialsShouldRenderGeometry: boolean;
  24494. /**
  24495. * Should materials render the irradiance information on the MRT
  24496. */
  24497. materialsShouldRenderIrradiance: boolean;
  24498. private _mrtFormats;
  24499. private _mrtLayout;
  24500. private _enabled;
  24501. /**
  24502. * Indicates if the prepass is enabled
  24503. */
  24504. get enabled(): boolean;
  24505. /**
  24506. * How many samples are used for MSAA of the scene render target
  24507. */
  24508. get samples(): number;
  24509. set samples(n: number);
  24510. /**
  24511. * Instanciates a prepass renderer
  24512. * @param scene The scene
  24513. */
  24514. constructor(scene: Scene);
  24515. private _initializeAttachments;
  24516. private _createCompositionEffect;
  24517. /**
  24518. * Indicates if rendering a prepass is supported
  24519. */
  24520. get isSupported(): boolean;
  24521. /**
  24522. * Sets the proper output textures to draw in the engine.
  24523. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24524. */
  24525. bindAttachmentsForEffect(effect: Effect): void;
  24526. /**
  24527. * @hidden
  24528. */
  24529. _beforeCameraDraw(): void;
  24530. /**
  24531. * @hidden
  24532. */
  24533. _afterCameraDraw(): void;
  24534. private _checkRTSize;
  24535. private _bindFrameBuffer;
  24536. /**
  24537. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24538. */
  24539. clear(): void;
  24540. private _setState;
  24541. private _checkTextureType;
  24542. /**
  24543. * Adds an effect configuration to the prepass.
  24544. * If an effect has already been added, it won't add it twice and will return the configuration
  24545. * already present.
  24546. * @param cfg the effect configuration
  24547. * @return the effect configuration now used by the prepass
  24548. */
  24549. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24550. /**
  24551. * Returns the index of a texture in the multi render target texture array.
  24552. * @param type Texture type
  24553. * @return The index
  24554. */
  24555. getIndex(type: number): number;
  24556. private _enable;
  24557. private _disable;
  24558. private _resetLayout;
  24559. private _resetPostProcessChain;
  24560. private _bindPostProcessChain;
  24561. /**
  24562. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24563. */
  24564. markAsDirty(): void;
  24565. /**
  24566. * Enables a texture on the MultiRenderTarget for prepass
  24567. */
  24568. private _enableTextures;
  24569. private _update;
  24570. /**
  24571. * Disposes the prepass renderer.
  24572. */
  24573. dispose(): void;
  24574. }
  24575. }
  24576. declare module BABYLON {
  24577. /**
  24578. * Options for compiling materials.
  24579. */
  24580. export interface IMaterialCompilationOptions {
  24581. /**
  24582. * Defines whether clip planes are enabled.
  24583. */
  24584. clipPlane: boolean;
  24585. /**
  24586. * Defines whether instances are enabled.
  24587. */
  24588. useInstances: boolean;
  24589. }
  24590. /**
  24591. * Options passed when calling customShaderNameResolve
  24592. */
  24593. export interface ICustomShaderNameResolveOptions {
  24594. /**
  24595. * 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
  24596. */
  24597. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24598. }
  24599. /**
  24600. * Base class for the main features of a material in Babylon.js
  24601. */
  24602. export class Material implements IAnimatable {
  24603. /**
  24604. * Returns the triangle fill mode
  24605. */
  24606. static readonly TriangleFillMode: number;
  24607. /**
  24608. * Returns the wireframe mode
  24609. */
  24610. static readonly WireFrameFillMode: number;
  24611. /**
  24612. * Returns the point fill mode
  24613. */
  24614. static readonly PointFillMode: number;
  24615. /**
  24616. * Returns the point list draw mode
  24617. */
  24618. static readonly PointListDrawMode: number;
  24619. /**
  24620. * Returns the line list draw mode
  24621. */
  24622. static readonly LineListDrawMode: number;
  24623. /**
  24624. * Returns the line loop draw mode
  24625. */
  24626. static readonly LineLoopDrawMode: number;
  24627. /**
  24628. * Returns the line strip draw mode
  24629. */
  24630. static readonly LineStripDrawMode: number;
  24631. /**
  24632. * Returns the triangle strip draw mode
  24633. */
  24634. static readonly TriangleStripDrawMode: number;
  24635. /**
  24636. * Returns the triangle fan draw mode
  24637. */
  24638. static readonly TriangleFanDrawMode: number;
  24639. /**
  24640. * Stores the clock-wise side orientation
  24641. */
  24642. static readonly ClockWiseSideOrientation: number;
  24643. /**
  24644. * Stores the counter clock-wise side orientation
  24645. */
  24646. static readonly CounterClockWiseSideOrientation: number;
  24647. /**
  24648. * The dirty texture flag value
  24649. */
  24650. static readonly TextureDirtyFlag: number;
  24651. /**
  24652. * The dirty light flag value
  24653. */
  24654. static readonly LightDirtyFlag: number;
  24655. /**
  24656. * The dirty fresnel flag value
  24657. */
  24658. static readonly FresnelDirtyFlag: number;
  24659. /**
  24660. * The dirty attribute flag value
  24661. */
  24662. static readonly AttributesDirtyFlag: number;
  24663. /**
  24664. * The dirty misc flag value
  24665. */
  24666. static readonly MiscDirtyFlag: number;
  24667. /**
  24668. * The all dirty flag value
  24669. */
  24670. static readonly AllDirtyFlag: number;
  24671. /**
  24672. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24673. */
  24674. static readonly MATERIAL_OPAQUE: number;
  24675. /**
  24676. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24677. */
  24678. static readonly MATERIAL_ALPHATEST: number;
  24679. /**
  24680. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24681. */
  24682. static readonly MATERIAL_ALPHABLEND: number;
  24683. /**
  24684. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24685. * They are also discarded below the alpha cutoff threshold to improve performances.
  24686. */
  24687. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24688. /**
  24689. * The Whiteout method is used to blend normals.
  24690. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24691. */
  24692. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24693. /**
  24694. * The Reoriented Normal Mapping method is used to blend normals.
  24695. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24696. */
  24697. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24698. /**
  24699. * Custom callback helping to override the default shader used in the material.
  24700. */
  24701. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24702. /**
  24703. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24704. */
  24705. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24706. /**
  24707. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24708. * This means that the material can keep using a previous shader while a new one is being compiled.
  24709. * This is mostly used when shader parallel compilation is supported (true by default)
  24710. */
  24711. allowShaderHotSwapping: boolean;
  24712. /**
  24713. * The ID of the material
  24714. */
  24715. id: string;
  24716. /**
  24717. * Gets or sets the unique id of the material
  24718. */
  24719. uniqueId: number;
  24720. /**
  24721. * The name of the material
  24722. */
  24723. name: string;
  24724. /**
  24725. * Gets or sets user defined metadata
  24726. */
  24727. metadata: any;
  24728. /**
  24729. * For internal use only. Please do not use.
  24730. */
  24731. reservedDataStore: any;
  24732. /**
  24733. * Specifies if the ready state should be checked on each call
  24734. */
  24735. checkReadyOnEveryCall: boolean;
  24736. /**
  24737. * Specifies if the ready state should be checked once
  24738. */
  24739. checkReadyOnlyOnce: boolean;
  24740. /**
  24741. * The state of the material
  24742. */
  24743. state: string;
  24744. /**
  24745. * If the material can be rendered to several textures with MRT extension
  24746. */
  24747. get canRenderToMRT(): boolean;
  24748. /**
  24749. * The alpha value of the material
  24750. */
  24751. protected _alpha: number;
  24752. /**
  24753. * List of inspectable custom properties (used by the Inspector)
  24754. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24755. */
  24756. inspectableCustomProperties: IInspectable[];
  24757. /**
  24758. * Sets the alpha value of the material
  24759. */
  24760. set alpha(value: number);
  24761. /**
  24762. * Gets the alpha value of the material
  24763. */
  24764. get alpha(): number;
  24765. /**
  24766. * Specifies if back face culling is enabled
  24767. */
  24768. protected _backFaceCulling: boolean;
  24769. /**
  24770. * Sets the back-face culling state
  24771. */
  24772. set backFaceCulling(value: boolean);
  24773. /**
  24774. * Gets the back-face culling state
  24775. */
  24776. get backFaceCulling(): boolean;
  24777. /**
  24778. * Stores the value for side orientation
  24779. */
  24780. sideOrientation: number;
  24781. /**
  24782. * Callback triggered when the material is compiled
  24783. */
  24784. onCompiled: Nullable<(effect: Effect) => void>;
  24785. /**
  24786. * Callback triggered when an error occurs
  24787. */
  24788. onError: Nullable<(effect: Effect, errors: string) => void>;
  24789. /**
  24790. * Callback triggered to get the render target textures
  24791. */
  24792. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24793. /**
  24794. * Gets a boolean indicating that current material needs to register RTT
  24795. */
  24796. get hasRenderTargetTextures(): boolean;
  24797. /**
  24798. * Specifies if the material should be serialized
  24799. */
  24800. doNotSerialize: boolean;
  24801. /**
  24802. * @hidden
  24803. */
  24804. _storeEffectOnSubMeshes: boolean;
  24805. /**
  24806. * Stores the animations for the material
  24807. */
  24808. animations: Nullable<Array<Animation>>;
  24809. /**
  24810. * An event triggered when the material is disposed
  24811. */
  24812. onDisposeObservable: Observable<Material>;
  24813. /**
  24814. * An observer which watches for dispose events
  24815. */
  24816. private _onDisposeObserver;
  24817. private _onUnBindObservable;
  24818. /**
  24819. * Called during a dispose event
  24820. */
  24821. set onDispose(callback: () => void);
  24822. private _onBindObservable;
  24823. /**
  24824. * An event triggered when the material is bound
  24825. */
  24826. get onBindObservable(): Observable<AbstractMesh>;
  24827. /**
  24828. * An observer which watches for bind events
  24829. */
  24830. private _onBindObserver;
  24831. /**
  24832. * Called during a bind event
  24833. */
  24834. set onBind(callback: (Mesh: AbstractMesh) => void);
  24835. /**
  24836. * An event triggered when the material is unbound
  24837. */
  24838. get onUnBindObservable(): Observable<Material>;
  24839. protected _onEffectCreatedObservable: Nullable<Observable<{
  24840. effect: Effect;
  24841. subMesh: Nullable<SubMesh>;
  24842. }>>;
  24843. /**
  24844. * An event triggered when the effect is (re)created
  24845. */
  24846. get onEffectCreatedObservable(): Observable<{
  24847. effect: Effect;
  24848. subMesh: Nullable<SubMesh>;
  24849. }>;
  24850. /**
  24851. * Stores the value of the alpha mode
  24852. */
  24853. private _alphaMode;
  24854. /**
  24855. * Sets the value of the alpha mode.
  24856. *
  24857. * | Value | Type | Description |
  24858. * | --- | --- | --- |
  24859. * | 0 | ALPHA_DISABLE | |
  24860. * | 1 | ALPHA_ADD | |
  24861. * | 2 | ALPHA_COMBINE | |
  24862. * | 3 | ALPHA_SUBTRACT | |
  24863. * | 4 | ALPHA_MULTIPLY | |
  24864. * | 5 | ALPHA_MAXIMIZED | |
  24865. * | 6 | ALPHA_ONEONE | |
  24866. * | 7 | ALPHA_PREMULTIPLIED | |
  24867. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24868. * | 9 | ALPHA_INTERPOLATE | |
  24869. * | 10 | ALPHA_SCREENMODE | |
  24870. *
  24871. */
  24872. set alphaMode(value: number);
  24873. /**
  24874. * Gets the value of the alpha mode
  24875. */
  24876. get alphaMode(): number;
  24877. /**
  24878. * Stores the state of the need depth pre-pass value
  24879. */
  24880. private _needDepthPrePass;
  24881. /**
  24882. * Sets the need depth pre-pass value
  24883. */
  24884. set needDepthPrePass(value: boolean);
  24885. /**
  24886. * Gets the depth pre-pass value
  24887. */
  24888. get needDepthPrePass(): boolean;
  24889. /**
  24890. * Specifies if depth writing should be disabled
  24891. */
  24892. disableDepthWrite: boolean;
  24893. /**
  24894. * Specifies if color writing should be disabled
  24895. */
  24896. disableColorWrite: boolean;
  24897. /**
  24898. * Specifies if depth writing should be forced
  24899. */
  24900. forceDepthWrite: boolean;
  24901. /**
  24902. * Specifies the depth function that should be used. 0 means the default engine function
  24903. */
  24904. depthFunction: number;
  24905. /**
  24906. * Specifies if there should be a separate pass for culling
  24907. */
  24908. separateCullingPass: boolean;
  24909. /**
  24910. * Stores the state specifing if fog should be enabled
  24911. */
  24912. private _fogEnabled;
  24913. /**
  24914. * Sets the state for enabling fog
  24915. */
  24916. set fogEnabled(value: boolean);
  24917. /**
  24918. * Gets the value of the fog enabled state
  24919. */
  24920. get fogEnabled(): boolean;
  24921. /**
  24922. * Stores the size of points
  24923. */
  24924. pointSize: number;
  24925. /**
  24926. * Stores the z offset value
  24927. */
  24928. zOffset: number;
  24929. get wireframe(): boolean;
  24930. /**
  24931. * Sets the state of wireframe mode
  24932. */
  24933. set wireframe(value: boolean);
  24934. /**
  24935. * Gets the value specifying if point clouds are enabled
  24936. */
  24937. get pointsCloud(): boolean;
  24938. /**
  24939. * Sets the state of point cloud mode
  24940. */
  24941. set pointsCloud(value: boolean);
  24942. /**
  24943. * Gets the material fill mode
  24944. */
  24945. get fillMode(): number;
  24946. /**
  24947. * Sets the material fill mode
  24948. */
  24949. set fillMode(value: number);
  24950. /**
  24951. * @hidden
  24952. * Stores the effects for the material
  24953. */
  24954. _effect: Nullable<Effect>;
  24955. /**
  24956. * Specifies if uniform buffers should be used
  24957. */
  24958. private _useUBO;
  24959. /**
  24960. * Stores a reference to the scene
  24961. */
  24962. private _scene;
  24963. /**
  24964. * Stores the fill mode state
  24965. */
  24966. private _fillMode;
  24967. /**
  24968. * Specifies if the depth write state should be cached
  24969. */
  24970. private _cachedDepthWriteState;
  24971. /**
  24972. * Specifies if the color write state should be cached
  24973. */
  24974. private _cachedColorWriteState;
  24975. /**
  24976. * Specifies if the depth function state should be cached
  24977. */
  24978. private _cachedDepthFunctionState;
  24979. /**
  24980. * Stores the uniform buffer
  24981. */
  24982. protected _uniformBuffer: UniformBuffer;
  24983. /** @hidden */
  24984. _indexInSceneMaterialArray: number;
  24985. /** @hidden */
  24986. meshMap: Nullable<{
  24987. [id: string]: AbstractMesh | undefined;
  24988. }>;
  24989. /**
  24990. * Creates a material instance
  24991. * @param name defines the name of the material
  24992. * @param scene defines the scene to reference
  24993. * @param doNotAdd specifies if the material should be added to the scene
  24994. */
  24995. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24996. /**
  24997. * Returns a string representation of the current material
  24998. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24999. * @returns a string with material information
  25000. */
  25001. toString(fullDetails?: boolean): string;
  25002. /**
  25003. * Gets the class name of the material
  25004. * @returns a string with the class name of the material
  25005. */
  25006. getClassName(): string;
  25007. /**
  25008. * Specifies if updates for the material been locked
  25009. */
  25010. get isFrozen(): boolean;
  25011. /**
  25012. * Locks updates for the material
  25013. */
  25014. freeze(): void;
  25015. /**
  25016. * Unlocks updates for the material
  25017. */
  25018. unfreeze(): void;
  25019. /**
  25020. * Specifies if the material is ready to be used
  25021. * @param mesh defines the mesh to check
  25022. * @param useInstances specifies if instances should be used
  25023. * @returns a boolean indicating if the material is ready to be used
  25024. */
  25025. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25026. /**
  25027. * Specifies that the submesh is ready to be used
  25028. * @param mesh defines the mesh to check
  25029. * @param subMesh defines which submesh to check
  25030. * @param useInstances specifies that instances should be used
  25031. * @returns a boolean indicating that the submesh is ready or not
  25032. */
  25033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25034. /**
  25035. * Returns the material effect
  25036. * @returns the effect associated with the material
  25037. */
  25038. getEffect(): Nullable<Effect>;
  25039. /**
  25040. * Returns the current scene
  25041. * @returns a Scene
  25042. */
  25043. getScene(): Scene;
  25044. /**
  25045. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25046. */
  25047. protected _forceAlphaTest: boolean;
  25048. /**
  25049. * The transparency mode of the material.
  25050. */
  25051. protected _transparencyMode: Nullable<number>;
  25052. /**
  25053. * Gets the current transparency mode.
  25054. */
  25055. get transparencyMode(): Nullable<number>;
  25056. /**
  25057. * Sets the transparency mode of the material.
  25058. *
  25059. * | Value | Type | Description |
  25060. * | ----- | ----------------------------------- | ----------- |
  25061. * | 0 | OPAQUE | |
  25062. * | 1 | ALPHATEST | |
  25063. * | 2 | ALPHABLEND | |
  25064. * | 3 | ALPHATESTANDBLEND | |
  25065. *
  25066. */
  25067. set transparencyMode(value: Nullable<number>);
  25068. /**
  25069. * Returns true if alpha blending should be disabled.
  25070. */
  25071. protected get _disableAlphaBlending(): boolean;
  25072. /**
  25073. * Specifies whether or not this material should be rendered in alpha blend mode.
  25074. * @returns a boolean specifying if alpha blending is needed
  25075. */
  25076. needAlphaBlending(): boolean;
  25077. /**
  25078. * Specifies if the mesh will require alpha blending
  25079. * @param mesh defines the mesh to check
  25080. * @returns a boolean specifying if alpha blending is needed for the mesh
  25081. */
  25082. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25083. /**
  25084. * Specifies whether or not this material should be rendered in alpha test mode.
  25085. * @returns a boolean specifying if an alpha test is needed.
  25086. */
  25087. needAlphaTesting(): boolean;
  25088. /**
  25089. * Specifies if material alpha testing should be turned on for the mesh
  25090. * @param mesh defines the mesh to check
  25091. */
  25092. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25093. /**
  25094. * Gets the texture used for the alpha test
  25095. * @returns the texture to use for alpha testing
  25096. */
  25097. getAlphaTestTexture(): Nullable<BaseTexture>;
  25098. /**
  25099. * Marks the material to indicate that it needs to be re-calculated
  25100. */
  25101. markDirty(): void;
  25102. /** @hidden */
  25103. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25104. /**
  25105. * Binds the material to the mesh
  25106. * @param world defines the world transformation matrix
  25107. * @param mesh defines the mesh to bind the material to
  25108. */
  25109. bind(world: Matrix, mesh?: Mesh): void;
  25110. /**
  25111. * Binds the submesh to the material
  25112. * @param world defines the world transformation matrix
  25113. * @param mesh defines the mesh containing the submesh
  25114. * @param subMesh defines the submesh to bind the material to
  25115. */
  25116. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25117. /**
  25118. * Binds the world matrix to the material
  25119. * @param world defines the world transformation matrix
  25120. */
  25121. bindOnlyWorldMatrix(world: Matrix): void;
  25122. /**
  25123. * Binds the scene's uniform buffer to the effect.
  25124. * @param effect defines the effect to bind to the scene uniform buffer
  25125. * @param sceneUbo defines the uniform buffer storing scene data
  25126. */
  25127. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25128. /**
  25129. * Binds the view matrix to the effect
  25130. * @param effect defines the effect to bind the view matrix to
  25131. */
  25132. bindView(effect: Effect): void;
  25133. /**
  25134. * Binds the view projection matrix to the effect
  25135. * @param effect defines the effect to bind the view projection matrix to
  25136. */
  25137. bindViewProjection(effect: Effect): void;
  25138. /**
  25139. * Processes to execute after binding the material to a mesh
  25140. * @param mesh defines the rendered mesh
  25141. */
  25142. protected _afterBind(mesh?: Mesh): void;
  25143. /**
  25144. * Unbinds the material from the mesh
  25145. */
  25146. unbind(): void;
  25147. /**
  25148. * Gets the active textures from the material
  25149. * @returns an array of textures
  25150. */
  25151. getActiveTextures(): BaseTexture[];
  25152. /**
  25153. * Specifies if the material uses a texture
  25154. * @param texture defines the texture to check against the material
  25155. * @returns a boolean specifying if the material uses the texture
  25156. */
  25157. hasTexture(texture: BaseTexture): boolean;
  25158. /**
  25159. * Makes a duplicate of the material, and gives it a new name
  25160. * @param name defines the new name for the duplicated material
  25161. * @returns the cloned material
  25162. */
  25163. clone(name: string): Nullable<Material>;
  25164. /**
  25165. * Gets the meshes bound to the material
  25166. * @returns an array of meshes bound to the material
  25167. */
  25168. getBindedMeshes(): AbstractMesh[];
  25169. /**
  25170. * Force shader compilation
  25171. * @param mesh defines the mesh associated with this material
  25172. * @param onCompiled defines a function to execute once the material is compiled
  25173. * @param options defines the options to configure the compilation
  25174. * @param onError defines a function to execute if the material fails compiling
  25175. */
  25176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25177. /**
  25178. * Force shader compilation
  25179. * @param mesh defines the mesh that will use this material
  25180. * @param options defines additional options for compiling the shaders
  25181. * @returns a promise that resolves when the compilation completes
  25182. */
  25183. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25184. private static readonly _AllDirtyCallBack;
  25185. private static readonly _ImageProcessingDirtyCallBack;
  25186. private static readonly _TextureDirtyCallBack;
  25187. private static readonly _FresnelDirtyCallBack;
  25188. private static readonly _MiscDirtyCallBack;
  25189. private static readonly _LightsDirtyCallBack;
  25190. private static readonly _AttributeDirtyCallBack;
  25191. private static _FresnelAndMiscDirtyCallBack;
  25192. private static _TextureAndMiscDirtyCallBack;
  25193. private static readonly _DirtyCallbackArray;
  25194. private static readonly _RunDirtyCallBacks;
  25195. /**
  25196. * Marks a define in the material to indicate that it needs to be re-computed
  25197. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25198. */
  25199. markAsDirty(flag: number): void;
  25200. /**
  25201. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25202. * @param func defines a function which checks material defines against the submeshes
  25203. */
  25204. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25205. /**
  25206. * Indicates that the scene should check if the rendering now needs a prepass
  25207. */
  25208. protected _markScenePrePassDirty(): void;
  25209. /**
  25210. * Indicates that we need to re-calculated for all submeshes
  25211. */
  25212. protected _markAllSubMeshesAsAllDirty(): void;
  25213. /**
  25214. * Indicates that image processing needs to be re-calculated for all submeshes
  25215. */
  25216. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25217. /**
  25218. * Indicates that textures need to be re-calculated for all submeshes
  25219. */
  25220. protected _markAllSubMeshesAsTexturesDirty(): void;
  25221. /**
  25222. * Indicates that fresnel needs to be re-calculated for all submeshes
  25223. */
  25224. protected _markAllSubMeshesAsFresnelDirty(): void;
  25225. /**
  25226. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25227. */
  25228. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25229. /**
  25230. * Indicates that lights need to be re-calculated for all submeshes
  25231. */
  25232. protected _markAllSubMeshesAsLightsDirty(): void;
  25233. /**
  25234. * Indicates that attributes need to be re-calculated for all submeshes
  25235. */
  25236. protected _markAllSubMeshesAsAttributesDirty(): void;
  25237. /**
  25238. * Indicates that misc needs to be re-calculated for all submeshes
  25239. */
  25240. protected _markAllSubMeshesAsMiscDirty(): void;
  25241. /**
  25242. * Indicates that textures and misc need to be re-calculated for all submeshes
  25243. */
  25244. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25245. /**
  25246. * Sets the required values to the prepass renderer.
  25247. * @param prePassRenderer defines the prepass renderer to setup.
  25248. * @returns true if the pre pass is needed.
  25249. */
  25250. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25251. /**
  25252. * Disposes the material
  25253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25255. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25256. */
  25257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25258. /** @hidden */
  25259. private releaseVertexArrayObject;
  25260. /**
  25261. * Serializes this material
  25262. * @returns the serialized material object
  25263. */
  25264. serialize(): any;
  25265. /**
  25266. * Creates a material from parsed material data
  25267. * @param parsedMaterial defines parsed material data
  25268. * @param scene defines the hosting scene
  25269. * @param rootUrl defines the root URL to use to load textures
  25270. * @returns a new material
  25271. */
  25272. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25273. }
  25274. }
  25275. declare module BABYLON {
  25276. /**
  25277. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25278. * separate meshes. This can be use to improve performances.
  25279. * @see https://doc.babylonjs.com/how_to/multi_materials
  25280. */
  25281. export class MultiMaterial extends Material {
  25282. private _subMaterials;
  25283. /**
  25284. * Gets or Sets the list of Materials used within the multi material.
  25285. * They need to be ordered according to the submeshes order in the associated mesh
  25286. */
  25287. get subMaterials(): Nullable<Material>[];
  25288. set subMaterials(value: Nullable<Material>[]);
  25289. /**
  25290. * Function used to align with Node.getChildren()
  25291. * @returns the list of Materials used within the multi material
  25292. */
  25293. getChildren(): Nullable<Material>[];
  25294. /**
  25295. * Instantiates a new Multi Material
  25296. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25297. * separate meshes. This can be use to improve performances.
  25298. * @see https://doc.babylonjs.com/how_to/multi_materials
  25299. * @param name Define the name in the scene
  25300. * @param scene Define the scene the material belongs to
  25301. */
  25302. constructor(name: string, scene: Scene);
  25303. private _hookArray;
  25304. /**
  25305. * Get one of the submaterial by its index in the submaterials array
  25306. * @param index The index to look the sub material at
  25307. * @returns The Material if the index has been defined
  25308. */
  25309. getSubMaterial(index: number): Nullable<Material>;
  25310. /**
  25311. * Get the list of active textures for the whole sub materials list.
  25312. * @returns All the textures that will be used during the rendering
  25313. */
  25314. getActiveTextures(): BaseTexture[];
  25315. /**
  25316. * Gets the current class name of the material e.g. "MultiMaterial"
  25317. * Mainly use in serialization.
  25318. * @returns the class name
  25319. */
  25320. getClassName(): string;
  25321. /**
  25322. * Checks if the material is ready to render the requested sub mesh
  25323. * @param mesh Define the mesh the submesh belongs to
  25324. * @param subMesh Define the sub mesh to look readyness for
  25325. * @param useInstances Define whether or not the material is used with instances
  25326. * @returns true if ready, otherwise false
  25327. */
  25328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25329. /**
  25330. * Clones the current material and its related sub materials
  25331. * @param name Define the name of the newly cloned material
  25332. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25333. * @returns the cloned material
  25334. */
  25335. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25336. /**
  25337. * Serializes the materials into a JSON representation.
  25338. * @returns the JSON representation
  25339. */
  25340. serialize(): any;
  25341. /**
  25342. * Dispose the material and release its associated resources
  25343. * @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)
  25344. * @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)
  25345. * @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)
  25346. */
  25347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25348. /**
  25349. * Creates a MultiMaterial from parsed MultiMaterial data.
  25350. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25351. * @param scene defines the hosting scene
  25352. * @returns a new MultiMaterial
  25353. */
  25354. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25355. }
  25356. }
  25357. declare module BABYLON {
  25358. /**
  25359. * Defines a subdivision inside a mesh
  25360. */
  25361. export class SubMesh implements ICullable {
  25362. /** the material index to use */
  25363. materialIndex: number;
  25364. /** vertex index start */
  25365. verticesStart: number;
  25366. /** vertices count */
  25367. verticesCount: number;
  25368. /** index start */
  25369. indexStart: number;
  25370. /** indices count */
  25371. indexCount: number;
  25372. /** @hidden */
  25373. _materialDefines: Nullable<MaterialDefines>;
  25374. /** @hidden */
  25375. _materialEffect: Nullable<Effect>;
  25376. /** @hidden */
  25377. _effectOverride: Nullable<Effect>;
  25378. /**
  25379. * Gets material defines used by the effect associated to the sub mesh
  25380. */
  25381. get materialDefines(): Nullable<MaterialDefines>;
  25382. /**
  25383. * Sets material defines used by the effect associated to the sub mesh
  25384. */
  25385. set materialDefines(defines: Nullable<MaterialDefines>);
  25386. /**
  25387. * Gets associated effect
  25388. */
  25389. get effect(): Nullable<Effect>;
  25390. /**
  25391. * Sets associated effect (effect used to render this submesh)
  25392. * @param effect defines the effect to associate with
  25393. * @param defines defines the set of defines used to compile this effect
  25394. */
  25395. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25396. /** @hidden */
  25397. _linesIndexCount: number;
  25398. private _mesh;
  25399. private _renderingMesh;
  25400. private _boundingInfo;
  25401. private _linesIndexBuffer;
  25402. /** @hidden */
  25403. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25404. /** @hidden */
  25405. _trianglePlanes: Plane[];
  25406. /** @hidden */
  25407. _lastColliderTransformMatrix: Nullable<Matrix>;
  25408. /** @hidden */
  25409. _renderId: number;
  25410. /** @hidden */
  25411. _alphaIndex: number;
  25412. /** @hidden */
  25413. _distanceToCamera: number;
  25414. /** @hidden */
  25415. _id: number;
  25416. private _currentMaterial;
  25417. /**
  25418. * Add a new submesh to a mesh
  25419. * @param materialIndex defines the material index to use
  25420. * @param verticesStart defines vertex index start
  25421. * @param verticesCount defines vertices count
  25422. * @param indexStart defines index start
  25423. * @param indexCount defines indices count
  25424. * @param mesh defines the parent mesh
  25425. * @param renderingMesh defines an optional rendering mesh
  25426. * @param createBoundingBox defines if bounding box should be created for this submesh
  25427. * @returns the new submesh
  25428. */
  25429. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25430. /**
  25431. * Creates a new submesh
  25432. * @param materialIndex defines the material index to use
  25433. * @param verticesStart defines vertex index start
  25434. * @param verticesCount defines vertices count
  25435. * @param indexStart defines index start
  25436. * @param indexCount defines indices count
  25437. * @param mesh defines the parent mesh
  25438. * @param renderingMesh defines an optional rendering mesh
  25439. * @param createBoundingBox defines if bounding box should be created for this submesh
  25440. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25441. */
  25442. constructor(
  25443. /** the material index to use */
  25444. materialIndex: number,
  25445. /** vertex index start */
  25446. verticesStart: number,
  25447. /** vertices count */
  25448. verticesCount: number,
  25449. /** index start */
  25450. indexStart: number,
  25451. /** indices count */
  25452. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25453. /**
  25454. * Returns true if this submesh covers the entire parent mesh
  25455. * @ignorenaming
  25456. */
  25457. get IsGlobal(): boolean;
  25458. /**
  25459. * Returns the submesh BoudingInfo object
  25460. * @returns current bounding info (or mesh's one if the submesh is global)
  25461. */
  25462. getBoundingInfo(): BoundingInfo;
  25463. /**
  25464. * Sets the submesh BoundingInfo
  25465. * @param boundingInfo defines the new bounding info to use
  25466. * @returns the SubMesh
  25467. */
  25468. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25469. /**
  25470. * Returns the mesh of the current submesh
  25471. * @return the parent mesh
  25472. */
  25473. getMesh(): AbstractMesh;
  25474. /**
  25475. * Returns the rendering mesh of the submesh
  25476. * @returns the rendering mesh (could be different from parent mesh)
  25477. */
  25478. getRenderingMesh(): Mesh;
  25479. /**
  25480. * Returns the replacement mesh of the submesh
  25481. * @returns the replacement mesh (could be different from parent mesh)
  25482. */
  25483. getReplacementMesh(): Nullable<AbstractMesh>;
  25484. /**
  25485. * Returns the effective mesh of the submesh
  25486. * @returns the effective mesh (could be different from parent mesh)
  25487. */
  25488. getEffectiveMesh(): AbstractMesh;
  25489. /**
  25490. * Returns the submesh material
  25491. * @returns null or the current material
  25492. */
  25493. getMaterial(): Nullable<Material>;
  25494. private _IsMultiMaterial;
  25495. /**
  25496. * Sets a new updated BoundingInfo object to the submesh
  25497. * @param data defines an optional position array to use to determine the bounding info
  25498. * @returns the SubMesh
  25499. */
  25500. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25501. /** @hidden */
  25502. _checkCollision(collider: Collider): boolean;
  25503. /**
  25504. * Updates the submesh BoundingInfo
  25505. * @param world defines the world matrix to use to update the bounding info
  25506. * @returns the submesh
  25507. */
  25508. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25509. /**
  25510. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25511. * @param frustumPlanes defines the frustum planes
  25512. * @returns true if the submesh is intersecting with the frustum
  25513. */
  25514. isInFrustum(frustumPlanes: Plane[]): boolean;
  25515. /**
  25516. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25517. * @param frustumPlanes defines the frustum planes
  25518. * @returns true if the submesh is inside the frustum
  25519. */
  25520. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25521. /**
  25522. * Renders the submesh
  25523. * @param enableAlphaMode defines if alpha needs to be used
  25524. * @returns the submesh
  25525. */
  25526. render(enableAlphaMode: boolean): SubMesh;
  25527. /**
  25528. * @hidden
  25529. */
  25530. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25531. /**
  25532. * Checks if the submesh intersects with a ray
  25533. * @param ray defines the ray to test
  25534. * @returns true is the passed ray intersects the submesh bounding box
  25535. */
  25536. canIntersects(ray: Ray): boolean;
  25537. /**
  25538. * Intersects current submesh with a ray
  25539. * @param ray defines the ray to test
  25540. * @param positions defines mesh's positions array
  25541. * @param indices defines mesh's indices array
  25542. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25544. * @returns intersection info or null if no intersection
  25545. */
  25546. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25547. /** @hidden */
  25548. private _intersectLines;
  25549. /** @hidden */
  25550. private _intersectUnIndexedLines;
  25551. /** @hidden */
  25552. private _intersectTriangles;
  25553. /** @hidden */
  25554. private _intersectUnIndexedTriangles;
  25555. /** @hidden */
  25556. _rebuild(): void;
  25557. /**
  25558. * Creates a new submesh from the passed mesh
  25559. * @param newMesh defines the new hosting mesh
  25560. * @param newRenderingMesh defines an optional rendering mesh
  25561. * @returns the new submesh
  25562. */
  25563. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25564. /**
  25565. * Release associated resources
  25566. */
  25567. dispose(): void;
  25568. /**
  25569. * Gets the class name
  25570. * @returns the string "SubMesh".
  25571. */
  25572. getClassName(): string;
  25573. /**
  25574. * Creates a new submesh from indices data
  25575. * @param materialIndex the index of the main mesh material
  25576. * @param startIndex the index where to start the copy in the mesh indices array
  25577. * @param indexCount the number of indices to copy then from the startIndex
  25578. * @param mesh the main mesh to create the submesh from
  25579. * @param renderingMesh the optional rendering mesh
  25580. * @returns a new submesh
  25581. */
  25582. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25583. }
  25584. }
  25585. declare module BABYLON {
  25586. /**
  25587. * Class used to represent data loading progression
  25588. */
  25589. export class SceneLoaderFlags {
  25590. private static _ForceFullSceneLoadingForIncremental;
  25591. private static _ShowLoadingScreen;
  25592. private static _CleanBoneMatrixWeights;
  25593. private static _loggingLevel;
  25594. /**
  25595. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25596. */
  25597. static get ForceFullSceneLoadingForIncremental(): boolean;
  25598. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25599. /**
  25600. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25601. */
  25602. static get ShowLoadingScreen(): boolean;
  25603. static set ShowLoadingScreen(value: boolean);
  25604. /**
  25605. * Defines the current logging level (while loading the scene)
  25606. * @ignorenaming
  25607. */
  25608. static get loggingLevel(): number;
  25609. static set loggingLevel(value: number);
  25610. /**
  25611. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25612. */
  25613. static get CleanBoneMatrixWeights(): boolean;
  25614. static set CleanBoneMatrixWeights(value: boolean);
  25615. }
  25616. }
  25617. declare module BABYLON {
  25618. /**
  25619. * Class used to store geometry data (vertex buffers + index buffer)
  25620. */
  25621. export class Geometry implements IGetSetVerticesData {
  25622. /**
  25623. * Gets or sets the ID of the geometry
  25624. */
  25625. id: string;
  25626. /**
  25627. * Gets or sets the unique ID of the geometry
  25628. */
  25629. uniqueId: number;
  25630. /**
  25631. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25632. */
  25633. delayLoadState: number;
  25634. /**
  25635. * Gets the file containing the data to load when running in delay load state
  25636. */
  25637. delayLoadingFile: Nullable<string>;
  25638. /**
  25639. * Callback called when the geometry is updated
  25640. */
  25641. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25642. private _scene;
  25643. private _engine;
  25644. private _meshes;
  25645. private _totalVertices;
  25646. /** @hidden */
  25647. _indices: IndicesArray;
  25648. /** @hidden */
  25649. _vertexBuffers: {
  25650. [key: string]: VertexBuffer;
  25651. };
  25652. private _isDisposed;
  25653. private _extend;
  25654. private _boundingBias;
  25655. /** @hidden */
  25656. _delayInfo: Array<string>;
  25657. private _indexBuffer;
  25658. private _indexBufferIsUpdatable;
  25659. /** @hidden */
  25660. _boundingInfo: Nullable<BoundingInfo>;
  25661. /** @hidden */
  25662. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25663. /** @hidden */
  25664. _softwareSkinningFrameId: number;
  25665. private _vertexArrayObjects;
  25666. private _updatable;
  25667. /** @hidden */
  25668. _positions: Nullable<Vector3[]>;
  25669. /**
  25670. * 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
  25671. */
  25672. get boundingBias(): Vector2;
  25673. /**
  25674. * 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
  25675. */
  25676. set boundingBias(value: Vector2);
  25677. /**
  25678. * Static function used to attach a new empty geometry to a mesh
  25679. * @param mesh defines the mesh to attach the geometry to
  25680. * @returns the new Geometry
  25681. */
  25682. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25683. /** Get the list of meshes using this geometry */
  25684. get meshes(): Mesh[];
  25685. /**
  25686. * 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
  25687. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25688. */
  25689. useBoundingInfoFromGeometry: boolean;
  25690. /**
  25691. * Creates a new geometry
  25692. * @param id defines the unique ID
  25693. * @param scene defines the hosting scene
  25694. * @param vertexData defines the VertexData used to get geometry data
  25695. * @param updatable defines if geometry must be updatable (false by default)
  25696. * @param mesh defines the mesh that will be associated with the geometry
  25697. */
  25698. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25699. /**
  25700. * Gets the current extend of the geometry
  25701. */
  25702. get extend(): {
  25703. minimum: Vector3;
  25704. maximum: Vector3;
  25705. };
  25706. /**
  25707. * Gets the hosting scene
  25708. * @returns the hosting Scene
  25709. */
  25710. getScene(): Scene;
  25711. /**
  25712. * Gets the hosting engine
  25713. * @returns the hosting Engine
  25714. */
  25715. getEngine(): Engine;
  25716. /**
  25717. * Defines if the geometry is ready to use
  25718. * @returns true if the geometry is ready to be used
  25719. */
  25720. isReady(): boolean;
  25721. /**
  25722. * Gets a value indicating that the geometry should not be serialized
  25723. */
  25724. get doNotSerialize(): boolean;
  25725. /** @hidden */
  25726. _rebuild(): void;
  25727. /**
  25728. * Affects all geometry data in one call
  25729. * @param vertexData defines the geometry data
  25730. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25731. */
  25732. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25733. /**
  25734. * Set specific vertex data
  25735. * @param kind defines the data kind (Position, normal, etc...)
  25736. * @param data defines the vertex data to use
  25737. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25738. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25739. */
  25740. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25741. /**
  25742. * Removes a specific vertex data
  25743. * @param kind defines the data kind (Position, normal, etc...)
  25744. */
  25745. removeVerticesData(kind: string): void;
  25746. /**
  25747. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25748. * @param buffer defines the vertex buffer to use
  25749. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25750. */
  25751. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25752. /**
  25753. * Update a specific vertex buffer
  25754. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25755. * It will do nothing if the buffer is not updatable
  25756. * @param kind defines the data kind (Position, normal, etc...)
  25757. * @param data defines the data to use
  25758. * @param offset defines the offset in the target buffer where to store the data
  25759. * @param useBytes set to true if the offset is in bytes
  25760. */
  25761. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25762. /**
  25763. * Update a specific vertex buffer
  25764. * This function will create a new buffer if the current one is not updatable
  25765. * @param kind defines the data kind (Position, normal, etc...)
  25766. * @param data defines the data to use
  25767. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25768. */
  25769. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25770. private _updateBoundingInfo;
  25771. /** @hidden */
  25772. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25773. /**
  25774. * Gets total number of vertices
  25775. * @returns the total number of vertices
  25776. */
  25777. getTotalVertices(): number;
  25778. /**
  25779. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25780. * @param kind defines the data kind (Position, normal, etc...)
  25781. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25782. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25783. * @returns a float array containing vertex data
  25784. */
  25785. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25786. /**
  25787. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25788. * @param kind defines the data kind (Position, normal, etc...)
  25789. * @returns true if the vertex buffer with the specified kind is updatable
  25790. */
  25791. isVertexBufferUpdatable(kind: string): boolean;
  25792. /**
  25793. * Gets a specific vertex buffer
  25794. * @param kind defines the data kind (Position, normal, etc...)
  25795. * @returns a VertexBuffer
  25796. */
  25797. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25798. /**
  25799. * Returns all vertex buffers
  25800. * @return an object holding all vertex buffers indexed by kind
  25801. */
  25802. getVertexBuffers(): Nullable<{
  25803. [key: string]: VertexBuffer;
  25804. }>;
  25805. /**
  25806. * Gets a boolean indicating if specific vertex buffer is present
  25807. * @param kind defines the data kind (Position, normal, etc...)
  25808. * @returns true if data is present
  25809. */
  25810. isVerticesDataPresent(kind: string): boolean;
  25811. /**
  25812. * Gets a list of all attached data kinds (Position, normal, etc...)
  25813. * @returns a list of string containing all kinds
  25814. */
  25815. getVerticesDataKinds(): string[];
  25816. /**
  25817. * Update index buffer
  25818. * @param indices defines the indices to store in the index buffer
  25819. * @param offset defines the offset in the target buffer where to store the data
  25820. * @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)
  25821. */
  25822. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25823. /**
  25824. * Creates a new index buffer
  25825. * @param indices defines the indices to store in the index buffer
  25826. * @param totalVertices defines the total number of vertices (could be null)
  25827. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25828. */
  25829. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25830. /**
  25831. * Return the total number of indices
  25832. * @returns the total number of indices
  25833. */
  25834. getTotalIndices(): number;
  25835. /**
  25836. * Gets the index buffer array
  25837. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25839. * @returns the index buffer array
  25840. */
  25841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25842. /**
  25843. * Gets the index buffer
  25844. * @return the index buffer
  25845. */
  25846. getIndexBuffer(): Nullable<DataBuffer>;
  25847. /** @hidden */
  25848. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25849. /**
  25850. * Release the associated resources for a specific mesh
  25851. * @param mesh defines the source mesh
  25852. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25853. */
  25854. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25855. /**
  25856. * Apply current geometry to a given mesh
  25857. * @param mesh defines the mesh to apply geometry to
  25858. */
  25859. applyToMesh(mesh: Mesh): void;
  25860. private _updateExtend;
  25861. private _applyToMesh;
  25862. private notifyUpdate;
  25863. /**
  25864. * Load the geometry if it was flagged as delay loaded
  25865. * @param scene defines the hosting scene
  25866. * @param onLoaded defines a callback called when the geometry is loaded
  25867. */
  25868. load(scene: Scene, onLoaded?: () => void): void;
  25869. private _queueLoad;
  25870. /**
  25871. * Invert the geometry to move from a right handed system to a left handed one.
  25872. */
  25873. toLeftHanded(): void;
  25874. /** @hidden */
  25875. _resetPointsArrayCache(): void;
  25876. /** @hidden */
  25877. _generatePointsArray(): boolean;
  25878. /**
  25879. * Gets a value indicating if the geometry is disposed
  25880. * @returns true if the geometry was disposed
  25881. */
  25882. isDisposed(): boolean;
  25883. private _disposeVertexArrayObjects;
  25884. /**
  25885. * Free all associated resources
  25886. */
  25887. dispose(): void;
  25888. /**
  25889. * Clone the current geometry into a new geometry
  25890. * @param id defines the unique ID of the new geometry
  25891. * @returns a new geometry object
  25892. */
  25893. copy(id: string): Geometry;
  25894. /**
  25895. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25896. * @return a JSON representation of the current geometry data (without the vertices data)
  25897. */
  25898. serialize(): any;
  25899. private toNumberArray;
  25900. /**
  25901. * Serialize all vertices data into a JSON oject
  25902. * @returns a JSON representation of the current geometry data
  25903. */
  25904. serializeVerticeData(): any;
  25905. /**
  25906. * Extracts a clone of a mesh geometry
  25907. * @param mesh defines the source mesh
  25908. * @param id defines the unique ID of the new geometry object
  25909. * @returns the new geometry object
  25910. */
  25911. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25912. /**
  25913. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25914. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25915. * Be aware Math.random() could cause collisions, but:
  25916. * "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"
  25917. * @returns a string containing a new GUID
  25918. */
  25919. static RandomId(): string;
  25920. /** @hidden */
  25921. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25922. private static _CleanMatricesWeights;
  25923. /**
  25924. * Create a new geometry from persisted data (Using .babylon file format)
  25925. * @param parsedVertexData defines the persisted data
  25926. * @param scene defines the hosting scene
  25927. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25928. * @returns the new geometry object
  25929. */
  25930. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /**
  25935. * Define an interface for all classes that will get and set the data on vertices
  25936. */
  25937. export interface IGetSetVerticesData {
  25938. /**
  25939. * Gets a boolean indicating if specific vertex data is present
  25940. * @param kind defines the vertex data kind to use
  25941. * @returns true is data kind is present
  25942. */
  25943. isVerticesDataPresent(kind: string): boolean;
  25944. /**
  25945. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25946. * @param kind defines the data kind (Position, normal, etc...)
  25947. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25948. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25949. * @returns a float array containing vertex data
  25950. */
  25951. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25952. /**
  25953. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25954. * @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.
  25955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25956. * @returns the indices array or an empty array if the mesh has no geometry
  25957. */
  25958. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25959. /**
  25960. * Set specific vertex data
  25961. * @param kind defines the data kind (Position, normal, etc...)
  25962. * @param data defines the vertex data to use
  25963. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25964. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25965. */
  25966. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25967. /**
  25968. * Update a specific associated vertex buffer
  25969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25970. * - VertexBuffer.PositionKind
  25971. * - VertexBuffer.UVKind
  25972. * - VertexBuffer.UV2Kind
  25973. * - VertexBuffer.UV3Kind
  25974. * - VertexBuffer.UV4Kind
  25975. * - VertexBuffer.UV5Kind
  25976. * - VertexBuffer.UV6Kind
  25977. * - VertexBuffer.ColorKind
  25978. * - VertexBuffer.MatricesIndicesKind
  25979. * - VertexBuffer.MatricesIndicesExtraKind
  25980. * - VertexBuffer.MatricesWeightsKind
  25981. * - VertexBuffer.MatricesWeightsExtraKind
  25982. * @param data defines the data source
  25983. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25984. * @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)
  25985. */
  25986. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25987. /**
  25988. * Creates a new index buffer
  25989. * @param indices defines the indices to store in the index buffer
  25990. * @param totalVertices defines the total number of vertices (could be null)
  25991. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25992. */
  25993. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25994. }
  25995. /**
  25996. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25997. */
  25998. export class VertexData {
  25999. /**
  26000. * Mesh side orientation : usually the external or front surface
  26001. */
  26002. static readonly FRONTSIDE: number;
  26003. /**
  26004. * Mesh side orientation : usually the internal or back surface
  26005. */
  26006. static readonly BACKSIDE: number;
  26007. /**
  26008. * Mesh side orientation : both internal and external or front and back surfaces
  26009. */
  26010. static readonly DOUBLESIDE: number;
  26011. /**
  26012. * Mesh side orientation : by default, `FRONTSIDE`
  26013. */
  26014. static readonly DEFAULTSIDE: number;
  26015. /**
  26016. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26017. */
  26018. positions: Nullable<FloatArray>;
  26019. /**
  26020. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26021. */
  26022. normals: Nullable<FloatArray>;
  26023. /**
  26024. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26025. */
  26026. tangents: Nullable<FloatArray>;
  26027. /**
  26028. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26029. */
  26030. uvs: Nullable<FloatArray>;
  26031. /**
  26032. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26033. */
  26034. uvs2: Nullable<FloatArray>;
  26035. /**
  26036. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26037. */
  26038. uvs3: Nullable<FloatArray>;
  26039. /**
  26040. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26041. */
  26042. uvs4: Nullable<FloatArray>;
  26043. /**
  26044. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26045. */
  26046. uvs5: Nullable<FloatArray>;
  26047. /**
  26048. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26049. */
  26050. uvs6: Nullable<FloatArray>;
  26051. /**
  26052. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26053. */
  26054. colors: Nullable<FloatArray>;
  26055. /**
  26056. * 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).
  26057. */
  26058. matricesIndices: Nullable<FloatArray>;
  26059. /**
  26060. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26061. */
  26062. matricesWeights: Nullable<FloatArray>;
  26063. /**
  26064. * An array extending the number of possible indices
  26065. */
  26066. matricesIndicesExtra: Nullable<FloatArray>;
  26067. /**
  26068. * An array extending the number of possible weights when the number of indices is extended
  26069. */
  26070. matricesWeightsExtra: Nullable<FloatArray>;
  26071. /**
  26072. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26073. */
  26074. indices: Nullable<IndicesArray>;
  26075. /**
  26076. * Uses the passed data array to set the set the values for the specified kind of data
  26077. * @param data a linear array of floating numbers
  26078. * @param kind the type of data that is being set, eg positions, colors etc
  26079. */
  26080. set(data: FloatArray, kind: string): void;
  26081. /**
  26082. * Associates the vertexData to the passed Mesh.
  26083. * Sets it as updatable or not (default `false`)
  26084. * @param mesh the mesh the vertexData is applied to
  26085. * @param updatable when used and having the value true allows new data to update the vertexData
  26086. * @returns the VertexData
  26087. */
  26088. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26089. /**
  26090. * Associates the vertexData to the passed Geometry.
  26091. * Sets it as updatable or not (default `false`)
  26092. * @param geometry the geometry the vertexData is applied to
  26093. * @param updatable when used and having the value true allows new data to update the vertexData
  26094. * @returns VertexData
  26095. */
  26096. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26097. /**
  26098. * Updates the associated mesh
  26099. * @param mesh the mesh to be updated
  26100. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26101. * @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
  26102. * @returns VertexData
  26103. */
  26104. updateMesh(mesh: Mesh): VertexData;
  26105. /**
  26106. * Updates the associated geometry
  26107. * @param geometry the geometry to be updated
  26108. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26109. * @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
  26110. * @returns VertexData.
  26111. */
  26112. updateGeometry(geometry: Geometry): VertexData;
  26113. private _applyTo;
  26114. private _update;
  26115. /**
  26116. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26117. * @param matrix the transforming matrix
  26118. * @returns the VertexData
  26119. */
  26120. transform(matrix: Matrix): VertexData;
  26121. /**
  26122. * Merges the passed VertexData into the current one
  26123. * @param other the VertexData to be merged into the current one
  26124. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26125. * @returns the modified VertexData
  26126. */
  26127. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26128. private _mergeElement;
  26129. private _validate;
  26130. /**
  26131. * Serializes the VertexData
  26132. * @returns a serialized object
  26133. */
  26134. serialize(): any;
  26135. /**
  26136. * Extracts the vertexData from a mesh
  26137. * @param mesh the mesh from which to extract the VertexData
  26138. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26139. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26140. * @returns the object VertexData associated to the passed mesh
  26141. */
  26142. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26143. /**
  26144. * Extracts the vertexData from the geometry
  26145. * @param geometry the geometry from which to extract the VertexData
  26146. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26147. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26148. * @returns the object VertexData associated to the passed mesh
  26149. */
  26150. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26151. private static _ExtractFrom;
  26152. /**
  26153. * Creates the VertexData for a Ribbon
  26154. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26155. * * pathArray array of paths, each of which an array of successive Vector3
  26156. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26157. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26158. * * 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
  26159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26160. * * 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)
  26161. * * 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)
  26162. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26163. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26164. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26165. * @returns the VertexData of the ribbon
  26166. */
  26167. static CreateRibbon(options: {
  26168. pathArray: Vector3[][];
  26169. closeArray?: boolean;
  26170. closePath?: boolean;
  26171. offset?: number;
  26172. sideOrientation?: number;
  26173. frontUVs?: Vector4;
  26174. backUVs?: Vector4;
  26175. invertUV?: boolean;
  26176. uvs?: Vector2[];
  26177. colors?: Color4[];
  26178. }): VertexData;
  26179. /**
  26180. * Creates the VertexData for a box
  26181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26182. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26183. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26184. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26185. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26186. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26187. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26189. * * 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)
  26190. * * 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)
  26191. * @returns the VertexData of the box
  26192. */
  26193. static CreateBox(options: {
  26194. size?: number;
  26195. width?: number;
  26196. height?: number;
  26197. depth?: number;
  26198. faceUV?: Vector4[];
  26199. faceColors?: Color4[];
  26200. sideOrientation?: number;
  26201. frontUVs?: Vector4;
  26202. backUVs?: Vector4;
  26203. }): VertexData;
  26204. /**
  26205. * Creates the VertexData for a tiled box
  26206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26207. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26208. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26209. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26211. * @returns the VertexData of the box
  26212. */
  26213. static CreateTiledBox(options: {
  26214. pattern?: number;
  26215. width?: number;
  26216. height?: number;
  26217. depth?: number;
  26218. tileSize?: number;
  26219. tileWidth?: number;
  26220. tileHeight?: number;
  26221. alignHorizontal?: number;
  26222. alignVertical?: number;
  26223. faceUV?: Vector4[];
  26224. faceColors?: Color4[];
  26225. sideOrientation?: number;
  26226. }): VertexData;
  26227. /**
  26228. * Creates the VertexData for a tiled plane
  26229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26230. * * pattern a limited pattern arrangement depending on the number
  26231. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26232. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26233. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26235. * * 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)
  26236. * * 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)
  26237. * @returns the VertexData of the tiled plane
  26238. */
  26239. static CreateTiledPlane(options: {
  26240. pattern?: number;
  26241. tileSize?: number;
  26242. tileWidth?: number;
  26243. tileHeight?: number;
  26244. size?: number;
  26245. width?: number;
  26246. height?: number;
  26247. alignHorizontal?: number;
  26248. alignVertical?: number;
  26249. sideOrientation?: number;
  26250. frontUVs?: Vector4;
  26251. backUVs?: Vector4;
  26252. }): VertexData;
  26253. /**
  26254. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26255. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26256. * * segments sets the number of horizontal strips optional, default 32
  26257. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26258. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26259. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26260. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26261. * * 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
  26262. * * 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
  26263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26264. * * 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)
  26265. * * 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)
  26266. * @returns the VertexData of the ellipsoid
  26267. */
  26268. static CreateSphere(options: {
  26269. segments?: number;
  26270. diameter?: number;
  26271. diameterX?: number;
  26272. diameterY?: number;
  26273. diameterZ?: number;
  26274. arc?: number;
  26275. slice?: number;
  26276. sideOrientation?: number;
  26277. frontUVs?: Vector4;
  26278. backUVs?: Vector4;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData for a cylinder, cone or prism
  26282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26283. * * height sets the height (y direction) of the cylinder, optional, default 2
  26284. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26285. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26286. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26287. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26288. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26289. * * 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
  26290. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26291. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26292. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26293. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26295. * * 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)
  26296. * * 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)
  26297. * @returns the VertexData of the cylinder, cone or prism
  26298. */
  26299. static CreateCylinder(options: {
  26300. height?: number;
  26301. diameterTop?: number;
  26302. diameterBottom?: number;
  26303. diameter?: number;
  26304. tessellation?: number;
  26305. subdivisions?: number;
  26306. arc?: number;
  26307. faceColors?: Color4[];
  26308. faceUV?: Vector4[];
  26309. hasRings?: boolean;
  26310. enclose?: boolean;
  26311. sideOrientation?: number;
  26312. frontUVs?: Vector4;
  26313. backUVs?: Vector4;
  26314. }): VertexData;
  26315. /**
  26316. * Creates the VertexData for a torus
  26317. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26318. * * diameter the diameter of the torus, optional default 1
  26319. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26320. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * * 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)
  26323. * * 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)
  26324. * @returns the VertexData of the torus
  26325. */
  26326. static CreateTorus(options: {
  26327. diameter?: number;
  26328. thickness?: number;
  26329. tessellation?: number;
  26330. sideOrientation?: number;
  26331. frontUVs?: Vector4;
  26332. backUVs?: Vector4;
  26333. }): VertexData;
  26334. /**
  26335. * Creates the VertexData of the LineSystem
  26336. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26337. * - lines an array of lines, each line being an array of successive Vector3
  26338. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26339. * @returns the VertexData of the LineSystem
  26340. */
  26341. static CreateLineSystem(options: {
  26342. lines: Vector3[][];
  26343. colors?: Nullable<Color4[][]>;
  26344. }): VertexData;
  26345. /**
  26346. * Create the VertexData for a DashedLines
  26347. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26348. * - points an array successive Vector3
  26349. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26350. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26351. * - dashNb the intended total number of dashes, optional, default 200
  26352. * @returns the VertexData for the DashedLines
  26353. */
  26354. static CreateDashedLines(options: {
  26355. points: Vector3[];
  26356. dashSize?: number;
  26357. gapSize?: number;
  26358. dashNb?: number;
  26359. }): VertexData;
  26360. /**
  26361. * Creates the VertexData for a Ground
  26362. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26363. * - width the width (x direction) of the ground, optional, default 1
  26364. * - height the height (z direction) of the ground, optional, default 1
  26365. * - subdivisions the number of subdivisions per side, optional, default 1
  26366. * @returns the VertexData of the Ground
  26367. */
  26368. static CreateGround(options: {
  26369. width?: number;
  26370. height?: number;
  26371. subdivisions?: number;
  26372. subdivisionsX?: number;
  26373. subdivisionsY?: number;
  26374. }): VertexData;
  26375. /**
  26376. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26377. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26378. * * xmin the ground minimum X coordinate, optional, default -1
  26379. * * zmin the ground minimum Z coordinate, optional, default -1
  26380. * * xmax the ground maximum X coordinate, optional, default 1
  26381. * * zmax the ground maximum Z coordinate, optional, default 1
  26382. * * 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}
  26383. * * 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}
  26384. * @returns the VertexData of the TiledGround
  26385. */
  26386. static CreateTiledGround(options: {
  26387. xmin: number;
  26388. zmin: number;
  26389. xmax: number;
  26390. zmax: number;
  26391. subdivisions?: {
  26392. w: number;
  26393. h: number;
  26394. };
  26395. precision?: {
  26396. w: number;
  26397. h: number;
  26398. };
  26399. }): VertexData;
  26400. /**
  26401. * Creates the VertexData of the Ground designed from a heightmap
  26402. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26403. * * width the width (x direction) of the ground
  26404. * * height the height (z direction) of the ground
  26405. * * subdivisions the number of subdivisions per side
  26406. * * minHeight the minimum altitude on the ground, optional, default 0
  26407. * * maxHeight the maximum altitude on the ground, optional default 1
  26408. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26409. * * buffer the array holding the image color data
  26410. * * bufferWidth the width of image
  26411. * * bufferHeight the height of image
  26412. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26413. * @returns the VertexData of the Ground designed from a heightmap
  26414. */
  26415. static CreateGroundFromHeightMap(options: {
  26416. width: number;
  26417. height: number;
  26418. subdivisions: number;
  26419. minHeight: number;
  26420. maxHeight: number;
  26421. colorFilter: Color3;
  26422. buffer: Uint8Array;
  26423. bufferWidth: number;
  26424. bufferHeight: number;
  26425. alphaFilter: number;
  26426. }): VertexData;
  26427. /**
  26428. * Creates the VertexData for a Plane
  26429. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26430. * * size sets the width and height of the plane to the value of size, optional default 1
  26431. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26432. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26434. * * 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)
  26435. * * 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)
  26436. * @returns the VertexData of the box
  26437. */
  26438. static CreatePlane(options: {
  26439. size?: number;
  26440. width?: number;
  26441. height?: number;
  26442. sideOrientation?: number;
  26443. frontUVs?: Vector4;
  26444. backUVs?: Vector4;
  26445. }): VertexData;
  26446. /**
  26447. * Creates the VertexData of the Disc or regular Polygon
  26448. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26449. * * radius the radius of the disc, optional default 0.5
  26450. * * tessellation the number of polygon sides, optional, default 64
  26451. * * 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
  26452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26453. * * 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)
  26454. * * 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)
  26455. * @returns the VertexData of the box
  26456. */
  26457. static CreateDisc(options: {
  26458. radius?: number;
  26459. tessellation?: number;
  26460. arc?: number;
  26461. sideOrientation?: number;
  26462. frontUVs?: Vector4;
  26463. backUVs?: Vector4;
  26464. }): VertexData;
  26465. /**
  26466. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26467. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26468. * @param polygon a mesh built from polygonTriangulation.build()
  26469. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26470. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26471. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26472. * @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)
  26473. * @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)
  26474. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26475. * @returns the VertexData of the Polygon
  26476. */
  26477. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26478. /**
  26479. * Creates the VertexData of the IcoSphere
  26480. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26481. * * radius the radius of the IcoSphere, optional default 1
  26482. * * radiusX allows stretching in the x direction, optional, default radius
  26483. * * radiusY allows stretching in the y direction, optional, default radius
  26484. * * radiusZ allows stretching in the z direction, optional, default radius
  26485. * * flat when true creates a flat shaded mesh, optional, default true
  26486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26488. * * 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)
  26489. * * 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)
  26490. * @returns the VertexData of the IcoSphere
  26491. */
  26492. static CreateIcoSphere(options: {
  26493. radius?: number;
  26494. radiusX?: number;
  26495. radiusY?: number;
  26496. radiusZ?: number;
  26497. flat?: boolean;
  26498. subdivisions?: number;
  26499. sideOrientation?: number;
  26500. frontUVs?: Vector4;
  26501. backUVs?: Vector4;
  26502. }): VertexData;
  26503. /**
  26504. * Creates the VertexData for a Polyhedron
  26505. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26506. * * type provided types are:
  26507. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26508. * * 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)
  26509. * * size the size of the IcoSphere, optional default 1
  26510. * * sizeX allows stretching in the x direction, optional, default size
  26511. * * sizeY allows stretching in the y direction, optional, default size
  26512. * * sizeZ allows stretching in the z direction, optional, default size
  26513. * * 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
  26514. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26515. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26516. * * flat when true creates a flat shaded mesh, optional, default true
  26517. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26519. * * 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)
  26520. * * 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)
  26521. * @returns the VertexData of the Polyhedron
  26522. */
  26523. static CreatePolyhedron(options: {
  26524. type?: number;
  26525. size?: number;
  26526. sizeX?: number;
  26527. sizeY?: number;
  26528. sizeZ?: number;
  26529. custom?: any;
  26530. faceUV?: Vector4[];
  26531. faceColors?: Color4[];
  26532. flat?: boolean;
  26533. sideOrientation?: number;
  26534. frontUVs?: Vector4;
  26535. backUVs?: Vector4;
  26536. }): VertexData;
  26537. /**
  26538. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26539. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26540. * @returns the VertexData of the Capsule
  26541. */
  26542. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26543. /**
  26544. * Creates the VertexData for a TorusKnot
  26545. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26546. * * radius the radius of the torus knot, optional, default 2
  26547. * * tube the thickness of the tube, optional, default 0.5
  26548. * * radialSegments the number of sides on each tube segments, optional, default 32
  26549. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26550. * * p the number of windings around the z axis, optional, default 2
  26551. * * q the number of windings around the x axis, optional, default 3
  26552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26553. * * 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)
  26554. * * 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)
  26555. * @returns the VertexData of the Torus Knot
  26556. */
  26557. static CreateTorusKnot(options: {
  26558. radius?: number;
  26559. tube?: number;
  26560. radialSegments?: number;
  26561. tubularSegments?: number;
  26562. p?: number;
  26563. q?: number;
  26564. sideOrientation?: number;
  26565. frontUVs?: Vector4;
  26566. backUVs?: Vector4;
  26567. }): VertexData;
  26568. /**
  26569. * Compute normals for given positions and indices
  26570. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26571. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26572. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26573. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26574. * * facetNormals : optional array of facet normals (vector3)
  26575. * * facetPositions : optional array of facet positions (vector3)
  26576. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26577. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26578. * * bInfo : optional bounding info, required for facetPartitioning computation
  26579. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26580. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26581. * * useRightHandedSystem: optional boolean to for right handed system computation
  26582. * * depthSort : optional boolean to enable the facet depth sort computation
  26583. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26584. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26585. */
  26586. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26587. facetNormals?: any;
  26588. facetPositions?: any;
  26589. facetPartitioning?: any;
  26590. ratio?: number;
  26591. bInfo?: any;
  26592. bbSize?: Vector3;
  26593. subDiv?: any;
  26594. useRightHandedSystem?: boolean;
  26595. depthSort?: boolean;
  26596. distanceTo?: Vector3;
  26597. depthSortedFacets?: any;
  26598. }): void;
  26599. /** @hidden */
  26600. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26601. /**
  26602. * Applies VertexData created from the imported parameters to the geometry
  26603. * @param parsedVertexData the parsed data from an imported file
  26604. * @param geometry the geometry to apply the VertexData to
  26605. */
  26606. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26607. }
  26608. }
  26609. declare module BABYLON {
  26610. /**
  26611. * Defines a target to use with MorphTargetManager
  26612. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26613. */
  26614. export class MorphTarget implements IAnimatable {
  26615. /** defines the name of the target */
  26616. name: string;
  26617. /**
  26618. * Gets or sets the list of animations
  26619. */
  26620. animations: Animation[];
  26621. private _scene;
  26622. private _positions;
  26623. private _normals;
  26624. private _tangents;
  26625. private _uvs;
  26626. private _influence;
  26627. private _uniqueId;
  26628. /**
  26629. * Observable raised when the influence changes
  26630. */
  26631. onInfluenceChanged: Observable<boolean>;
  26632. /** @hidden */
  26633. _onDataLayoutChanged: Observable<void>;
  26634. /**
  26635. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26636. */
  26637. get influence(): number;
  26638. set influence(influence: number);
  26639. /**
  26640. * Gets or sets the id of the morph Target
  26641. */
  26642. id: string;
  26643. private _animationPropertiesOverride;
  26644. /**
  26645. * Gets or sets the animation properties override
  26646. */
  26647. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26648. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26649. /**
  26650. * Creates a new MorphTarget
  26651. * @param name defines the name of the target
  26652. * @param influence defines the influence to use
  26653. * @param scene defines the scene the morphtarget belongs to
  26654. */
  26655. constructor(
  26656. /** defines the name of the target */
  26657. name: string, influence?: number, scene?: Nullable<Scene>);
  26658. /**
  26659. * Gets the unique ID of this manager
  26660. */
  26661. get uniqueId(): number;
  26662. /**
  26663. * Gets a boolean defining if the target contains position data
  26664. */
  26665. get hasPositions(): boolean;
  26666. /**
  26667. * Gets a boolean defining if the target contains normal data
  26668. */
  26669. get hasNormals(): boolean;
  26670. /**
  26671. * Gets a boolean defining if the target contains tangent data
  26672. */
  26673. get hasTangents(): boolean;
  26674. /**
  26675. * Gets a boolean defining if the target contains texture coordinates data
  26676. */
  26677. get hasUVs(): boolean;
  26678. /**
  26679. * Affects position data to this target
  26680. * @param data defines the position data to use
  26681. */
  26682. setPositions(data: Nullable<FloatArray>): void;
  26683. /**
  26684. * Gets the position data stored in this target
  26685. * @returns a FloatArray containing the position data (or null if not present)
  26686. */
  26687. getPositions(): Nullable<FloatArray>;
  26688. /**
  26689. * Affects normal data to this target
  26690. * @param data defines the normal data to use
  26691. */
  26692. setNormals(data: Nullable<FloatArray>): void;
  26693. /**
  26694. * Gets the normal data stored in this target
  26695. * @returns a FloatArray containing the normal data (or null if not present)
  26696. */
  26697. getNormals(): Nullable<FloatArray>;
  26698. /**
  26699. * Affects tangent data to this target
  26700. * @param data defines the tangent data to use
  26701. */
  26702. setTangents(data: Nullable<FloatArray>): void;
  26703. /**
  26704. * Gets the tangent data stored in this target
  26705. * @returns a FloatArray containing the tangent data (or null if not present)
  26706. */
  26707. getTangents(): Nullable<FloatArray>;
  26708. /**
  26709. * Affects texture coordinates data to this target
  26710. * @param data defines the texture coordinates data to use
  26711. */
  26712. setUVs(data: Nullable<FloatArray>): void;
  26713. /**
  26714. * Gets the texture coordinates data stored in this target
  26715. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26716. */
  26717. getUVs(): Nullable<FloatArray>;
  26718. /**
  26719. * Clone the current target
  26720. * @returns a new MorphTarget
  26721. */
  26722. clone(): MorphTarget;
  26723. /**
  26724. * Serializes the current target into a Serialization object
  26725. * @returns the serialized object
  26726. */
  26727. serialize(): any;
  26728. /**
  26729. * Returns the string "MorphTarget"
  26730. * @returns "MorphTarget"
  26731. */
  26732. getClassName(): string;
  26733. /**
  26734. * Creates a new target from serialized data
  26735. * @param serializationObject defines the serialized data to use
  26736. * @returns a new MorphTarget
  26737. */
  26738. static Parse(serializationObject: any): MorphTarget;
  26739. /**
  26740. * Creates a MorphTarget from mesh data
  26741. * @param mesh defines the source mesh
  26742. * @param name defines the name to use for the new target
  26743. * @param influence defines the influence to attach to the target
  26744. * @returns a new MorphTarget
  26745. */
  26746. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26747. }
  26748. }
  26749. declare module BABYLON {
  26750. /**
  26751. * This class is used to deform meshes using morphing between different targets
  26752. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26753. */
  26754. export class MorphTargetManager {
  26755. private _targets;
  26756. private _targetInfluenceChangedObservers;
  26757. private _targetDataLayoutChangedObservers;
  26758. private _activeTargets;
  26759. private _scene;
  26760. private _influences;
  26761. private _supportsNormals;
  26762. private _supportsTangents;
  26763. private _supportsUVs;
  26764. private _vertexCount;
  26765. private _uniqueId;
  26766. private _tempInfluences;
  26767. /**
  26768. * Gets or sets a boolean indicating if normals must be morphed
  26769. */
  26770. enableNormalMorphing: boolean;
  26771. /**
  26772. * Gets or sets a boolean indicating if tangents must be morphed
  26773. */
  26774. enableTangentMorphing: boolean;
  26775. /**
  26776. * Gets or sets a boolean indicating if UV must be morphed
  26777. */
  26778. enableUVMorphing: boolean;
  26779. /**
  26780. * Creates a new MorphTargetManager
  26781. * @param scene defines the current scene
  26782. */
  26783. constructor(scene?: Nullable<Scene>);
  26784. /**
  26785. * Gets the unique ID of this manager
  26786. */
  26787. get uniqueId(): number;
  26788. /**
  26789. * Gets the number of vertices handled by this manager
  26790. */
  26791. get vertexCount(): number;
  26792. /**
  26793. * Gets a boolean indicating if this manager supports morphing of normals
  26794. */
  26795. get supportsNormals(): boolean;
  26796. /**
  26797. * Gets a boolean indicating if this manager supports morphing of tangents
  26798. */
  26799. get supportsTangents(): boolean;
  26800. /**
  26801. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26802. */
  26803. get supportsUVs(): boolean;
  26804. /**
  26805. * Gets the number of targets stored in this manager
  26806. */
  26807. get numTargets(): number;
  26808. /**
  26809. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26810. */
  26811. get numInfluencers(): number;
  26812. /**
  26813. * Gets the list of influences (one per target)
  26814. */
  26815. get influences(): Float32Array;
  26816. /**
  26817. * Gets the active target at specified index. An active target is a target with an influence > 0
  26818. * @param index defines the index to check
  26819. * @returns the requested target
  26820. */
  26821. getActiveTarget(index: number): MorphTarget;
  26822. /**
  26823. * Gets the target at specified index
  26824. * @param index defines the index to check
  26825. * @returns the requested target
  26826. */
  26827. getTarget(index: number): MorphTarget;
  26828. /**
  26829. * Add a new target to this manager
  26830. * @param target defines the target to add
  26831. */
  26832. addTarget(target: MorphTarget): void;
  26833. /**
  26834. * Removes a target from the manager
  26835. * @param target defines the target to remove
  26836. */
  26837. removeTarget(target: MorphTarget): void;
  26838. /**
  26839. * Clone the current manager
  26840. * @returns a new MorphTargetManager
  26841. */
  26842. clone(): MorphTargetManager;
  26843. /**
  26844. * Serializes the current manager into a Serialization object
  26845. * @returns the serialized object
  26846. */
  26847. serialize(): any;
  26848. private _syncActiveTargets;
  26849. /**
  26850. * Syncrhonize the targets with all the meshes using this morph target manager
  26851. */
  26852. synchronize(): void;
  26853. /**
  26854. * Creates a new MorphTargetManager from serialized data
  26855. * @param serializationObject defines the serialized data
  26856. * @param scene defines the hosting scene
  26857. * @returns the new MorphTargetManager
  26858. */
  26859. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26860. }
  26861. }
  26862. declare module BABYLON {
  26863. /**
  26864. * Class used to represent a specific level of detail of a mesh
  26865. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26866. */
  26867. export class MeshLODLevel {
  26868. /** Defines the distance where this level should start being displayed */
  26869. distance: number;
  26870. /** Defines the mesh to use to render this level */
  26871. mesh: Nullable<Mesh>;
  26872. /**
  26873. * Creates a new LOD level
  26874. * @param distance defines the distance where this level should star being displayed
  26875. * @param mesh defines the mesh to use to render this level
  26876. */
  26877. constructor(
  26878. /** Defines the distance where this level should start being displayed */
  26879. distance: number,
  26880. /** Defines the mesh to use to render this level */
  26881. mesh: Nullable<Mesh>);
  26882. }
  26883. }
  26884. declare module BABYLON {
  26885. /**
  26886. * Helper class used to generate a canvas to manipulate images
  26887. */
  26888. export class CanvasGenerator {
  26889. /**
  26890. * Create a new canvas (or offscreen canvas depending on the context)
  26891. * @param width defines the expected width
  26892. * @param height defines the expected height
  26893. * @return a new canvas or offscreen canvas
  26894. */
  26895. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26896. }
  26897. }
  26898. declare module BABYLON {
  26899. /**
  26900. * Mesh representing the gorund
  26901. */
  26902. export class GroundMesh extends Mesh {
  26903. /** If octree should be generated */
  26904. generateOctree: boolean;
  26905. private _heightQuads;
  26906. /** @hidden */
  26907. _subdivisionsX: number;
  26908. /** @hidden */
  26909. _subdivisionsY: number;
  26910. /** @hidden */
  26911. _width: number;
  26912. /** @hidden */
  26913. _height: number;
  26914. /** @hidden */
  26915. _minX: number;
  26916. /** @hidden */
  26917. _maxX: number;
  26918. /** @hidden */
  26919. _minZ: number;
  26920. /** @hidden */
  26921. _maxZ: number;
  26922. constructor(name: string, scene: Scene);
  26923. /**
  26924. * "GroundMesh"
  26925. * @returns "GroundMesh"
  26926. */
  26927. getClassName(): string;
  26928. /**
  26929. * The minimum of x and y subdivisions
  26930. */
  26931. get subdivisions(): number;
  26932. /**
  26933. * X subdivisions
  26934. */
  26935. get subdivisionsX(): number;
  26936. /**
  26937. * Y subdivisions
  26938. */
  26939. get subdivisionsY(): number;
  26940. /**
  26941. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26942. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26943. * @param chunksCount the number of subdivisions for x and y
  26944. * @param octreeBlocksSize (Default: 32)
  26945. */
  26946. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26947. /**
  26948. * Returns a height (y) value in the Worl system :
  26949. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26950. * @param x x coordinate
  26951. * @param z z coordinate
  26952. * @returns the ground y position if (x, z) are outside the ground surface.
  26953. */
  26954. getHeightAtCoordinates(x: number, z: number): number;
  26955. /**
  26956. * Returns a normalized vector (Vector3) orthogonal to the ground
  26957. * at the ground coordinates (x, z) expressed in the World system.
  26958. * @param x x coordinate
  26959. * @param z z coordinate
  26960. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26961. */
  26962. getNormalAtCoordinates(x: number, z: number): Vector3;
  26963. /**
  26964. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26965. * at the ground coordinates (x, z) expressed in the World system.
  26966. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26967. * @param x x coordinate
  26968. * @param z z coordinate
  26969. * @param ref vector to store the result
  26970. * @returns the GroundMesh.
  26971. */
  26972. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26973. /**
  26974. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26975. * if the ground has been updated.
  26976. * This can be used in the render loop.
  26977. * @returns the GroundMesh.
  26978. */
  26979. updateCoordinateHeights(): GroundMesh;
  26980. private _getFacetAt;
  26981. private _initHeightQuads;
  26982. private _computeHeightQuads;
  26983. /**
  26984. * Serializes this ground mesh
  26985. * @param serializationObject object to write serialization to
  26986. */
  26987. serialize(serializationObject: any): void;
  26988. /**
  26989. * Parses a serialized ground mesh
  26990. * @param parsedMesh the serialized mesh
  26991. * @param scene the scene to create the ground mesh in
  26992. * @returns the created ground mesh
  26993. */
  26994. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26995. }
  26996. }
  26997. declare module BABYLON {
  26998. /**
  26999. * Interface for Physics-Joint data
  27000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27001. */
  27002. export interface PhysicsJointData {
  27003. /**
  27004. * The main pivot of the joint
  27005. */
  27006. mainPivot?: Vector3;
  27007. /**
  27008. * The connected pivot of the joint
  27009. */
  27010. connectedPivot?: Vector3;
  27011. /**
  27012. * The main axis of the joint
  27013. */
  27014. mainAxis?: Vector3;
  27015. /**
  27016. * The connected axis of the joint
  27017. */
  27018. connectedAxis?: Vector3;
  27019. /**
  27020. * The collision of the joint
  27021. */
  27022. collision?: boolean;
  27023. /**
  27024. * Native Oimo/Cannon/Energy data
  27025. */
  27026. nativeParams?: any;
  27027. }
  27028. /**
  27029. * This is a holder class for the physics joint created by the physics plugin
  27030. * It holds a set of functions to control the underlying joint
  27031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27032. */
  27033. export class PhysicsJoint {
  27034. /**
  27035. * The type of the physics joint
  27036. */
  27037. type: number;
  27038. /**
  27039. * The data for the physics joint
  27040. */
  27041. jointData: PhysicsJointData;
  27042. private _physicsJoint;
  27043. protected _physicsPlugin: IPhysicsEnginePlugin;
  27044. /**
  27045. * Initializes the physics joint
  27046. * @param type The type of the physics joint
  27047. * @param jointData The data for the physics joint
  27048. */
  27049. constructor(
  27050. /**
  27051. * The type of the physics joint
  27052. */
  27053. type: number,
  27054. /**
  27055. * The data for the physics joint
  27056. */
  27057. jointData: PhysicsJointData);
  27058. /**
  27059. * Gets the physics joint
  27060. */
  27061. get physicsJoint(): any;
  27062. /**
  27063. * Sets the physics joint
  27064. */
  27065. set physicsJoint(newJoint: any);
  27066. /**
  27067. * Sets the physics plugin
  27068. */
  27069. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27070. /**
  27071. * Execute a function that is physics-plugin specific.
  27072. * @param {Function} func the function that will be executed.
  27073. * It accepts two parameters: the physics world and the physics joint
  27074. */
  27075. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27076. /**
  27077. * Distance-Joint type
  27078. */
  27079. static DistanceJoint: number;
  27080. /**
  27081. * Hinge-Joint type
  27082. */
  27083. static HingeJoint: number;
  27084. /**
  27085. * Ball-and-Socket joint type
  27086. */
  27087. static BallAndSocketJoint: number;
  27088. /**
  27089. * Wheel-Joint type
  27090. */
  27091. static WheelJoint: number;
  27092. /**
  27093. * Slider-Joint type
  27094. */
  27095. static SliderJoint: number;
  27096. /**
  27097. * Prismatic-Joint type
  27098. */
  27099. static PrismaticJoint: number;
  27100. /**
  27101. * Universal-Joint type
  27102. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27103. */
  27104. static UniversalJoint: number;
  27105. /**
  27106. * Hinge-Joint 2 type
  27107. */
  27108. static Hinge2Joint: number;
  27109. /**
  27110. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27111. */
  27112. static PointToPointJoint: number;
  27113. /**
  27114. * Spring-Joint type
  27115. */
  27116. static SpringJoint: number;
  27117. /**
  27118. * Lock-Joint type
  27119. */
  27120. static LockJoint: number;
  27121. }
  27122. /**
  27123. * A class representing a physics distance joint
  27124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27125. */
  27126. export class DistanceJoint extends PhysicsJoint {
  27127. /**
  27128. *
  27129. * @param jointData The data for the Distance-Joint
  27130. */
  27131. constructor(jointData: DistanceJointData);
  27132. /**
  27133. * Update the predefined distance.
  27134. * @param maxDistance The maximum preferred distance
  27135. * @param minDistance The minimum preferred distance
  27136. */
  27137. updateDistance(maxDistance: number, minDistance?: number): void;
  27138. }
  27139. /**
  27140. * Represents a Motor-Enabled Joint
  27141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27142. */
  27143. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27144. /**
  27145. * Initializes the Motor-Enabled Joint
  27146. * @param type The type of the joint
  27147. * @param jointData The physica joint data for the joint
  27148. */
  27149. constructor(type: number, jointData: PhysicsJointData);
  27150. /**
  27151. * Set the motor values.
  27152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27153. * @param force the force to apply
  27154. * @param maxForce max force for this motor.
  27155. */
  27156. setMotor(force?: number, maxForce?: number): void;
  27157. /**
  27158. * Set the motor's limits.
  27159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27160. * @param upperLimit The upper limit of the motor
  27161. * @param lowerLimit The lower limit of the motor
  27162. */
  27163. setLimit(upperLimit: number, lowerLimit?: number): void;
  27164. }
  27165. /**
  27166. * This class represents a single physics Hinge-Joint
  27167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27168. */
  27169. export class HingeJoint extends MotorEnabledJoint {
  27170. /**
  27171. * Initializes the Hinge-Joint
  27172. * @param jointData The joint data for the Hinge-Joint
  27173. */
  27174. constructor(jointData: PhysicsJointData);
  27175. /**
  27176. * Set the motor values.
  27177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27178. * @param {number} force the force to apply
  27179. * @param {number} maxForce max force for this motor.
  27180. */
  27181. setMotor(force?: number, maxForce?: number): void;
  27182. /**
  27183. * Set the motor's limits.
  27184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27185. * @param upperLimit The upper limit of the motor
  27186. * @param lowerLimit The lower limit of the motor
  27187. */
  27188. setLimit(upperLimit: number, lowerLimit?: number): void;
  27189. }
  27190. /**
  27191. * This class represents a dual hinge physics joint (same as wheel joint)
  27192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27193. */
  27194. export class Hinge2Joint extends MotorEnabledJoint {
  27195. /**
  27196. * Initializes the Hinge2-Joint
  27197. * @param jointData The joint data for the Hinge2-Joint
  27198. */
  27199. constructor(jointData: PhysicsJointData);
  27200. /**
  27201. * Set the motor values.
  27202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27203. * @param {number} targetSpeed the speed the motor is to reach
  27204. * @param {number} maxForce max force for this motor.
  27205. * @param {motorIndex} the motor's index, 0 or 1.
  27206. */
  27207. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27208. /**
  27209. * Set the motor limits.
  27210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27211. * @param {number} upperLimit the upper limit
  27212. * @param {number} lowerLimit lower limit
  27213. * @param {motorIndex} the motor's index, 0 or 1.
  27214. */
  27215. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27216. }
  27217. /**
  27218. * Interface for a motor enabled joint
  27219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27220. */
  27221. export interface IMotorEnabledJoint {
  27222. /**
  27223. * Physics joint
  27224. */
  27225. physicsJoint: any;
  27226. /**
  27227. * Sets the motor of the motor-enabled joint
  27228. * @param force The force of the motor
  27229. * @param maxForce The maximum force of the motor
  27230. * @param motorIndex The index of the motor
  27231. */
  27232. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27233. /**
  27234. * Sets the limit of the motor
  27235. * @param upperLimit The upper limit of the motor
  27236. * @param lowerLimit The lower limit of the motor
  27237. * @param motorIndex The index of the motor
  27238. */
  27239. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27240. }
  27241. /**
  27242. * Joint data for a Distance-Joint
  27243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27244. */
  27245. export interface DistanceJointData extends PhysicsJointData {
  27246. /**
  27247. * Max distance the 2 joint objects can be apart
  27248. */
  27249. maxDistance: number;
  27250. }
  27251. /**
  27252. * Joint data from a spring joint
  27253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27254. */
  27255. export interface SpringJointData extends PhysicsJointData {
  27256. /**
  27257. * Length of the spring
  27258. */
  27259. length: number;
  27260. /**
  27261. * Stiffness of the spring
  27262. */
  27263. stiffness: number;
  27264. /**
  27265. * Damping of the spring
  27266. */
  27267. damping: number;
  27268. /** this callback will be called when applying the force to the impostors. */
  27269. forceApplicationCallback: () => void;
  27270. }
  27271. }
  27272. declare module BABYLON {
  27273. /**
  27274. * Holds the data for the raycast result
  27275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27276. */
  27277. export class PhysicsRaycastResult {
  27278. private _hasHit;
  27279. private _hitDistance;
  27280. private _hitNormalWorld;
  27281. private _hitPointWorld;
  27282. private _rayFromWorld;
  27283. private _rayToWorld;
  27284. /**
  27285. * Gets if there was a hit
  27286. */
  27287. get hasHit(): boolean;
  27288. /**
  27289. * Gets the distance from the hit
  27290. */
  27291. get hitDistance(): number;
  27292. /**
  27293. * Gets the hit normal/direction in the world
  27294. */
  27295. get hitNormalWorld(): Vector3;
  27296. /**
  27297. * Gets the hit point in the world
  27298. */
  27299. get hitPointWorld(): Vector3;
  27300. /**
  27301. * Gets the ray "start point" of the ray in the world
  27302. */
  27303. get rayFromWorld(): Vector3;
  27304. /**
  27305. * Gets the ray "end point" of the ray in the world
  27306. */
  27307. get rayToWorld(): Vector3;
  27308. /**
  27309. * Sets the hit data (normal & point in world space)
  27310. * @param hitNormalWorld defines the normal in world space
  27311. * @param hitPointWorld defines the point in world space
  27312. */
  27313. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27314. /**
  27315. * Sets the distance from the start point to the hit point
  27316. * @param distance
  27317. */
  27318. setHitDistance(distance: number): void;
  27319. /**
  27320. * Calculates the distance manually
  27321. */
  27322. calculateHitDistance(): void;
  27323. /**
  27324. * Resets all the values to default
  27325. * @param from The from point on world space
  27326. * @param to The to point on world space
  27327. */
  27328. reset(from?: Vector3, to?: Vector3): void;
  27329. }
  27330. /**
  27331. * Interface for the size containing width and height
  27332. */
  27333. interface IXYZ {
  27334. /**
  27335. * X
  27336. */
  27337. x: number;
  27338. /**
  27339. * Y
  27340. */
  27341. y: number;
  27342. /**
  27343. * Z
  27344. */
  27345. z: number;
  27346. }
  27347. }
  27348. declare module BABYLON {
  27349. /**
  27350. * Interface used to describe a physics joint
  27351. */
  27352. export interface PhysicsImpostorJoint {
  27353. /** Defines the main impostor to which the joint is linked */
  27354. mainImpostor: PhysicsImpostor;
  27355. /** Defines the impostor that is connected to the main impostor using this joint */
  27356. connectedImpostor: PhysicsImpostor;
  27357. /** Defines the joint itself */
  27358. joint: PhysicsJoint;
  27359. }
  27360. /** @hidden */
  27361. export interface IPhysicsEnginePlugin {
  27362. world: any;
  27363. name: string;
  27364. setGravity(gravity: Vector3): void;
  27365. setTimeStep(timeStep: number): void;
  27366. getTimeStep(): number;
  27367. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27368. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27369. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27370. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27371. removePhysicsBody(impostor: PhysicsImpostor): void;
  27372. generateJoint(joint: PhysicsImpostorJoint): void;
  27373. removeJoint(joint: PhysicsImpostorJoint): void;
  27374. isSupported(): boolean;
  27375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27382. getBodyMass(impostor: PhysicsImpostor): number;
  27383. getBodyFriction(impostor: PhysicsImpostor): number;
  27384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27385. getBodyRestitution(impostor: PhysicsImpostor): number;
  27386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27387. getBodyPressure?(impostor: PhysicsImpostor): number;
  27388. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27389. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27390. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27391. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27392. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27393. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27394. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27395. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27396. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27397. sleepBody(impostor: PhysicsImpostor): void;
  27398. wakeUpBody(impostor: PhysicsImpostor): void;
  27399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27401. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27403. getRadius(impostor: PhysicsImpostor): number;
  27404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27406. dispose(): void;
  27407. }
  27408. /**
  27409. * Interface used to define a physics engine
  27410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27411. */
  27412. export interface IPhysicsEngine {
  27413. /**
  27414. * Gets the gravity vector used by the simulation
  27415. */
  27416. gravity: Vector3;
  27417. /**
  27418. * Sets the gravity vector used by the simulation
  27419. * @param gravity defines the gravity vector to use
  27420. */
  27421. setGravity(gravity: Vector3): void;
  27422. /**
  27423. * Set the time step of the physics engine.
  27424. * Default is 1/60.
  27425. * To slow it down, enter 1/600 for example.
  27426. * To speed it up, 1/30
  27427. * @param newTimeStep the new timestep to apply to this world.
  27428. */
  27429. setTimeStep(newTimeStep: number): void;
  27430. /**
  27431. * Get the time step of the physics engine.
  27432. * @returns the current time step
  27433. */
  27434. getTimeStep(): number;
  27435. /**
  27436. * Set the sub time step of the physics engine.
  27437. * Default is 0 meaning there is no sub steps
  27438. * To increase physics resolution precision, set a small value (like 1 ms)
  27439. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27440. */
  27441. setSubTimeStep(subTimeStep: number): void;
  27442. /**
  27443. * Get the sub time step of the physics engine.
  27444. * @returns the current sub time step
  27445. */
  27446. getSubTimeStep(): number;
  27447. /**
  27448. * Release all resources
  27449. */
  27450. dispose(): void;
  27451. /**
  27452. * Gets the name of the current physics plugin
  27453. * @returns the name of the plugin
  27454. */
  27455. getPhysicsPluginName(): string;
  27456. /**
  27457. * Adding a new impostor for the impostor tracking.
  27458. * This will be done by the impostor itself.
  27459. * @param impostor the impostor to add
  27460. */
  27461. addImpostor(impostor: PhysicsImpostor): void;
  27462. /**
  27463. * Remove an impostor from the engine.
  27464. * This impostor and its mesh will not longer be updated by the physics engine.
  27465. * @param impostor the impostor to remove
  27466. */
  27467. removeImpostor(impostor: PhysicsImpostor): void;
  27468. /**
  27469. * Add a joint to the physics engine
  27470. * @param mainImpostor defines the main impostor to which the joint is added.
  27471. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27472. * @param joint defines the joint that will connect both impostors.
  27473. */
  27474. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27475. /**
  27476. * Removes a joint from the simulation
  27477. * @param mainImpostor defines the impostor used with the joint
  27478. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27479. * @param joint defines the joint to remove
  27480. */
  27481. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27482. /**
  27483. * Gets the current plugin used to run the simulation
  27484. * @returns current plugin
  27485. */
  27486. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27487. /**
  27488. * Gets the list of physic impostors
  27489. * @returns an array of PhysicsImpostor
  27490. */
  27491. getImpostors(): Array<PhysicsImpostor>;
  27492. /**
  27493. * Gets the impostor for a physics enabled object
  27494. * @param object defines the object impersonated by the impostor
  27495. * @returns the PhysicsImpostor or null if not found
  27496. */
  27497. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27498. /**
  27499. * Gets the impostor for a physics body object
  27500. * @param body defines physics body used by the impostor
  27501. * @returns the PhysicsImpostor or null if not found
  27502. */
  27503. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27504. /**
  27505. * Does a raycast in the physics world
  27506. * @param from when should the ray start?
  27507. * @param to when should the ray end?
  27508. * @returns PhysicsRaycastResult
  27509. */
  27510. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27511. /**
  27512. * Called by the scene. No need to call it.
  27513. * @param delta defines the timespam between frames
  27514. */
  27515. _step(delta: number): void;
  27516. }
  27517. }
  27518. declare module BABYLON {
  27519. /**
  27520. * The interface for the physics imposter parameters
  27521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27522. */
  27523. export interface PhysicsImpostorParameters {
  27524. /**
  27525. * The mass of the physics imposter
  27526. */
  27527. mass: number;
  27528. /**
  27529. * The friction of the physics imposter
  27530. */
  27531. friction?: number;
  27532. /**
  27533. * The coefficient of restitution of the physics imposter
  27534. */
  27535. restitution?: number;
  27536. /**
  27537. * The native options of the physics imposter
  27538. */
  27539. nativeOptions?: any;
  27540. /**
  27541. * Specifies if the parent should be ignored
  27542. */
  27543. ignoreParent?: boolean;
  27544. /**
  27545. * Specifies if bi-directional transformations should be disabled
  27546. */
  27547. disableBidirectionalTransformation?: boolean;
  27548. /**
  27549. * The pressure inside the physics imposter, soft object only
  27550. */
  27551. pressure?: number;
  27552. /**
  27553. * The stiffness the physics imposter, soft object only
  27554. */
  27555. stiffness?: number;
  27556. /**
  27557. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27558. */
  27559. velocityIterations?: number;
  27560. /**
  27561. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27562. */
  27563. positionIterations?: number;
  27564. /**
  27565. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27566. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27567. * Add to fix multiple points
  27568. */
  27569. fixedPoints?: number;
  27570. /**
  27571. * The collision margin around a soft object
  27572. */
  27573. margin?: number;
  27574. /**
  27575. * The collision margin around a soft object
  27576. */
  27577. damping?: number;
  27578. /**
  27579. * The path for a rope based on an extrusion
  27580. */
  27581. path?: any;
  27582. /**
  27583. * The shape of an extrusion used for a rope based on an extrusion
  27584. */
  27585. shape?: any;
  27586. }
  27587. /**
  27588. * Interface for a physics-enabled object
  27589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27590. */
  27591. export interface IPhysicsEnabledObject {
  27592. /**
  27593. * The position of the physics-enabled object
  27594. */
  27595. position: Vector3;
  27596. /**
  27597. * The rotation of the physics-enabled object
  27598. */
  27599. rotationQuaternion: Nullable<Quaternion>;
  27600. /**
  27601. * The scale of the physics-enabled object
  27602. */
  27603. scaling: Vector3;
  27604. /**
  27605. * The rotation of the physics-enabled object
  27606. */
  27607. rotation?: Vector3;
  27608. /**
  27609. * The parent of the physics-enabled object
  27610. */
  27611. parent?: any;
  27612. /**
  27613. * The bounding info of the physics-enabled object
  27614. * @returns The bounding info of the physics-enabled object
  27615. */
  27616. getBoundingInfo(): BoundingInfo;
  27617. /**
  27618. * Computes the world matrix
  27619. * @param force Specifies if the world matrix should be computed by force
  27620. * @returns A world matrix
  27621. */
  27622. computeWorldMatrix(force: boolean): Matrix;
  27623. /**
  27624. * Gets the world matrix
  27625. * @returns A world matrix
  27626. */
  27627. getWorldMatrix?(): Matrix;
  27628. /**
  27629. * Gets the child meshes
  27630. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27631. * @returns An array of abstract meshes
  27632. */
  27633. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27634. /**
  27635. * Gets the vertex data
  27636. * @param kind The type of vertex data
  27637. * @returns A nullable array of numbers, or a float32 array
  27638. */
  27639. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27640. /**
  27641. * Gets the indices from the mesh
  27642. * @returns A nullable array of index arrays
  27643. */
  27644. getIndices?(): Nullable<IndicesArray>;
  27645. /**
  27646. * Gets the scene from the mesh
  27647. * @returns the indices array or null
  27648. */
  27649. getScene?(): Scene;
  27650. /**
  27651. * Gets the absolute position from the mesh
  27652. * @returns the absolute position
  27653. */
  27654. getAbsolutePosition(): Vector3;
  27655. /**
  27656. * Gets the absolute pivot point from the mesh
  27657. * @returns the absolute pivot point
  27658. */
  27659. getAbsolutePivotPoint(): Vector3;
  27660. /**
  27661. * Rotates the mesh
  27662. * @param axis The axis of rotation
  27663. * @param amount The amount of rotation
  27664. * @param space The space of the rotation
  27665. * @returns The rotation transform node
  27666. */
  27667. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27668. /**
  27669. * Translates the mesh
  27670. * @param axis The axis of translation
  27671. * @param distance The distance of translation
  27672. * @param space The space of the translation
  27673. * @returns The transform node
  27674. */
  27675. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27676. /**
  27677. * Sets the absolute position of the mesh
  27678. * @param absolutePosition The absolute position of the mesh
  27679. * @returns The transform node
  27680. */
  27681. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27682. /**
  27683. * Gets the class name of the mesh
  27684. * @returns The class name
  27685. */
  27686. getClassName(): string;
  27687. }
  27688. /**
  27689. * Represents a physics imposter
  27690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27691. */
  27692. export class PhysicsImpostor {
  27693. /**
  27694. * The physics-enabled object used as the physics imposter
  27695. */
  27696. object: IPhysicsEnabledObject;
  27697. /**
  27698. * The type of the physics imposter
  27699. */
  27700. type: number;
  27701. private _options;
  27702. private _scene?;
  27703. /**
  27704. * The default object size of the imposter
  27705. */
  27706. static DEFAULT_OBJECT_SIZE: Vector3;
  27707. /**
  27708. * The identity quaternion of the imposter
  27709. */
  27710. static IDENTITY_QUATERNION: Quaternion;
  27711. /** @hidden */
  27712. _pluginData: any;
  27713. private _physicsEngine;
  27714. private _physicsBody;
  27715. private _bodyUpdateRequired;
  27716. private _onBeforePhysicsStepCallbacks;
  27717. private _onAfterPhysicsStepCallbacks;
  27718. /** @hidden */
  27719. _onPhysicsCollideCallbacks: Array<{
  27720. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27721. otherImpostors: Array<PhysicsImpostor>;
  27722. }>;
  27723. private _deltaPosition;
  27724. private _deltaRotation;
  27725. private _deltaRotationConjugated;
  27726. /** @hidden */
  27727. _isFromLine: boolean;
  27728. private _parent;
  27729. private _isDisposed;
  27730. private static _tmpVecs;
  27731. private static _tmpQuat;
  27732. /**
  27733. * Specifies if the physics imposter is disposed
  27734. */
  27735. get isDisposed(): boolean;
  27736. /**
  27737. * Gets the mass of the physics imposter
  27738. */
  27739. get mass(): number;
  27740. set mass(value: number);
  27741. /**
  27742. * Gets the coefficient of friction
  27743. */
  27744. get friction(): number;
  27745. /**
  27746. * Sets the coefficient of friction
  27747. */
  27748. set friction(value: number);
  27749. /**
  27750. * Gets the coefficient of restitution
  27751. */
  27752. get restitution(): number;
  27753. /**
  27754. * Sets the coefficient of restitution
  27755. */
  27756. set restitution(value: number);
  27757. /**
  27758. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27759. */
  27760. get pressure(): number;
  27761. /**
  27762. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27763. */
  27764. set pressure(value: number);
  27765. /**
  27766. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27767. */
  27768. get stiffness(): number;
  27769. /**
  27770. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27771. */
  27772. set stiffness(value: number);
  27773. /**
  27774. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27775. */
  27776. get velocityIterations(): number;
  27777. /**
  27778. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27779. */
  27780. set velocityIterations(value: number);
  27781. /**
  27782. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27783. */
  27784. get positionIterations(): number;
  27785. /**
  27786. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27787. */
  27788. set positionIterations(value: number);
  27789. /**
  27790. * The unique id of the physics imposter
  27791. * set by the physics engine when adding this impostor to the array
  27792. */
  27793. uniqueId: number;
  27794. /**
  27795. * @hidden
  27796. */
  27797. soft: boolean;
  27798. /**
  27799. * @hidden
  27800. */
  27801. segments: number;
  27802. private _joints;
  27803. /**
  27804. * Initializes the physics imposter
  27805. * @param object The physics-enabled object used as the physics imposter
  27806. * @param type The type of the physics imposter
  27807. * @param _options The options for the physics imposter
  27808. * @param _scene The Babylon scene
  27809. */
  27810. constructor(
  27811. /**
  27812. * The physics-enabled object used as the physics imposter
  27813. */
  27814. object: IPhysicsEnabledObject,
  27815. /**
  27816. * The type of the physics imposter
  27817. */
  27818. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27819. /**
  27820. * This function will completly initialize this impostor.
  27821. * It will create a new body - but only if this mesh has no parent.
  27822. * If it has, this impostor will not be used other than to define the impostor
  27823. * of the child mesh.
  27824. * @hidden
  27825. */
  27826. _init(): void;
  27827. private _getPhysicsParent;
  27828. /**
  27829. * Should a new body be generated.
  27830. * @returns boolean specifying if body initialization is required
  27831. */
  27832. isBodyInitRequired(): boolean;
  27833. /**
  27834. * Sets the updated scaling
  27835. * @param updated Specifies if the scaling is updated
  27836. */
  27837. setScalingUpdated(): void;
  27838. /**
  27839. * Force a regeneration of this or the parent's impostor's body.
  27840. * Use under cautious - This will remove all joints already implemented.
  27841. */
  27842. forceUpdate(): void;
  27843. /**
  27844. * Gets the body that holds this impostor. Either its own, or its parent.
  27845. */
  27846. get physicsBody(): any;
  27847. /**
  27848. * Get the parent of the physics imposter
  27849. * @returns Physics imposter or null
  27850. */
  27851. get parent(): Nullable<PhysicsImpostor>;
  27852. /**
  27853. * Sets the parent of the physics imposter
  27854. */
  27855. set parent(value: Nullable<PhysicsImpostor>);
  27856. /**
  27857. * Set the physics body. Used mainly by the physics engine/plugin
  27858. */
  27859. set physicsBody(physicsBody: any);
  27860. /**
  27861. * Resets the update flags
  27862. */
  27863. resetUpdateFlags(): void;
  27864. /**
  27865. * Gets the object extend size
  27866. * @returns the object extend size
  27867. */
  27868. getObjectExtendSize(): Vector3;
  27869. /**
  27870. * Gets the object center
  27871. * @returns The object center
  27872. */
  27873. getObjectCenter(): Vector3;
  27874. /**
  27875. * Get a specific parameter from the options parameters
  27876. * @param paramName The object parameter name
  27877. * @returns The object parameter
  27878. */
  27879. getParam(paramName: string): any;
  27880. /**
  27881. * Sets a specific parameter in the options given to the physics plugin
  27882. * @param paramName The parameter name
  27883. * @param value The value of the parameter
  27884. */
  27885. setParam(paramName: string, value: number): void;
  27886. /**
  27887. * Specifically change the body's mass option. Won't recreate the physics body object
  27888. * @param mass The mass of the physics imposter
  27889. */
  27890. setMass(mass: number): void;
  27891. /**
  27892. * Gets the linear velocity
  27893. * @returns linear velocity or null
  27894. */
  27895. getLinearVelocity(): Nullable<Vector3>;
  27896. /**
  27897. * Sets the linear velocity
  27898. * @param velocity linear velocity or null
  27899. */
  27900. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27901. /**
  27902. * Gets the angular velocity
  27903. * @returns angular velocity or null
  27904. */
  27905. getAngularVelocity(): Nullable<Vector3>;
  27906. /**
  27907. * Sets the angular velocity
  27908. * @param velocity The velocity or null
  27909. */
  27910. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27911. /**
  27912. * Execute a function with the physics plugin native code
  27913. * Provide a function the will have two variables - the world object and the physics body object
  27914. * @param func The function to execute with the physics plugin native code
  27915. */
  27916. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27917. /**
  27918. * Register a function that will be executed before the physics world is stepping forward
  27919. * @param func The function to execute before the physics world is stepped forward
  27920. */
  27921. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27922. /**
  27923. * Unregister a function that will be executed before the physics world is stepping forward
  27924. * @param func The function to execute before the physics world is stepped forward
  27925. */
  27926. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27927. /**
  27928. * Register a function that will be executed after the physics step
  27929. * @param func The function to execute after physics step
  27930. */
  27931. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27932. /**
  27933. * Unregisters a function that will be executed after the physics step
  27934. * @param func The function to execute after physics step
  27935. */
  27936. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27937. /**
  27938. * register a function that will be executed when this impostor collides against a different body
  27939. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27940. * @param func Callback that is executed on collision
  27941. */
  27942. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27943. /**
  27944. * Unregisters the physics imposter on contact
  27945. * @param collideAgainst The physics object to collide against
  27946. * @param func Callback to execute on collision
  27947. */
  27948. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27949. private _tmpQuat;
  27950. private _tmpQuat2;
  27951. /**
  27952. * Get the parent rotation
  27953. * @returns The parent rotation
  27954. */
  27955. getParentsRotation(): Quaternion;
  27956. /**
  27957. * this function is executed by the physics engine.
  27958. */
  27959. beforeStep: () => void;
  27960. /**
  27961. * this function is executed by the physics engine
  27962. */
  27963. afterStep: () => void;
  27964. /**
  27965. * Legacy collision detection event support
  27966. */
  27967. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27968. /**
  27969. * event and body object due to cannon's event-based architecture.
  27970. */
  27971. onCollide: (e: {
  27972. body: any;
  27973. }) => void;
  27974. /**
  27975. * Apply a force
  27976. * @param force The force to apply
  27977. * @param contactPoint The contact point for the force
  27978. * @returns The physics imposter
  27979. */
  27980. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27981. /**
  27982. * Apply an impulse
  27983. * @param force The impulse force
  27984. * @param contactPoint The contact point for the impulse force
  27985. * @returns The physics imposter
  27986. */
  27987. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27988. /**
  27989. * A help function to create a joint
  27990. * @param otherImpostor A physics imposter used to create a joint
  27991. * @param jointType The type of joint
  27992. * @param jointData The data for the joint
  27993. * @returns The physics imposter
  27994. */
  27995. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27996. /**
  27997. * Add a joint to this impostor with a different impostor
  27998. * @param otherImpostor A physics imposter used to add a joint
  27999. * @param joint The joint to add
  28000. * @returns The physics imposter
  28001. */
  28002. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28003. /**
  28004. * Add an anchor to a cloth impostor
  28005. * @param otherImpostor rigid impostor to anchor to
  28006. * @param width ratio across width from 0 to 1
  28007. * @param height ratio up height from 0 to 1
  28008. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28009. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28010. * @returns impostor the soft imposter
  28011. */
  28012. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28013. /**
  28014. * Add a hook to a rope impostor
  28015. * @param otherImpostor rigid impostor to anchor to
  28016. * @param length ratio across rope from 0 to 1
  28017. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28018. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28019. * @returns impostor the rope imposter
  28020. */
  28021. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28022. /**
  28023. * Will keep this body still, in a sleep mode.
  28024. * @returns the physics imposter
  28025. */
  28026. sleep(): PhysicsImpostor;
  28027. /**
  28028. * Wake the body up.
  28029. * @returns The physics imposter
  28030. */
  28031. wakeUp(): PhysicsImpostor;
  28032. /**
  28033. * Clones the physics imposter
  28034. * @param newObject The physics imposter clones to this physics-enabled object
  28035. * @returns A nullable physics imposter
  28036. */
  28037. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28038. /**
  28039. * Disposes the physics imposter
  28040. */
  28041. dispose(): void;
  28042. /**
  28043. * Sets the delta position
  28044. * @param position The delta position amount
  28045. */
  28046. setDeltaPosition(position: Vector3): void;
  28047. /**
  28048. * Sets the delta rotation
  28049. * @param rotation The delta rotation amount
  28050. */
  28051. setDeltaRotation(rotation: Quaternion): void;
  28052. /**
  28053. * Gets the box size of the physics imposter and stores the result in the input parameter
  28054. * @param result Stores the box size
  28055. * @returns The physics imposter
  28056. */
  28057. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28058. /**
  28059. * Gets the radius of the physics imposter
  28060. * @returns Radius of the physics imposter
  28061. */
  28062. getRadius(): number;
  28063. /**
  28064. * Sync a bone with this impostor
  28065. * @param bone The bone to sync to the impostor.
  28066. * @param boneMesh The mesh that the bone is influencing.
  28067. * @param jointPivot The pivot of the joint / bone in local space.
  28068. * @param distToJoint Optional distance from the impostor to the joint.
  28069. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28070. */
  28071. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28072. /**
  28073. * Sync impostor to a bone
  28074. * @param bone The bone that the impostor will be synced to.
  28075. * @param boneMesh The mesh that the bone is influencing.
  28076. * @param jointPivot The pivot of the joint / bone in local space.
  28077. * @param distToJoint Optional distance from the impostor to the joint.
  28078. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28079. * @param boneAxis Optional vector3 axis the bone is aligned with
  28080. */
  28081. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28082. /**
  28083. * No-Imposter type
  28084. */
  28085. static NoImpostor: number;
  28086. /**
  28087. * Sphere-Imposter type
  28088. */
  28089. static SphereImpostor: number;
  28090. /**
  28091. * Box-Imposter type
  28092. */
  28093. static BoxImpostor: number;
  28094. /**
  28095. * Plane-Imposter type
  28096. */
  28097. static PlaneImpostor: number;
  28098. /**
  28099. * Mesh-imposter type
  28100. */
  28101. static MeshImpostor: number;
  28102. /**
  28103. * Capsule-Impostor type (Ammo.js plugin only)
  28104. */
  28105. static CapsuleImpostor: number;
  28106. /**
  28107. * Cylinder-Imposter type
  28108. */
  28109. static CylinderImpostor: number;
  28110. /**
  28111. * Particle-Imposter type
  28112. */
  28113. static ParticleImpostor: number;
  28114. /**
  28115. * Heightmap-Imposter type
  28116. */
  28117. static HeightmapImpostor: number;
  28118. /**
  28119. * ConvexHull-Impostor type (Ammo.js plugin only)
  28120. */
  28121. static ConvexHullImpostor: number;
  28122. /**
  28123. * Custom-Imposter type (Ammo.js plugin only)
  28124. */
  28125. static CustomImpostor: number;
  28126. /**
  28127. * Rope-Imposter type
  28128. */
  28129. static RopeImpostor: number;
  28130. /**
  28131. * Cloth-Imposter type
  28132. */
  28133. static ClothImpostor: number;
  28134. /**
  28135. * Softbody-Imposter type
  28136. */
  28137. static SoftbodyImpostor: number;
  28138. }
  28139. }
  28140. declare module BABYLON {
  28141. /**
  28142. * @hidden
  28143. **/
  28144. export class _CreationDataStorage {
  28145. closePath?: boolean;
  28146. closeArray?: boolean;
  28147. idx: number[];
  28148. dashSize: number;
  28149. gapSize: number;
  28150. path3D: Path3D;
  28151. pathArray: Vector3[][];
  28152. arc: number;
  28153. radius: number;
  28154. cap: number;
  28155. tessellation: number;
  28156. }
  28157. /**
  28158. * @hidden
  28159. **/
  28160. class _InstanceDataStorage {
  28161. visibleInstances: any;
  28162. batchCache: _InstancesBatch;
  28163. instancesBufferSize: number;
  28164. instancesBuffer: Nullable<Buffer>;
  28165. instancesData: Float32Array;
  28166. overridenInstanceCount: number;
  28167. isFrozen: boolean;
  28168. previousBatch: Nullable<_InstancesBatch>;
  28169. hardwareInstancedRendering: boolean;
  28170. sideOrientation: number;
  28171. manualUpdate: boolean;
  28172. previousRenderId: number;
  28173. }
  28174. /**
  28175. * @hidden
  28176. **/
  28177. export class _InstancesBatch {
  28178. mustReturn: boolean;
  28179. visibleInstances: Nullable<InstancedMesh[]>[];
  28180. renderSelf: boolean[];
  28181. hardwareInstancedRendering: boolean[];
  28182. }
  28183. /**
  28184. * @hidden
  28185. **/
  28186. class _ThinInstanceDataStorage {
  28187. instancesCount: number;
  28188. matrixBuffer: Nullable<Buffer>;
  28189. matrixBufferSize: number;
  28190. matrixData: Nullable<Float32Array>;
  28191. boundingVectors: Array<Vector3>;
  28192. worldMatrices: Nullable<Matrix[]>;
  28193. }
  28194. /**
  28195. * Class used to represent renderable models
  28196. */
  28197. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28198. /**
  28199. * Mesh side orientation : usually the external or front surface
  28200. */
  28201. static readonly FRONTSIDE: number;
  28202. /**
  28203. * Mesh side orientation : usually the internal or back surface
  28204. */
  28205. static readonly BACKSIDE: number;
  28206. /**
  28207. * Mesh side orientation : both internal and external or front and back surfaces
  28208. */
  28209. static readonly DOUBLESIDE: number;
  28210. /**
  28211. * Mesh side orientation : by default, `FRONTSIDE`
  28212. */
  28213. static readonly DEFAULTSIDE: number;
  28214. /**
  28215. * Mesh cap setting : no cap
  28216. */
  28217. static readonly NO_CAP: number;
  28218. /**
  28219. * Mesh cap setting : one cap at the beginning of the mesh
  28220. */
  28221. static readonly CAP_START: number;
  28222. /**
  28223. * Mesh cap setting : one cap at the end of the mesh
  28224. */
  28225. static readonly CAP_END: number;
  28226. /**
  28227. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28228. */
  28229. static readonly CAP_ALL: number;
  28230. /**
  28231. * Mesh pattern setting : no flip or rotate
  28232. */
  28233. static readonly NO_FLIP: number;
  28234. /**
  28235. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28236. */
  28237. static readonly FLIP_TILE: number;
  28238. /**
  28239. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28240. */
  28241. static readonly ROTATE_TILE: number;
  28242. /**
  28243. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28244. */
  28245. static readonly FLIP_ROW: number;
  28246. /**
  28247. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28248. */
  28249. static readonly ROTATE_ROW: number;
  28250. /**
  28251. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28252. */
  28253. static readonly FLIP_N_ROTATE_TILE: number;
  28254. /**
  28255. * Mesh pattern setting : rotate pattern and rotate
  28256. */
  28257. static readonly FLIP_N_ROTATE_ROW: number;
  28258. /**
  28259. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28260. */
  28261. static readonly CENTER: number;
  28262. /**
  28263. * Mesh tile positioning : part tiles on left
  28264. */
  28265. static readonly LEFT: number;
  28266. /**
  28267. * Mesh tile positioning : part tiles on right
  28268. */
  28269. static readonly RIGHT: number;
  28270. /**
  28271. * Mesh tile positioning : part tiles on top
  28272. */
  28273. static readonly TOP: number;
  28274. /**
  28275. * Mesh tile positioning : part tiles on bottom
  28276. */
  28277. static readonly BOTTOM: number;
  28278. /**
  28279. * Gets the default side orientation.
  28280. * @param orientation the orientation to value to attempt to get
  28281. * @returns the default orientation
  28282. * @hidden
  28283. */
  28284. static _GetDefaultSideOrientation(orientation?: number): number;
  28285. private _internalMeshDataInfo;
  28286. get computeBonesUsingShaders(): boolean;
  28287. set computeBonesUsingShaders(value: boolean);
  28288. /**
  28289. * An event triggered before rendering the mesh
  28290. */
  28291. get onBeforeRenderObservable(): Observable<Mesh>;
  28292. /**
  28293. * An event triggered before binding the mesh
  28294. */
  28295. get onBeforeBindObservable(): Observable<Mesh>;
  28296. /**
  28297. * An event triggered after rendering the mesh
  28298. */
  28299. get onAfterRenderObservable(): Observable<Mesh>;
  28300. /**
  28301. * An event triggered before drawing the mesh
  28302. */
  28303. get onBeforeDrawObservable(): Observable<Mesh>;
  28304. private _onBeforeDrawObserver;
  28305. /**
  28306. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28307. */
  28308. set onBeforeDraw(callback: () => void);
  28309. get hasInstances(): boolean;
  28310. get hasThinInstances(): boolean;
  28311. /**
  28312. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28313. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28314. */
  28315. delayLoadState: number;
  28316. /**
  28317. * Gets the list of instances created from this mesh
  28318. * it is not supposed to be modified manually.
  28319. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28321. */
  28322. instances: InstancedMesh[];
  28323. /**
  28324. * Gets the file containing delay loading data for this mesh
  28325. */
  28326. delayLoadingFile: string;
  28327. /** @hidden */
  28328. _binaryInfo: any;
  28329. /**
  28330. * User defined function used to change how LOD level selection is done
  28331. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28332. */
  28333. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28334. /**
  28335. * Gets or sets the morph target manager
  28336. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28337. */
  28338. get morphTargetManager(): Nullable<MorphTargetManager>;
  28339. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28340. /** @hidden */
  28341. _creationDataStorage: Nullable<_CreationDataStorage>;
  28342. /** @hidden */
  28343. _geometry: Nullable<Geometry>;
  28344. /** @hidden */
  28345. _delayInfo: Array<string>;
  28346. /** @hidden */
  28347. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28348. /** @hidden */
  28349. _instanceDataStorage: _InstanceDataStorage;
  28350. /** @hidden */
  28351. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28352. private _effectiveMaterial;
  28353. /** @hidden */
  28354. _shouldGenerateFlatShading: boolean;
  28355. /** @hidden */
  28356. _originalBuilderSideOrientation: number;
  28357. /**
  28358. * Use this property to change the original side orientation defined at construction time
  28359. */
  28360. overrideMaterialSideOrientation: Nullable<number>;
  28361. /**
  28362. * Gets the source mesh (the one used to clone this one from)
  28363. */
  28364. get source(): Nullable<Mesh>;
  28365. /**
  28366. * Gets the list of clones of this mesh
  28367. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28368. * Note that useClonedMeshMap=true is the default setting
  28369. */
  28370. get cloneMeshMap(): Nullable<{
  28371. [id: string]: Mesh | undefined;
  28372. }>;
  28373. /**
  28374. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28375. */
  28376. get isUnIndexed(): boolean;
  28377. set isUnIndexed(value: boolean);
  28378. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28379. get worldMatrixInstancedBuffer(): Float32Array;
  28380. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28381. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28382. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28383. /**
  28384. * @constructor
  28385. * @param name The value used by scene.getMeshByName() to do a lookup.
  28386. * @param scene The scene to add this mesh to.
  28387. * @param parent The parent of this mesh, if it has one
  28388. * @param source An optional Mesh from which geometry is shared, cloned.
  28389. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28390. * When false, achieved by calling a clone(), also passing False.
  28391. * This will make creation of children, recursive.
  28392. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28393. */
  28394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28395. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28396. doNotInstantiate: boolean;
  28397. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28398. /**
  28399. * Gets the class name
  28400. * @returns the string "Mesh".
  28401. */
  28402. getClassName(): string;
  28403. /** @hidden */
  28404. get _isMesh(): boolean;
  28405. /**
  28406. * Returns a description of this mesh
  28407. * @param fullDetails define if full details about this mesh must be used
  28408. * @returns a descriptive string representing this mesh
  28409. */
  28410. toString(fullDetails?: boolean): string;
  28411. /** @hidden */
  28412. _unBindEffect(): void;
  28413. /**
  28414. * Gets a boolean indicating if this mesh has LOD
  28415. */
  28416. get hasLODLevels(): boolean;
  28417. /**
  28418. * Gets the list of MeshLODLevel associated with the current mesh
  28419. * @returns an array of MeshLODLevel
  28420. */
  28421. getLODLevels(): MeshLODLevel[];
  28422. private _sortLODLevels;
  28423. /**
  28424. * Add a mesh as LOD level triggered at the given distance.
  28425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28426. * @param distance The distance from the center of the object to show this level
  28427. * @param mesh The mesh to be added as LOD level (can be null)
  28428. * @return This mesh (for chaining)
  28429. */
  28430. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28431. /**
  28432. * Returns the LOD level mesh at the passed distance or null if not found.
  28433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28434. * @param distance The distance from the center of the object to show this level
  28435. * @returns a Mesh or `null`
  28436. */
  28437. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28438. /**
  28439. * Remove a mesh from the LOD array
  28440. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28441. * @param mesh defines the mesh to be removed
  28442. * @return This mesh (for chaining)
  28443. */
  28444. removeLODLevel(mesh: Mesh): Mesh;
  28445. /**
  28446. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28448. * @param camera defines the camera to use to compute distance
  28449. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28450. * @return This mesh (for chaining)
  28451. */
  28452. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28453. /**
  28454. * Gets the mesh internal Geometry object
  28455. */
  28456. get geometry(): Nullable<Geometry>;
  28457. /**
  28458. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28459. * @returns the total number of vertices
  28460. */
  28461. getTotalVertices(): number;
  28462. /**
  28463. * Returns the content of an associated vertex buffer
  28464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28465. * - VertexBuffer.PositionKind
  28466. * - VertexBuffer.UVKind
  28467. * - VertexBuffer.UV2Kind
  28468. * - VertexBuffer.UV3Kind
  28469. * - VertexBuffer.UV4Kind
  28470. * - VertexBuffer.UV5Kind
  28471. * - VertexBuffer.UV6Kind
  28472. * - VertexBuffer.ColorKind
  28473. * - VertexBuffer.MatricesIndicesKind
  28474. * - VertexBuffer.MatricesIndicesExtraKind
  28475. * - VertexBuffer.MatricesWeightsKind
  28476. * - VertexBuffer.MatricesWeightsExtraKind
  28477. * @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
  28478. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28479. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28480. */
  28481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28482. /**
  28483. * Returns the mesh VertexBuffer object from the requested `kind`
  28484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28485. * - VertexBuffer.PositionKind
  28486. * - VertexBuffer.NormalKind
  28487. * - VertexBuffer.UVKind
  28488. * - VertexBuffer.UV2Kind
  28489. * - VertexBuffer.UV3Kind
  28490. * - VertexBuffer.UV4Kind
  28491. * - VertexBuffer.UV5Kind
  28492. * - VertexBuffer.UV6Kind
  28493. * - VertexBuffer.ColorKind
  28494. * - VertexBuffer.MatricesIndicesKind
  28495. * - VertexBuffer.MatricesIndicesExtraKind
  28496. * - VertexBuffer.MatricesWeightsKind
  28497. * - VertexBuffer.MatricesWeightsExtraKind
  28498. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28499. */
  28500. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28501. /**
  28502. * Tests if a specific vertex buffer is associated with this mesh
  28503. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28504. * - VertexBuffer.PositionKind
  28505. * - VertexBuffer.NormalKind
  28506. * - VertexBuffer.UVKind
  28507. * - VertexBuffer.UV2Kind
  28508. * - VertexBuffer.UV3Kind
  28509. * - VertexBuffer.UV4Kind
  28510. * - VertexBuffer.UV5Kind
  28511. * - VertexBuffer.UV6Kind
  28512. * - VertexBuffer.ColorKind
  28513. * - VertexBuffer.MatricesIndicesKind
  28514. * - VertexBuffer.MatricesIndicesExtraKind
  28515. * - VertexBuffer.MatricesWeightsKind
  28516. * - VertexBuffer.MatricesWeightsExtraKind
  28517. * @returns a boolean
  28518. */
  28519. isVerticesDataPresent(kind: string): boolean;
  28520. /**
  28521. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28522. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28523. * - VertexBuffer.PositionKind
  28524. * - VertexBuffer.UVKind
  28525. * - VertexBuffer.UV2Kind
  28526. * - VertexBuffer.UV3Kind
  28527. * - VertexBuffer.UV4Kind
  28528. * - VertexBuffer.UV5Kind
  28529. * - VertexBuffer.UV6Kind
  28530. * - VertexBuffer.ColorKind
  28531. * - VertexBuffer.MatricesIndicesKind
  28532. * - VertexBuffer.MatricesIndicesExtraKind
  28533. * - VertexBuffer.MatricesWeightsKind
  28534. * - VertexBuffer.MatricesWeightsExtraKind
  28535. * @returns a boolean
  28536. */
  28537. isVertexBufferUpdatable(kind: string): boolean;
  28538. /**
  28539. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28540. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28541. * - VertexBuffer.PositionKind
  28542. * - VertexBuffer.NormalKind
  28543. * - VertexBuffer.UVKind
  28544. * - VertexBuffer.UV2Kind
  28545. * - VertexBuffer.UV3Kind
  28546. * - VertexBuffer.UV4Kind
  28547. * - VertexBuffer.UV5Kind
  28548. * - VertexBuffer.UV6Kind
  28549. * - VertexBuffer.ColorKind
  28550. * - VertexBuffer.MatricesIndicesKind
  28551. * - VertexBuffer.MatricesIndicesExtraKind
  28552. * - VertexBuffer.MatricesWeightsKind
  28553. * - VertexBuffer.MatricesWeightsExtraKind
  28554. * @returns an array of strings
  28555. */
  28556. getVerticesDataKinds(): string[];
  28557. /**
  28558. * Returns a positive integer : the total number of indices in this mesh geometry.
  28559. * @returns the numner of indices or zero if the mesh has no geometry.
  28560. */
  28561. getTotalIndices(): number;
  28562. /**
  28563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28564. * @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.
  28565. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28566. * @returns the indices array or an empty array if the mesh has no geometry
  28567. */
  28568. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28569. get isBlocked(): boolean;
  28570. /**
  28571. * Determine if the current mesh is ready to be rendered
  28572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28573. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28574. * @returns true if all associated assets are ready (material, textures, shaders)
  28575. */
  28576. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28577. /**
  28578. * 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.
  28579. */
  28580. get areNormalsFrozen(): boolean;
  28581. /**
  28582. * 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.
  28583. * @returns the current mesh
  28584. */
  28585. freezeNormals(): Mesh;
  28586. /**
  28587. * 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
  28588. * @returns the current mesh
  28589. */
  28590. unfreezeNormals(): Mesh;
  28591. /**
  28592. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28593. */
  28594. set overridenInstanceCount(count: number);
  28595. /** @hidden */
  28596. _preActivate(): Mesh;
  28597. /** @hidden */
  28598. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28599. /** @hidden */
  28600. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28601. protected _afterComputeWorldMatrix(): void;
  28602. /** @hidden */
  28603. _postActivate(): void;
  28604. /**
  28605. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28606. * This means the mesh underlying bounding box and sphere are recomputed.
  28607. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28608. * @returns the current mesh
  28609. */
  28610. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28611. /** @hidden */
  28612. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28613. /**
  28614. * This function will subdivide the mesh into multiple submeshes
  28615. * @param count defines the expected number of submeshes
  28616. */
  28617. subdivide(count: number): void;
  28618. /**
  28619. * Copy a FloatArray into a specific associated vertex buffer
  28620. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28621. * - VertexBuffer.PositionKind
  28622. * - VertexBuffer.UVKind
  28623. * - VertexBuffer.UV2Kind
  28624. * - VertexBuffer.UV3Kind
  28625. * - VertexBuffer.UV4Kind
  28626. * - VertexBuffer.UV5Kind
  28627. * - VertexBuffer.UV6Kind
  28628. * - VertexBuffer.ColorKind
  28629. * - VertexBuffer.MatricesIndicesKind
  28630. * - VertexBuffer.MatricesIndicesExtraKind
  28631. * - VertexBuffer.MatricesWeightsKind
  28632. * - VertexBuffer.MatricesWeightsExtraKind
  28633. * @param data defines the data source
  28634. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28635. * @param stride defines the data stride size (can be null)
  28636. * @returns the current mesh
  28637. */
  28638. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28639. /**
  28640. * Delete a vertex buffer associated with this mesh
  28641. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28642. * - VertexBuffer.PositionKind
  28643. * - VertexBuffer.UVKind
  28644. * - VertexBuffer.UV2Kind
  28645. * - VertexBuffer.UV3Kind
  28646. * - VertexBuffer.UV4Kind
  28647. * - VertexBuffer.UV5Kind
  28648. * - VertexBuffer.UV6Kind
  28649. * - VertexBuffer.ColorKind
  28650. * - VertexBuffer.MatricesIndicesKind
  28651. * - VertexBuffer.MatricesIndicesExtraKind
  28652. * - VertexBuffer.MatricesWeightsKind
  28653. * - VertexBuffer.MatricesWeightsExtraKind
  28654. */
  28655. removeVerticesData(kind: string): void;
  28656. /**
  28657. * Flags an associated vertex buffer as updatable
  28658. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28659. * - VertexBuffer.PositionKind
  28660. * - VertexBuffer.UVKind
  28661. * - VertexBuffer.UV2Kind
  28662. * - VertexBuffer.UV3Kind
  28663. * - VertexBuffer.UV4Kind
  28664. * - VertexBuffer.UV5Kind
  28665. * - VertexBuffer.UV6Kind
  28666. * - VertexBuffer.ColorKind
  28667. * - VertexBuffer.MatricesIndicesKind
  28668. * - VertexBuffer.MatricesIndicesExtraKind
  28669. * - VertexBuffer.MatricesWeightsKind
  28670. * - VertexBuffer.MatricesWeightsExtraKind
  28671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28672. */
  28673. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28674. /**
  28675. * Sets the mesh global Vertex Buffer
  28676. * @param buffer defines the buffer to use
  28677. * @returns the current mesh
  28678. */
  28679. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28680. /**
  28681. * Update a specific associated vertex buffer
  28682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28683. * - VertexBuffer.PositionKind
  28684. * - VertexBuffer.UVKind
  28685. * - VertexBuffer.UV2Kind
  28686. * - VertexBuffer.UV3Kind
  28687. * - VertexBuffer.UV4Kind
  28688. * - VertexBuffer.UV5Kind
  28689. * - VertexBuffer.UV6Kind
  28690. * - VertexBuffer.ColorKind
  28691. * - VertexBuffer.MatricesIndicesKind
  28692. * - VertexBuffer.MatricesIndicesExtraKind
  28693. * - VertexBuffer.MatricesWeightsKind
  28694. * - VertexBuffer.MatricesWeightsExtraKind
  28695. * @param data defines the data source
  28696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28697. * @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)
  28698. * @returns the current mesh
  28699. */
  28700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28701. /**
  28702. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28703. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28704. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28705. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28706. * @returns the current mesh
  28707. */
  28708. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28709. /**
  28710. * Creates a un-shared specific occurence of the geometry for the mesh.
  28711. * @returns the current mesh
  28712. */
  28713. makeGeometryUnique(): Mesh;
  28714. /**
  28715. * Set the index buffer of this mesh
  28716. * @param indices defines the source data
  28717. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28718. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28719. * @returns the current mesh
  28720. */
  28721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28722. /**
  28723. * Update the current index buffer
  28724. * @param indices defines the source data
  28725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28726. * @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)
  28727. * @returns the current mesh
  28728. */
  28729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28730. /**
  28731. * Invert the geometry to move from a right handed system to a left handed one.
  28732. * @returns the current mesh
  28733. */
  28734. toLeftHanded(): Mesh;
  28735. /** @hidden */
  28736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28737. /** @hidden */
  28738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28739. /**
  28740. * Registers for this mesh a javascript function called just before the rendering process
  28741. * @param func defines the function to call before rendering this mesh
  28742. * @returns the current mesh
  28743. */
  28744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28745. /**
  28746. * Disposes a previously registered javascript function called before the rendering
  28747. * @param func defines the function to remove
  28748. * @returns the current mesh
  28749. */
  28750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28751. /**
  28752. * Registers for this mesh a javascript function called just after the rendering is complete
  28753. * @param func defines the function to call after rendering this mesh
  28754. * @returns the current mesh
  28755. */
  28756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28757. /**
  28758. * Disposes a previously registered javascript function called after the rendering.
  28759. * @param func defines the function to remove
  28760. * @returns the current mesh
  28761. */
  28762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28763. /** @hidden */
  28764. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28765. /** @hidden */
  28766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28767. /** @hidden */
  28768. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28769. /** @hidden */
  28770. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28771. /** @hidden */
  28772. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28773. /** @hidden */
  28774. _rebuild(): void;
  28775. /** @hidden */
  28776. _freeze(): void;
  28777. /** @hidden */
  28778. _unFreeze(): void;
  28779. /**
  28780. * 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
  28781. * @param subMesh defines the subMesh to render
  28782. * @param enableAlphaMode defines if alpha mode can be changed
  28783. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28784. * @returns the current mesh
  28785. */
  28786. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28787. private _onBeforeDraw;
  28788. /**
  28789. * Renormalize the mesh and patch it up if there are no weights
  28790. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28791. * However in the case of zero weights then we set just a single influence to 1.
  28792. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28793. */
  28794. cleanMatrixWeights(): void;
  28795. private normalizeSkinFourWeights;
  28796. private normalizeSkinWeightsAndExtra;
  28797. /**
  28798. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28799. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28800. * the user know there was an issue with importing the mesh
  28801. * @returns a validation object with skinned, valid and report string
  28802. */
  28803. validateSkinning(): {
  28804. skinned: boolean;
  28805. valid: boolean;
  28806. report: string;
  28807. };
  28808. /** @hidden */
  28809. _checkDelayState(): Mesh;
  28810. private _queueLoad;
  28811. /**
  28812. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28813. * A mesh is in the frustum if its bounding box intersects the frustum
  28814. * @param frustumPlanes defines the frustum to test
  28815. * @returns true if the mesh is in the frustum planes
  28816. */
  28817. isInFrustum(frustumPlanes: Plane[]): boolean;
  28818. /**
  28819. * Sets the mesh material by the material or multiMaterial `id` property
  28820. * @param id is a string identifying the material or the multiMaterial
  28821. * @returns the current mesh
  28822. */
  28823. setMaterialByID(id: string): Mesh;
  28824. /**
  28825. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28826. * @returns an array of IAnimatable
  28827. */
  28828. getAnimatables(): IAnimatable[];
  28829. /**
  28830. * Modifies the mesh geometry according to the passed transformation matrix.
  28831. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28832. * The mesh normals are modified using the same transformation.
  28833. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28834. * @param transform defines the transform matrix to use
  28835. * @see https://doc.babylonjs.com/resources/baking_transformations
  28836. * @returns the current mesh
  28837. */
  28838. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28839. /**
  28840. * Modifies the mesh geometry according to its own current World Matrix.
  28841. * The mesh World Matrix is then reset.
  28842. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28843. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28844. * @see https://doc.babylonjs.com/resources/baking_transformations
  28845. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28846. * @returns the current mesh
  28847. */
  28848. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28849. /** @hidden */
  28850. get _positions(): Nullable<Vector3[]>;
  28851. /** @hidden */
  28852. _resetPointsArrayCache(): Mesh;
  28853. /** @hidden */
  28854. _generatePointsArray(): boolean;
  28855. /**
  28856. * Returns a new Mesh object generated from the current mesh properties.
  28857. * This method must not get confused with createInstance()
  28858. * @param name is a string, the name given to the new mesh
  28859. * @param newParent can be any Node object (default `null`)
  28860. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28861. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28862. * @returns a new mesh
  28863. */
  28864. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28865. /**
  28866. * Releases resources associated with this mesh.
  28867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28869. */
  28870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28871. /** @hidden */
  28872. _disposeInstanceSpecificData(): void;
  28873. /** @hidden */
  28874. _disposeThinInstanceSpecificData(): void;
  28875. /**
  28876. * Modifies the mesh geometry according to a displacement map.
  28877. * 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.
  28878. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28879. * @param url is a string, the URL from the image file is to be downloaded.
  28880. * @param minHeight is the lower limit of the displacement.
  28881. * @param maxHeight is the upper limit of the displacement.
  28882. * @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.
  28883. * @param uvOffset is an optional vector2 used to offset UV.
  28884. * @param uvScale is an optional vector2 used to scale UV.
  28885. * @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.
  28886. * @returns the Mesh.
  28887. */
  28888. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28889. /**
  28890. * Modifies the mesh geometry according to a displacementMap buffer.
  28891. * 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.
  28892. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28893. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28894. * @param heightMapWidth is the width of the buffer image.
  28895. * @param heightMapHeight is the height of the buffer image.
  28896. * @param minHeight is the lower limit of the displacement.
  28897. * @param maxHeight is the upper limit of the displacement.
  28898. * @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.
  28899. * @param uvOffset is an optional vector2 used to offset UV.
  28900. * @param uvScale is an optional vector2 used to scale UV.
  28901. * @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.
  28902. * @returns the Mesh.
  28903. */
  28904. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28905. /**
  28906. * Modify the mesh to get a flat shading rendering.
  28907. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28908. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28909. * @returns current mesh
  28910. */
  28911. convertToFlatShadedMesh(): Mesh;
  28912. /**
  28913. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28914. * In other words, more vertices, no more indices and a single bigger VBO.
  28915. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28916. * @returns current mesh
  28917. */
  28918. convertToUnIndexedMesh(): Mesh;
  28919. /**
  28920. * Inverses facet orientations.
  28921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28922. * @param flipNormals will also inverts the normals
  28923. * @returns current mesh
  28924. */
  28925. flipFaces(flipNormals?: boolean): Mesh;
  28926. /**
  28927. * Increase the number of facets and hence vertices in a mesh
  28928. * Vertex normals are interpolated from existing vertex normals
  28929. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28930. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28931. */
  28932. increaseVertices(numberPerEdge: number): void;
  28933. /**
  28934. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28935. * This will undo any application of covertToFlatShadedMesh
  28936. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28937. */
  28938. forceSharedVertices(): void;
  28939. /** @hidden */
  28940. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28941. /** @hidden */
  28942. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28943. /**
  28944. * Creates a new InstancedMesh object from the mesh model.
  28945. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28946. * @param name defines the name of the new instance
  28947. * @returns a new InstancedMesh
  28948. */
  28949. createInstance(name: string): InstancedMesh;
  28950. /**
  28951. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28952. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28953. * @returns the current mesh
  28954. */
  28955. synchronizeInstances(): Mesh;
  28956. /**
  28957. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28958. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28959. * This should be used together with the simplification to avoid disappearing triangles.
  28960. * @param successCallback an optional success callback to be called after the optimization finished.
  28961. * @returns the current mesh
  28962. */
  28963. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28964. /**
  28965. * Serialize current mesh
  28966. * @param serializationObject defines the object which will receive the serialization data
  28967. */
  28968. serialize(serializationObject: any): void;
  28969. /** @hidden */
  28970. _syncGeometryWithMorphTargetManager(): void;
  28971. /** @hidden */
  28972. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28973. /**
  28974. * Returns a new Mesh object parsed from the source provided.
  28975. * @param parsedMesh is the source
  28976. * @param scene defines the hosting scene
  28977. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28978. * @returns a new Mesh
  28979. */
  28980. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28981. /**
  28982. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28984. * @param name defines the name of the mesh to create
  28985. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28986. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28987. * @param closePath creates a seam between the first and the last points of each path of the path array
  28988. * @param offset is taken in account only if the `pathArray` is containing a single path
  28989. * @param scene defines the hosting scene
  28990. * @param updatable defines if the mesh must be flagged as updatable
  28991. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28992. * @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)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28996. /**
  28997. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28998. * @param name defines the name of the mesh to create
  28999. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29000. * @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
  29001. * @param scene defines the hosting scene
  29002. * @param updatable defines if the mesh must be flagged as updatable
  29003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29004. * @returns a new Mesh
  29005. */
  29006. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29007. /**
  29008. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29009. * @param name defines the name of the mesh to create
  29010. * @param size sets the size (float) of each box side (default 1)
  29011. * @param scene defines the hosting scene
  29012. * @param updatable defines if the mesh must be flagged as updatable
  29013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29014. * @returns a new Mesh
  29015. */
  29016. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29017. /**
  29018. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29019. * @param name defines the name of the mesh to create
  29020. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29021. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29025. * @returns a new Mesh
  29026. */
  29027. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29028. /**
  29029. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29030. * @param name defines the name of the mesh to create
  29031. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29032. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29033. * @param scene defines the hosting scene
  29034. * @returns a new Mesh
  29035. */
  29036. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29037. /**
  29038. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29039. * @param name defines the name of the mesh to create
  29040. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29041. * @param diameterTop set the top cap diameter (floats, default 1)
  29042. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29043. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29044. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29045. * @param scene defines the hosting scene
  29046. * @param updatable defines if the mesh must be flagged as updatable
  29047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29048. * @returns a new Mesh
  29049. */
  29050. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29051. /**
  29052. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29053. * @param name defines the name of the mesh to create
  29054. * @param diameter sets the diameter size (float) of the torus (default 1)
  29055. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29056. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29057. * @param scene defines the hosting scene
  29058. * @param updatable defines if the mesh must be flagged as updatable
  29059. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29060. * @returns a new Mesh
  29061. */
  29062. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29063. /**
  29064. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29065. * @param name defines the name of the mesh to create
  29066. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29067. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29068. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29069. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29070. * @param p the number of windings on X axis (positive integers, default 2)
  29071. * @param q the number of windings on Y axis (positive integers, default 3)
  29072. * @param scene defines the hosting scene
  29073. * @param updatable defines if the mesh must be flagged as updatable
  29074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29075. * @returns a new Mesh
  29076. */
  29077. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29078. /**
  29079. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29080. * @param name defines the name of the mesh to create
  29081. * @param points is an array successive Vector3
  29082. * @param scene defines the hosting scene
  29083. * @param updatable defines if the mesh must be flagged as updatable
  29084. * @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).
  29085. * @returns a new Mesh
  29086. */
  29087. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29088. /**
  29089. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29090. * @param name defines the name of the mesh to create
  29091. * @param points is an array successive Vector3
  29092. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29093. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29094. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29095. * @param scene defines the hosting scene
  29096. * @param updatable defines if the mesh must be flagged as updatable
  29097. * @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)
  29098. * @returns a new Mesh
  29099. */
  29100. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29101. /**
  29102. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29103. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29104. * 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.
  29105. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29106. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29107. * Remember you can only change the shape positions, not their number when updating a polygon.
  29108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29109. * @param name defines the name of the mesh to create
  29110. * @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
  29111. * @param scene defines the hosting scene
  29112. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29113. * @param updatable defines if the mesh must be flagged as updatable
  29114. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29115. * @param earcutInjection can be used to inject your own earcut reference
  29116. * @returns a new Mesh
  29117. */
  29118. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29119. /**
  29120. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29122. * @param name defines the name of the mesh to create
  29123. * @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
  29124. * @param depth defines the height of extrusion
  29125. * @param scene defines the hosting scene
  29126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29127. * @param updatable defines if the mesh must be flagged as updatable
  29128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29129. * @param earcutInjection can be used to inject your own earcut reference
  29130. * @returns a new Mesh
  29131. */
  29132. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29133. /**
  29134. * Creates an extruded shape mesh.
  29135. * 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
  29136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29138. * @param name defines the name of the mesh to create
  29139. * @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
  29140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29141. * @param scale is the value to scale the shape
  29142. * @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
  29143. * @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
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29147. * @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)
  29148. * @returns a new Mesh
  29149. */
  29150. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29151. /**
  29152. * Creates an custom extruded shape mesh.
  29153. * The custom extrusion is a parametric shape.
  29154. * It has no predefined shape. Its final shape will depend on the input parameters.
  29155. * Please consider using the same method from the MeshBuilder class instead
  29156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29157. * @param name defines the name of the mesh to create
  29158. * @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
  29159. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29160. * @param scaleFunction is a custom Javascript function called on each path point
  29161. * @param rotationFunction is a custom Javascript function called on each path point
  29162. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29163. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29164. * @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
  29165. * @param scene defines the hosting scene
  29166. * @param updatable defines if the mesh must be flagged as updatable
  29167. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29168. * @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)
  29169. * @returns a new Mesh
  29170. */
  29171. 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;
  29172. /**
  29173. * Creates lathe mesh.
  29174. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29175. * Please consider using the same method from the MeshBuilder class instead
  29176. * @param name defines the name of the mesh to create
  29177. * @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
  29178. * @param radius is the radius value of the lathe
  29179. * @param tessellation is the side number of the lathe.
  29180. * @param scene defines the hosting scene
  29181. * @param updatable defines if the mesh must be flagged as updatable
  29182. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29183. * @returns a new Mesh
  29184. */
  29185. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29186. /**
  29187. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29188. * @param name defines the name of the mesh to create
  29189. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29190. * @param scene defines the hosting scene
  29191. * @param updatable defines if the mesh must be flagged as updatable
  29192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29193. * @returns a new Mesh
  29194. */
  29195. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29196. /**
  29197. * Creates a ground mesh.
  29198. * Please consider using the same method from the MeshBuilder class instead
  29199. * @param name defines the name of the mesh to create
  29200. * @param width set the width of the ground
  29201. * @param height set the height of the ground
  29202. * @param subdivisions sets the number of subdivisions per side
  29203. * @param scene defines the hosting scene
  29204. * @param updatable defines if the mesh must be flagged as updatable
  29205. * @returns a new Mesh
  29206. */
  29207. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29208. /**
  29209. * Creates a tiled ground mesh.
  29210. * Please consider using the same method from the MeshBuilder class instead
  29211. * @param name defines the name of the mesh to create
  29212. * @param xmin set the ground minimum X coordinate
  29213. * @param zmin set the ground minimum Y coordinate
  29214. * @param xmax set the ground maximum X coordinate
  29215. * @param zmax set the ground maximum Z coordinate
  29216. * @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
  29217. * @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
  29218. * @param scene defines the hosting scene
  29219. * @param updatable defines if the mesh must be flagged as updatable
  29220. * @returns a new Mesh
  29221. */
  29222. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29223. w: number;
  29224. h: number;
  29225. }, precision: {
  29226. w: number;
  29227. h: number;
  29228. }, scene: Scene, updatable?: boolean): Mesh;
  29229. /**
  29230. * Creates a ground mesh from a height map.
  29231. * Please consider using the same method from the MeshBuilder class instead
  29232. * @see https://doc.babylonjs.com/babylon101/height_map
  29233. * @param name defines the name of the mesh to create
  29234. * @param url sets the URL of the height map image resource
  29235. * @param width set the ground width size
  29236. * @param height set the ground height size
  29237. * @param subdivisions sets the number of subdivision per side
  29238. * @param minHeight is the minimum altitude on the ground
  29239. * @param maxHeight is the maximum altitude on the ground
  29240. * @param scene defines the hosting scene
  29241. * @param updatable defines if the mesh must be flagged as updatable
  29242. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29243. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29244. * @returns a new Mesh
  29245. */
  29246. 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;
  29247. /**
  29248. * Creates a tube mesh.
  29249. * The tube is a parametric shape.
  29250. * It has no predefined shape. Its final shape will depend on the input parameters.
  29251. * Please consider using the same method from the MeshBuilder class instead
  29252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29253. * @param name defines the name of the mesh to create
  29254. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29255. * @param radius sets the tube radius size
  29256. * @param tessellation is the number of sides on the tubular surface
  29257. * @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
  29258. * @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
  29259. * @param scene defines the hosting scene
  29260. * @param updatable defines if the mesh must be flagged as updatable
  29261. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29262. * @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)
  29263. * @returns a new Mesh
  29264. */
  29265. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29266. (i: number, distance: number): number;
  29267. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29268. /**
  29269. * Creates a polyhedron mesh.
  29270. * Please consider using the same method from the MeshBuilder class instead.
  29271. * * 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
  29272. * * The parameter `size` (positive float, default 1) sets the polygon size
  29273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29274. * * 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`
  29275. * * 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
  29276. * * 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)`)
  29277. * * 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
  29278. * * 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
  29279. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29280. * * 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
  29281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29282. * @param name defines the name of the mesh to create
  29283. * @param options defines the options used to create the mesh
  29284. * @param scene defines the hosting scene
  29285. * @returns a new Mesh
  29286. */
  29287. static CreatePolyhedron(name: string, options: {
  29288. type?: number;
  29289. size?: number;
  29290. sizeX?: number;
  29291. sizeY?: number;
  29292. sizeZ?: number;
  29293. custom?: any;
  29294. faceUV?: Vector4[];
  29295. faceColors?: Color4[];
  29296. updatable?: boolean;
  29297. sideOrientation?: number;
  29298. }, scene: Scene): Mesh;
  29299. /**
  29300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29302. * * 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`)
  29303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29304. * * 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
  29305. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29306. * * 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
  29307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29308. * @param name defines the name of the mesh
  29309. * @param options defines the options used to create the mesh
  29310. * @param scene defines the hosting scene
  29311. * @returns a new Mesh
  29312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29313. */
  29314. static CreateIcoSphere(name: string, options: {
  29315. radius?: number;
  29316. flat?: boolean;
  29317. subdivisions?: number;
  29318. sideOrientation?: number;
  29319. updatable?: boolean;
  29320. }, scene: Scene): Mesh;
  29321. /**
  29322. * Creates a decal mesh.
  29323. * Please consider using the same method from the MeshBuilder class instead.
  29324. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29325. * @param name defines the name of the mesh
  29326. * @param sourceMesh defines the mesh receiving the decal
  29327. * @param position sets the position of the decal in world coordinates
  29328. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29329. * @param size sets the decal scaling
  29330. * @param angle sets the angle to rotate the decal
  29331. * @returns a new Mesh
  29332. */
  29333. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29334. /** Creates a Capsule Mesh
  29335. * @param name defines the name of the mesh.
  29336. * @param options the constructors options used to shape the mesh.
  29337. * @param scene defines the scene the mesh is scoped to.
  29338. * @returns the capsule mesh
  29339. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29340. */
  29341. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29342. /**
  29343. * Prepare internal position array for software CPU skinning
  29344. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29345. */
  29346. setPositionsForCPUSkinning(): Float32Array;
  29347. /**
  29348. * Prepare internal normal array for software CPU skinning
  29349. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29350. */
  29351. setNormalsForCPUSkinning(): Float32Array;
  29352. /**
  29353. * Updates the vertex buffer by applying transformation from the bones
  29354. * @param skeleton defines the skeleton to apply to current mesh
  29355. * @returns the current mesh
  29356. */
  29357. applySkeleton(skeleton: Skeleton): Mesh;
  29358. /**
  29359. * 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
  29360. * @param meshes defines the list of meshes to scan
  29361. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29362. */
  29363. static MinMax(meshes: AbstractMesh[]): {
  29364. min: Vector3;
  29365. max: Vector3;
  29366. };
  29367. /**
  29368. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29369. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29370. * @returns a vector3
  29371. */
  29372. static Center(meshesOrMinMaxVector: {
  29373. min: Vector3;
  29374. max: Vector3;
  29375. } | AbstractMesh[]): Vector3;
  29376. /**
  29377. * Merge the array of meshes into a single mesh for performance reasons.
  29378. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29379. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29380. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29381. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29382. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29383. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29384. * @returns a new mesh
  29385. */
  29386. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29387. /** @hidden */
  29388. addInstance(instance: InstancedMesh): void;
  29389. /** @hidden */
  29390. removeInstance(instance: InstancedMesh): void;
  29391. }
  29392. }
  29393. declare module BABYLON {
  29394. /**
  29395. * This is the base class of all the camera used in the application.
  29396. * @see https://doc.babylonjs.com/features/cameras
  29397. */
  29398. export class Camera extends Node {
  29399. /** @hidden */
  29400. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29401. /**
  29402. * This is the default projection mode used by the cameras.
  29403. * It helps recreating a feeling of perspective and better appreciate depth.
  29404. * This is the best way to simulate real life cameras.
  29405. */
  29406. static readonly PERSPECTIVE_CAMERA: number;
  29407. /**
  29408. * This helps creating camera with an orthographic mode.
  29409. * 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.
  29410. */
  29411. static readonly ORTHOGRAPHIC_CAMERA: number;
  29412. /**
  29413. * This is the default FOV mode for perspective cameras.
  29414. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29415. */
  29416. static readonly FOVMODE_VERTICAL_FIXED: number;
  29417. /**
  29418. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29419. */
  29420. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29421. /**
  29422. * This specifies ther is no need for a camera rig.
  29423. * Basically only one eye is rendered corresponding to the camera.
  29424. */
  29425. static readonly RIG_MODE_NONE: number;
  29426. /**
  29427. * Simulates a camera Rig with one blue eye and one red eye.
  29428. * This can be use with 3d blue and red glasses.
  29429. */
  29430. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29431. /**
  29432. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29439. /**
  29440. * Defines that both eyes of the camera will be rendered over under each other.
  29441. */
  29442. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29443. /**
  29444. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29445. */
  29446. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29447. /**
  29448. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29449. */
  29450. static readonly RIG_MODE_VR: number;
  29451. /**
  29452. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29453. */
  29454. static readonly RIG_MODE_WEBVR: number;
  29455. /**
  29456. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29457. */
  29458. static readonly RIG_MODE_CUSTOM: number;
  29459. /**
  29460. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29461. */
  29462. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29463. /**
  29464. * Define the input manager associated with the camera.
  29465. */
  29466. inputs: CameraInputsManager<Camera>;
  29467. /** @hidden */
  29468. _position: Vector3;
  29469. /**
  29470. * Define the current local position of the camera in the scene
  29471. */
  29472. get position(): Vector3;
  29473. set position(newPosition: Vector3);
  29474. protected _upVector: Vector3;
  29475. /**
  29476. * The vector the camera should consider as up.
  29477. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29478. */
  29479. set upVector(vec: Vector3);
  29480. get upVector(): Vector3;
  29481. /**
  29482. * Define the current limit on the left side for an orthographic camera
  29483. * In scene unit
  29484. */
  29485. orthoLeft: Nullable<number>;
  29486. /**
  29487. * Define the current limit on the right side for an orthographic camera
  29488. * In scene unit
  29489. */
  29490. orthoRight: Nullable<number>;
  29491. /**
  29492. * Define the current limit on the bottom side for an orthographic camera
  29493. * In scene unit
  29494. */
  29495. orthoBottom: Nullable<number>;
  29496. /**
  29497. * Define the current limit on the top side for an orthographic camera
  29498. * In scene unit
  29499. */
  29500. orthoTop: Nullable<number>;
  29501. /**
  29502. * Field Of View is set in Radians. (default is 0.8)
  29503. */
  29504. fov: number;
  29505. /**
  29506. * Define the minimum distance the camera can see from.
  29507. * This is important to note that the depth buffer are not infinite and the closer it starts
  29508. * the more your scene might encounter depth fighting issue.
  29509. */
  29510. minZ: number;
  29511. /**
  29512. * Define the maximum distance the camera can see to.
  29513. * This is important to note that the depth buffer are not infinite and the further it end
  29514. * the more your scene might encounter depth fighting issue.
  29515. */
  29516. maxZ: number;
  29517. /**
  29518. * Define the default inertia of the camera.
  29519. * This helps giving a smooth feeling to the camera movement.
  29520. */
  29521. inertia: number;
  29522. /**
  29523. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29524. */
  29525. mode: number;
  29526. /**
  29527. * Define whether the camera is intermediate.
  29528. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29529. */
  29530. isIntermediate: boolean;
  29531. /**
  29532. * Define the viewport of the camera.
  29533. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29534. */
  29535. viewport: Viewport;
  29536. /**
  29537. * Restricts the camera to viewing objects with the same layerMask.
  29538. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29539. */
  29540. layerMask: number;
  29541. /**
  29542. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29543. */
  29544. fovMode: number;
  29545. /**
  29546. * Rig mode of the camera.
  29547. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29548. * This is normally controlled byt the camera themselves as internal use.
  29549. */
  29550. cameraRigMode: number;
  29551. /**
  29552. * Defines the distance between both "eyes" in case of a RIG
  29553. */
  29554. interaxialDistance: number;
  29555. /**
  29556. * Defines if stereoscopic rendering is done side by side or over under.
  29557. */
  29558. isStereoscopicSideBySide: boolean;
  29559. /**
  29560. * 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
  29561. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29562. * else in the scene. (Eg. security camera)
  29563. *
  29564. * 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)
  29565. */
  29566. customRenderTargets: RenderTargetTexture[];
  29567. /**
  29568. * When set, the camera will render to this render target instead of the default canvas
  29569. *
  29570. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29571. */
  29572. outputRenderTarget: Nullable<RenderTargetTexture>;
  29573. /**
  29574. * Observable triggered when the camera view matrix has changed.
  29575. */
  29576. onViewMatrixChangedObservable: Observable<Camera>;
  29577. /**
  29578. * Observable triggered when the camera Projection matrix has changed.
  29579. */
  29580. onProjectionMatrixChangedObservable: Observable<Camera>;
  29581. /**
  29582. * Observable triggered when the inputs have been processed.
  29583. */
  29584. onAfterCheckInputsObservable: Observable<Camera>;
  29585. /**
  29586. * Observable triggered when reset has been called and applied to the camera.
  29587. */
  29588. onRestoreStateObservable: Observable<Camera>;
  29589. /**
  29590. * Is this camera a part of a rig system?
  29591. */
  29592. isRigCamera: boolean;
  29593. /**
  29594. * If isRigCamera set to true this will be set with the parent camera.
  29595. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29596. */
  29597. rigParent?: Camera;
  29598. /** @hidden */
  29599. _cameraRigParams: any;
  29600. /** @hidden */
  29601. _rigCameras: Camera[];
  29602. /** @hidden */
  29603. _rigPostProcess: Nullable<PostProcess>;
  29604. protected _webvrViewMatrix: Matrix;
  29605. /** @hidden */
  29606. _skipRendering: boolean;
  29607. /** @hidden */
  29608. _projectionMatrix: Matrix;
  29609. /** @hidden */
  29610. _postProcesses: Nullable<PostProcess>[];
  29611. /** @hidden */
  29612. _activeMeshes: SmartArray<AbstractMesh>;
  29613. protected _globalPosition: Vector3;
  29614. /** @hidden */
  29615. _computedViewMatrix: Matrix;
  29616. private _doNotComputeProjectionMatrix;
  29617. private _transformMatrix;
  29618. private _frustumPlanes;
  29619. private _refreshFrustumPlanes;
  29620. private _storedFov;
  29621. private _stateStored;
  29622. /**
  29623. * Instantiates a new camera object.
  29624. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29625. * @see https://doc.babylonjs.com/features/cameras
  29626. * @param name Defines the name of the camera in the scene
  29627. * @param position Defines the position of the camera
  29628. * @param scene Defines the scene the camera belongs too
  29629. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29630. */
  29631. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29632. /**
  29633. * Store current camera state (fov, position, etc..)
  29634. * @returns the camera
  29635. */
  29636. storeState(): Camera;
  29637. /**
  29638. * Restores the camera state values if it has been stored. You must call storeState() first
  29639. */
  29640. protected _restoreStateValues(): boolean;
  29641. /**
  29642. * Restored camera state. You must call storeState() first.
  29643. * @returns true if restored and false otherwise
  29644. */
  29645. restoreState(): boolean;
  29646. /**
  29647. * Gets the class name of the camera.
  29648. * @returns the class name
  29649. */
  29650. getClassName(): string;
  29651. /** @hidden */
  29652. readonly _isCamera: boolean;
  29653. /**
  29654. * Gets a string representation of the camera useful for debug purpose.
  29655. * @param fullDetails Defines that a more verboe level of logging is required
  29656. * @returns the string representation
  29657. */
  29658. toString(fullDetails?: boolean): string;
  29659. /**
  29660. * Gets the current world space position of the camera.
  29661. */
  29662. get globalPosition(): Vector3;
  29663. /**
  29664. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29665. * @returns the active meshe list
  29666. */
  29667. getActiveMeshes(): SmartArray<AbstractMesh>;
  29668. /**
  29669. * Check whether a mesh is part of the current active mesh list of the camera
  29670. * @param mesh Defines the mesh to check
  29671. * @returns true if active, false otherwise
  29672. */
  29673. isActiveMesh(mesh: Mesh): boolean;
  29674. /**
  29675. * Is this camera ready to be used/rendered
  29676. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29677. * @return true if the camera is ready
  29678. */
  29679. isReady(completeCheck?: boolean): boolean;
  29680. /** @hidden */
  29681. _initCache(): void;
  29682. /** @hidden */
  29683. _updateCache(ignoreParentClass?: boolean): void;
  29684. /** @hidden */
  29685. _isSynchronized(): boolean;
  29686. /** @hidden */
  29687. _isSynchronizedViewMatrix(): boolean;
  29688. /** @hidden */
  29689. _isSynchronizedProjectionMatrix(): boolean;
  29690. /**
  29691. * Attach the input controls to a specific dom element to get the input from.
  29692. * @param element Defines the element the controls should be listened from
  29693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29694. */
  29695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29696. /**
  29697. * Detach the current controls from the specified dom element.
  29698. * @param element Defines the element to stop listening the inputs from
  29699. */
  29700. detachControl(element: HTMLElement): void;
  29701. /**
  29702. * Update the camera state according to the different inputs gathered during the frame.
  29703. */
  29704. update(): void;
  29705. /** @hidden */
  29706. _checkInputs(): void;
  29707. /** @hidden */
  29708. get rigCameras(): Camera[];
  29709. /**
  29710. * Gets the post process used by the rig cameras
  29711. */
  29712. get rigPostProcess(): Nullable<PostProcess>;
  29713. /**
  29714. * Internal, gets the first post proces.
  29715. * @returns the first post process to be run on this camera.
  29716. */
  29717. _getFirstPostProcess(): Nullable<PostProcess>;
  29718. private _cascadePostProcessesToRigCams;
  29719. /**
  29720. * Attach a post process to the camera.
  29721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29722. * @param postProcess The post process to attach to the camera
  29723. * @param insertAt The position of the post process in case several of them are in use in the scene
  29724. * @returns the position the post process has been inserted at
  29725. */
  29726. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29727. /**
  29728. * Detach a post process to the camera.
  29729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29730. * @param postProcess The post process to detach from the camera
  29731. */
  29732. detachPostProcess(postProcess: PostProcess): void;
  29733. /**
  29734. * Gets the current world matrix of the camera
  29735. */
  29736. getWorldMatrix(): Matrix;
  29737. /** @hidden */
  29738. _getViewMatrix(): Matrix;
  29739. /**
  29740. * Gets the current view matrix of the camera.
  29741. * @param force forces the camera to recompute the matrix without looking at the cached state
  29742. * @returns the view matrix
  29743. */
  29744. getViewMatrix(force?: boolean): Matrix;
  29745. /**
  29746. * Freeze the projection matrix.
  29747. * It will prevent the cache check of the camera projection compute and can speed up perf
  29748. * if no parameter of the camera are meant to change
  29749. * @param projection Defines manually a projection if necessary
  29750. */
  29751. freezeProjectionMatrix(projection?: Matrix): void;
  29752. /**
  29753. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29754. */
  29755. unfreezeProjectionMatrix(): void;
  29756. /**
  29757. * Gets the current projection matrix of the camera.
  29758. * @param force forces the camera to recompute the matrix without looking at the cached state
  29759. * @returns the projection matrix
  29760. */
  29761. getProjectionMatrix(force?: boolean): Matrix;
  29762. /**
  29763. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29764. * @returns a Matrix
  29765. */
  29766. getTransformationMatrix(): Matrix;
  29767. private _updateFrustumPlanes;
  29768. /**
  29769. * Checks if a cullable object (mesh...) is in the camera frustum
  29770. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29771. * @param target The object to check
  29772. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29773. * @returns true if the object is in frustum otherwise false
  29774. */
  29775. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29776. /**
  29777. * Checks if a cullable object (mesh...) is in the camera frustum
  29778. * Unlike isInFrustum this cheks the full bounding box
  29779. * @param target The object to check
  29780. * @returns true if the object is in frustum otherwise false
  29781. */
  29782. isCompletelyInFrustum(target: ICullable): boolean;
  29783. /**
  29784. * Gets a ray in the forward direction from the camera.
  29785. * @param length Defines the length of the ray to create
  29786. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29787. * @param origin Defines the start point of the ray which defaults to the camera position
  29788. * @returns the forward ray
  29789. */
  29790. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29791. /**
  29792. * Gets a ray in the forward direction from the camera.
  29793. * @param refRay the ray to (re)use when setting the values
  29794. * @param length Defines the length of the ray to create
  29795. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29796. * @param origin Defines the start point of the ray which defaults to the camera position
  29797. * @returns the forward ray
  29798. */
  29799. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29800. /**
  29801. * Releases resources associated with this node.
  29802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29804. */
  29805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29806. /** @hidden */
  29807. _isLeftCamera: boolean;
  29808. /**
  29809. * Gets the left camera of a rig setup in case of Rigged Camera
  29810. */
  29811. get isLeftCamera(): boolean;
  29812. /** @hidden */
  29813. _isRightCamera: boolean;
  29814. /**
  29815. * Gets the right camera of a rig setup in case of Rigged Camera
  29816. */
  29817. get isRightCamera(): boolean;
  29818. /**
  29819. * Gets the left camera of a rig setup in case of Rigged Camera
  29820. */
  29821. get leftCamera(): Nullable<FreeCamera>;
  29822. /**
  29823. * Gets the right camera of a rig setup in case of Rigged Camera
  29824. */
  29825. get rightCamera(): Nullable<FreeCamera>;
  29826. /**
  29827. * Gets the left camera target of a rig setup in case of Rigged Camera
  29828. * @returns the target position
  29829. */
  29830. getLeftTarget(): Nullable<Vector3>;
  29831. /**
  29832. * Gets the right camera target of a rig setup in case of Rigged Camera
  29833. * @returns the target position
  29834. */
  29835. getRightTarget(): Nullable<Vector3>;
  29836. /**
  29837. * @hidden
  29838. */
  29839. setCameraRigMode(mode: number, rigParams: any): void;
  29840. /** @hidden */
  29841. static _setStereoscopicRigMode(camera: Camera): void;
  29842. /** @hidden */
  29843. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29844. /** @hidden */
  29845. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29846. /** @hidden */
  29847. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29848. /** @hidden */
  29849. _getVRProjectionMatrix(): Matrix;
  29850. protected _updateCameraRotationMatrix(): void;
  29851. protected _updateWebVRCameraRotationMatrix(): void;
  29852. /**
  29853. * This function MUST be overwritten by the different WebVR cameras available.
  29854. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29855. * @hidden
  29856. */
  29857. _getWebVRProjectionMatrix(): Matrix;
  29858. /**
  29859. * This function MUST be overwritten by the different WebVR cameras available.
  29860. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29861. * @hidden
  29862. */
  29863. _getWebVRViewMatrix(): Matrix;
  29864. /** @hidden */
  29865. setCameraRigParameter(name: string, value: any): void;
  29866. /**
  29867. * needs to be overridden by children so sub has required properties to be copied
  29868. * @hidden
  29869. */
  29870. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29871. /**
  29872. * May need to be overridden by children
  29873. * @hidden
  29874. */
  29875. _updateRigCameras(): void;
  29876. /** @hidden */
  29877. _setupInputs(): void;
  29878. /**
  29879. * Serialiaze the camera setup to a json represention
  29880. * @returns the JSON representation
  29881. */
  29882. serialize(): any;
  29883. /**
  29884. * Clones the current camera.
  29885. * @param name The cloned camera name
  29886. * @returns the cloned camera
  29887. */
  29888. clone(name: string): Camera;
  29889. /**
  29890. * Gets the direction of the camera relative to a given local axis.
  29891. * @param localAxis Defines the reference axis to provide a relative direction.
  29892. * @return the direction
  29893. */
  29894. getDirection(localAxis: Vector3): Vector3;
  29895. /**
  29896. * Returns the current camera absolute rotation
  29897. */
  29898. get absoluteRotation(): Quaternion;
  29899. /**
  29900. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29901. * @param localAxis Defines the reference axis to provide a relative direction.
  29902. * @param result Defines the vector to store the result in
  29903. */
  29904. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29905. /**
  29906. * Gets a camera constructor for a given camera type
  29907. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29908. * @param name The name of the camera the result will be able to instantiate
  29909. * @param scene The scene the result will construct the camera in
  29910. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29911. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29912. * @returns a factory method to construc the camera
  29913. */
  29914. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29915. /**
  29916. * Compute the world matrix of the camera.
  29917. * @returns the camera world matrix
  29918. */
  29919. computeWorldMatrix(): Matrix;
  29920. /**
  29921. * Parse a JSON and creates the camera from the parsed information
  29922. * @param parsedCamera The JSON to parse
  29923. * @param scene The scene to instantiate the camera in
  29924. * @returns the newly constructed camera
  29925. */
  29926. static Parse(parsedCamera: any, scene: Scene): Camera;
  29927. }
  29928. }
  29929. declare module BABYLON {
  29930. /**
  29931. * Class containing static functions to help procedurally build meshes
  29932. */
  29933. export class DiscBuilder {
  29934. /**
  29935. * Creates a plane polygonal mesh. By default, this is a disc
  29936. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29937. * * 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
  29938. * * 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
  29939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29940. * * 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
  29941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29942. * @param name defines the name of the mesh
  29943. * @param options defines the options used to create the mesh
  29944. * @param scene defines the hosting scene
  29945. * @returns the plane polygonal mesh
  29946. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29947. */
  29948. static CreateDisc(name: string, options: {
  29949. radius?: number;
  29950. tessellation?: number;
  29951. arc?: number;
  29952. updatable?: boolean;
  29953. sideOrientation?: number;
  29954. frontUVs?: Vector4;
  29955. backUVs?: Vector4;
  29956. }, scene?: Nullable<Scene>): Mesh;
  29957. }
  29958. }
  29959. declare module BABYLON {
  29960. /**
  29961. * Options to be used when creating a FresnelParameters.
  29962. */
  29963. export type IFresnelParametersCreationOptions = {
  29964. /**
  29965. * Define the color used on edges (grazing angle)
  29966. */
  29967. leftColor?: Color3;
  29968. /**
  29969. * Define the color used on center
  29970. */
  29971. rightColor?: Color3;
  29972. /**
  29973. * Define bias applied to computed fresnel term
  29974. */
  29975. bias?: number;
  29976. /**
  29977. * Defined the power exponent applied to fresnel term
  29978. */
  29979. power?: number;
  29980. /**
  29981. * Define if the fresnel effect is enable or not.
  29982. */
  29983. isEnabled?: boolean;
  29984. };
  29985. /**
  29986. * Serialized format for FresnelParameters.
  29987. */
  29988. export type IFresnelParametersSerialized = {
  29989. /**
  29990. * Define the color used on edges (grazing angle) [as an array]
  29991. */
  29992. leftColor: number[];
  29993. /**
  29994. * Define the color used on center [as an array]
  29995. */
  29996. rightColor: number[];
  29997. /**
  29998. * Define bias applied to computed fresnel term
  29999. */
  30000. bias: number;
  30001. /**
  30002. * Defined the power exponent applied to fresnel term
  30003. */
  30004. power?: number;
  30005. /**
  30006. * Define if the fresnel effect is enable or not.
  30007. */
  30008. isEnabled: boolean;
  30009. };
  30010. /**
  30011. * This represents all the required information to add a fresnel effect on a material:
  30012. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30013. */
  30014. export class FresnelParameters {
  30015. private _isEnabled;
  30016. /**
  30017. * Define if the fresnel effect is enable or not.
  30018. */
  30019. get isEnabled(): boolean;
  30020. set isEnabled(value: boolean);
  30021. /**
  30022. * Define the color used on edges (grazing angle)
  30023. */
  30024. leftColor: Color3;
  30025. /**
  30026. * Define the color used on center
  30027. */
  30028. rightColor: Color3;
  30029. /**
  30030. * Define bias applied to computed fresnel term
  30031. */
  30032. bias: number;
  30033. /**
  30034. * Defined the power exponent applied to fresnel term
  30035. */
  30036. power: number;
  30037. /**
  30038. * Creates a new FresnelParameters object.
  30039. *
  30040. * @param options provide your own settings to optionally to override defaults
  30041. */
  30042. constructor(options?: IFresnelParametersCreationOptions);
  30043. /**
  30044. * Clones the current fresnel and its valuues
  30045. * @returns a clone fresnel configuration
  30046. */
  30047. clone(): FresnelParameters;
  30048. /**
  30049. * Determines equality between FresnelParameters objects
  30050. * @param otherFresnelParameters defines the second operand
  30051. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30052. */
  30053. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30054. /**
  30055. * Serializes the current fresnel parameters to a JSON representation.
  30056. * @return the JSON serialization
  30057. */
  30058. serialize(): IFresnelParametersSerialized;
  30059. /**
  30060. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30061. * @param parsedFresnelParameters Define the JSON representation
  30062. * @returns the parsed parameters
  30063. */
  30064. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30065. }
  30066. }
  30067. declare module BABYLON {
  30068. /**
  30069. * This groups all the flags used to control the materials channel.
  30070. */
  30071. export class MaterialFlags {
  30072. private static _DiffuseTextureEnabled;
  30073. /**
  30074. * Are diffuse textures enabled in the application.
  30075. */
  30076. static get DiffuseTextureEnabled(): boolean;
  30077. static set DiffuseTextureEnabled(value: boolean);
  30078. private static _DetailTextureEnabled;
  30079. /**
  30080. * Are detail textures enabled in the application.
  30081. */
  30082. static get DetailTextureEnabled(): boolean;
  30083. static set DetailTextureEnabled(value: boolean);
  30084. private static _AmbientTextureEnabled;
  30085. /**
  30086. * Are ambient textures enabled in the application.
  30087. */
  30088. static get AmbientTextureEnabled(): boolean;
  30089. static set AmbientTextureEnabled(value: boolean);
  30090. private static _OpacityTextureEnabled;
  30091. /**
  30092. * Are opacity textures enabled in the application.
  30093. */
  30094. static get OpacityTextureEnabled(): boolean;
  30095. static set OpacityTextureEnabled(value: boolean);
  30096. private static _ReflectionTextureEnabled;
  30097. /**
  30098. * Are reflection textures enabled in the application.
  30099. */
  30100. static get ReflectionTextureEnabled(): boolean;
  30101. static set ReflectionTextureEnabled(value: boolean);
  30102. private static _EmissiveTextureEnabled;
  30103. /**
  30104. * Are emissive textures enabled in the application.
  30105. */
  30106. static get EmissiveTextureEnabled(): boolean;
  30107. static set EmissiveTextureEnabled(value: boolean);
  30108. private static _SpecularTextureEnabled;
  30109. /**
  30110. * Are specular textures enabled in the application.
  30111. */
  30112. static get SpecularTextureEnabled(): boolean;
  30113. static set SpecularTextureEnabled(value: boolean);
  30114. private static _BumpTextureEnabled;
  30115. /**
  30116. * Are bump textures enabled in the application.
  30117. */
  30118. static get BumpTextureEnabled(): boolean;
  30119. static set BumpTextureEnabled(value: boolean);
  30120. private static _LightmapTextureEnabled;
  30121. /**
  30122. * Are lightmap textures enabled in the application.
  30123. */
  30124. static get LightmapTextureEnabled(): boolean;
  30125. static set LightmapTextureEnabled(value: boolean);
  30126. private static _RefractionTextureEnabled;
  30127. /**
  30128. * Are refraction textures enabled in the application.
  30129. */
  30130. static get RefractionTextureEnabled(): boolean;
  30131. static set RefractionTextureEnabled(value: boolean);
  30132. private static _ColorGradingTextureEnabled;
  30133. /**
  30134. * Are color grading textures enabled in the application.
  30135. */
  30136. static get ColorGradingTextureEnabled(): boolean;
  30137. static set ColorGradingTextureEnabled(value: boolean);
  30138. private static _FresnelEnabled;
  30139. /**
  30140. * Are fresnels enabled in the application.
  30141. */
  30142. static get FresnelEnabled(): boolean;
  30143. static set FresnelEnabled(value: boolean);
  30144. private static _ClearCoatTextureEnabled;
  30145. /**
  30146. * Are clear coat textures enabled in the application.
  30147. */
  30148. static get ClearCoatTextureEnabled(): boolean;
  30149. static set ClearCoatTextureEnabled(value: boolean);
  30150. private static _ClearCoatBumpTextureEnabled;
  30151. /**
  30152. * Are clear coat bump textures enabled in the application.
  30153. */
  30154. static get ClearCoatBumpTextureEnabled(): boolean;
  30155. static set ClearCoatBumpTextureEnabled(value: boolean);
  30156. private static _ClearCoatTintTextureEnabled;
  30157. /**
  30158. * Are clear coat tint textures enabled in the application.
  30159. */
  30160. static get ClearCoatTintTextureEnabled(): boolean;
  30161. static set ClearCoatTintTextureEnabled(value: boolean);
  30162. private static _SheenTextureEnabled;
  30163. /**
  30164. * Are sheen textures enabled in the application.
  30165. */
  30166. static get SheenTextureEnabled(): boolean;
  30167. static set SheenTextureEnabled(value: boolean);
  30168. private static _AnisotropicTextureEnabled;
  30169. /**
  30170. * Are anisotropic textures enabled in the application.
  30171. */
  30172. static get AnisotropicTextureEnabled(): boolean;
  30173. static set AnisotropicTextureEnabled(value: boolean);
  30174. private static _ThicknessTextureEnabled;
  30175. /**
  30176. * Are thickness textures enabled in the application.
  30177. */
  30178. static get ThicknessTextureEnabled(): boolean;
  30179. static set ThicknessTextureEnabled(value: boolean);
  30180. }
  30181. }
  30182. declare module BABYLON {
  30183. /** @hidden */
  30184. export var defaultFragmentDeclaration: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module BABYLON {
  30190. /** @hidden */
  30191. export var defaultUboDeclaration: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module BABYLON {
  30197. /** @hidden */
  30198. export var prePassDeclaration: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module BABYLON {
  30204. /** @hidden */
  30205. export var lightFragmentDeclaration: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module BABYLON {
  30211. /** @hidden */
  30212. export var lightUboDeclaration: {
  30213. name: string;
  30214. shader: string;
  30215. };
  30216. }
  30217. declare module BABYLON {
  30218. /** @hidden */
  30219. export var lightsFragmentFunctions: {
  30220. name: string;
  30221. shader: string;
  30222. };
  30223. }
  30224. declare module BABYLON {
  30225. /** @hidden */
  30226. export var shadowsFragmentFunctions: {
  30227. name: string;
  30228. shader: string;
  30229. };
  30230. }
  30231. declare module BABYLON {
  30232. /** @hidden */
  30233. export var fresnelFunction: {
  30234. name: string;
  30235. shader: string;
  30236. };
  30237. }
  30238. declare module BABYLON {
  30239. /** @hidden */
  30240. export var bumpFragmentMainFunctions: {
  30241. name: string;
  30242. shader: string;
  30243. };
  30244. }
  30245. declare module BABYLON {
  30246. /** @hidden */
  30247. export var bumpFragmentFunctions: {
  30248. name: string;
  30249. shader: string;
  30250. };
  30251. }
  30252. declare module BABYLON {
  30253. /** @hidden */
  30254. export var logDepthDeclaration: {
  30255. name: string;
  30256. shader: string;
  30257. };
  30258. }
  30259. declare module BABYLON {
  30260. /** @hidden */
  30261. export var bumpFragment: {
  30262. name: string;
  30263. shader: string;
  30264. };
  30265. }
  30266. declare module BABYLON {
  30267. /** @hidden */
  30268. export var depthPrePass: {
  30269. name: string;
  30270. shader: string;
  30271. };
  30272. }
  30273. declare module BABYLON {
  30274. /** @hidden */
  30275. export var lightFragment: {
  30276. name: string;
  30277. shader: string;
  30278. };
  30279. }
  30280. declare module BABYLON {
  30281. /** @hidden */
  30282. export var logDepthFragment: {
  30283. name: string;
  30284. shader: string;
  30285. };
  30286. }
  30287. declare module BABYLON {
  30288. /** @hidden */
  30289. export var defaultPixelShader: {
  30290. name: string;
  30291. shader: string;
  30292. };
  30293. }
  30294. declare module BABYLON {
  30295. /** @hidden */
  30296. export var defaultVertexDeclaration: {
  30297. name: string;
  30298. shader: string;
  30299. };
  30300. }
  30301. declare module BABYLON {
  30302. /** @hidden */
  30303. export var bumpVertexDeclaration: {
  30304. name: string;
  30305. shader: string;
  30306. };
  30307. }
  30308. declare module BABYLON {
  30309. /** @hidden */
  30310. export var bumpVertex: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module BABYLON {
  30316. /** @hidden */
  30317. export var fogVertex: {
  30318. name: string;
  30319. shader: string;
  30320. };
  30321. }
  30322. declare module BABYLON {
  30323. /** @hidden */
  30324. export var shadowsVertex: {
  30325. name: string;
  30326. shader: string;
  30327. };
  30328. }
  30329. declare module BABYLON {
  30330. /** @hidden */
  30331. export var pointCloudVertex: {
  30332. name: string;
  30333. shader: string;
  30334. };
  30335. }
  30336. declare module BABYLON {
  30337. /** @hidden */
  30338. export var logDepthVertex: {
  30339. name: string;
  30340. shader: string;
  30341. };
  30342. }
  30343. declare module BABYLON {
  30344. /** @hidden */
  30345. export var defaultVertexShader: {
  30346. name: string;
  30347. shader: string;
  30348. };
  30349. }
  30350. declare module BABYLON {
  30351. /**
  30352. * @hidden
  30353. */
  30354. export interface IMaterialDetailMapDefines {
  30355. DETAIL: boolean;
  30356. DETAILDIRECTUV: number;
  30357. DETAIL_NORMALBLENDMETHOD: number;
  30358. /** @hidden */
  30359. _areTexturesDirty: boolean;
  30360. }
  30361. /**
  30362. * Define the code related to the detail map parameters of a material
  30363. *
  30364. * Inspired from:
  30365. * 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
  30366. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30367. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30368. */
  30369. export class DetailMapConfiguration {
  30370. private _texture;
  30371. /**
  30372. * The detail texture of the material.
  30373. */
  30374. texture: Nullable<BaseTexture>;
  30375. /**
  30376. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30377. * Bigger values mean stronger blending
  30378. */
  30379. diffuseBlendLevel: number;
  30380. /**
  30381. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30382. * Bigger values mean stronger blending. Only used with PBR materials
  30383. */
  30384. roughnessBlendLevel: number;
  30385. /**
  30386. * Defines how strong the bump effect from the detail map is
  30387. * Bigger values mean stronger effect
  30388. */
  30389. bumpLevel: number;
  30390. private _normalBlendMethod;
  30391. /**
  30392. * The method used to blend the bump and detail normals together
  30393. */
  30394. normalBlendMethod: number;
  30395. private _isEnabled;
  30396. /**
  30397. * Enable or disable the detail map on this material
  30398. */
  30399. isEnabled: boolean;
  30400. /** @hidden */
  30401. private _internalMarkAllSubMeshesAsTexturesDirty;
  30402. /** @hidden */
  30403. _markAllSubMeshesAsTexturesDirty(): void;
  30404. /**
  30405. * Instantiate a new detail map
  30406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30407. */
  30408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30409. /**
  30410. * Gets whether the submesh is ready to be used or not.
  30411. * @param defines the list of "defines" to update.
  30412. * @param scene defines the scene the material belongs to.
  30413. * @returns - boolean indicating that the submesh is ready or not.
  30414. */
  30415. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30416. /**
  30417. * Update the defines for detail map usage
  30418. * @param defines the list of "defines" to update.
  30419. * @param scene defines the scene the material belongs to.
  30420. */
  30421. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30422. /**
  30423. * Binds the material data.
  30424. * @param uniformBuffer defines the Uniform buffer to fill in.
  30425. * @param scene defines the scene the material belongs to.
  30426. * @param isFrozen defines whether the material is frozen or not.
  30427. */
  30428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30429. /**
  30430. * Checks to see if a texture is used in the material.
  30431. * @param texture - Base texture to use.
  30432. * @returns - Boolean specifying if a texture is used in the material.
  30433. */
  30434. hasTexture(texture: BaseTexture): boolean;
  30435. /**
  30436. * Returns an array of the actively used textures.
  30437. * @param activeTextures Array of BaseTextures
  30438. */
  30439. getActiveTextures(activeTextures: BaseTexture[]): void;
  30440. /**
  30441. * Returns the animatable textures.
  30442. * @param animatables Array of animatable textures.
  30443. */
  30444. getAnimatables(animatables: IAnimatable[]): void;
  30445. /**
  30446. * Disposes the resources of the material.
  30447. * @param forceDisposeTextures - Forces the disposal of all textures.
  30448. */
  30449. dispose(forceDisposeTextures?: boolean): void;
  30450. /**
  30451. * Get the current class name useful for serialization or dynamic coding.
  30452. * @returns "DetailMap"
  30453. */
  30454. getClassName(): string;
  30455. /**
  30456. * Add the required uniforms to the current list.
  30457. * @param uniforms defines the current uniform list.
  30458. */
  30459. static AddUniforms(uniforms: string[]): void;
  30460. /**
  30461. * Add the required samplers to the current list.
  30462. * @param samplers defines the current sampler list.
  30463. */
  30464. static AddSamplers(samplers: string[]): void;
  30465. /**
  30466. * Add the required uniforms to the current buffer.
  30467. * @param uniformBuffer defines the current uniform buffer.
  30468. */
  30469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30470. /**
  30471. * Makes a duplicate of the current instance into another one.
  30472. * @param detailMap define the instance where to copy the info
  30473. */
  30474. copyTo(detailMap: DetailMapConfiguration): void;
  30475. /**
  30476. * Serializes this detail map instance
  30477. * @returns - An object with the serialized instance.
  30478. */
  30479. serialize(): any;
  30480. /**
  30481. * Parses a detail map setting from a serialized object.
  30482. * @param source - Serialized object.
  30483. * @param scene Defines the scene we are parsing for
  30484. * @param rootUrl Defines the rootUrl to load from
  30485. */
  30486. parse(source: any, scene: Scene, rootUrl: string): void;
  30487. }
  30488. }
  30489. declare module BABYLON {
  30490. /** @hidden */
  30491. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30492. MAINUV1: boolean;
  30493. MAINUV2: boolean;
  30494. DIFFUSE: boolean;
  30495. DIFFUSEDIRECTUV: number;
  30496. DETAIL: boolean;
  30497. DETAILDIRECTUV: number;
  30498. DETAIL_NORMALBLENDMETHOD: number;
  30499. AMBIENT: boolean;
  30500. AMBIENTDIRECTUV: number;
  30501. OPACITY: boolean;
  30502. OPACITYDIRECTUV: number;
  30503. OPACITYRGB: boolean;
  30504. REFLECTION: boolean;
  30505. EMISSIVE: boolean;
  30506. EMISSIVEDIRECTUV: number;
  30507. SPECULAR: boolean;
  30508. SPECULARDIRECTUV: number;
  30509. BUMP: boolean;
  30510. BUMPDIRECTUV: number;
  30511. PARALLAX: boolean;
  30512. PARALLAXOCCLUSION: boolean;
  30513. SPECULAROVERALPHA: boolean;
  30514. CLIPPLANE: boolean;
  30515. CLIPPLANE2: boolean;
  30516. CLIPPLANE3: boolean;
  30517. CLIPPLANE4: boolean;
  30518. CLIPPLANE5: boolean;
  30519. CLIPPLANE6: boolean;
  30520. ALPHATEST: boolean;
  30521. DEPTHPREPASS: boolean;
  30522. ALPHAFROMDIFFUSE: boolean;
  30523. POINTSIZE: boolean;
  30524. FOG: boolean;
  30525. SPECULARTERM: boolean;
  30526. DIFFUSEFRESNEL: boolean;
  30527. OPACITYFRESNEL: boolean;
  30528. REFLECTIONFRESNEL: boolean;
  30529. REFRACTIONFRESNEL: boolean;
  30530. EMISSIVEFRESNEL: boolean;
  30531. FRESNEL: boolean;
  30532. NORMAL: boolean;
  30533. UV1: boolean;
  30534. UV2: boolean;
  30535. VERTEXCOLOR: boolean;
  30536. VERTEXALPHA: boolean;
  30537. NUM_BONE_INFLUENCERS: number;
  30538. BonesPerMesh: number;
  30539. BONETEXTURE: boolean;
  30540. INSTANCES: boolean;
  30541. THIN_INSTANCES: boolean;
  30542. GLOSSINESS: boolean;
  30543. ROUGHNESS: boolean;
  30544. EMISSIVEASILLUMINATION: boolean;
  30545. LINKEMISSIVEWITHDIFFUSE: boolean;
  30546. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30547. LIGHTMAP: boolean;
  30548. LIGHTMAPDIRECTUV: number;
  30549. OBJECTSPACE_NORMALMAP: boolean;
  30550. USELIGHTMAPASSHADOWMAP: boolean;
  30551. REFLECTIONMAP_3D: boolean;
  30552. REFLECTIONMAP_SPHERICAL: boolean;
  30553. REFLECTIONMAP_PLANAR: boolean;
  30554. REFLECTIONMAP_CUBIC: boolean;
  30555. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30556. REFLECTIONMAP_PROJECTION: boolean;
  30557. REFLECTIONMAP_SKYBOX: boolean;
  30558. REFLECTIONMAP_EXPLICIT: boolean;
  30559. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30560. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30561. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30562. INVERTCUBICMAP: boolean;
  30563. LOGARITHMICDEPTH: boolean;
  30564. REFRACTION: boolean;
  30565. REFRACTIONMAP_3D: boolean;
  30566. REFLECTIONOVERALPHA: boolean;
  30567. TWOSIDEDLIGHTING: boolean;
  30568. SHADOWFLOAT: boolean;
  30569. MORPHTARGETS: boolean;
  30570. MORPHTARGETS_NORMAL: boolean;
  30571. MORPHTARGETS_TANGENT: boolean;
  30572. MORPHTARGETS_UV: boolean;
  30573. NUM_MORPH_INFLUENCERS: number;
  30574. NONUNIFORMSCALING: boolean;
  30575. PREMULTIPLYALPHA: boolean;
  30576. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30577. ALPHABLEND: boolean;
  30578. PREPASS: boolean;
  30579. PREPASS_IRRADIANCE: boolean;
  30580. PREPASS_IRRADIANCE_INDEX: number;
  30581. PREPASS_ALBEDO: boolean;
  30582. PREPASS_ALBEDO_INDEX: number;
  30583. PREPASS_DEPTHNORMAL: boolean;
  30584. PREPASS_DEPTHNORMAL_INDEX: number;
  30585. SCENE_MRT_COUNT: number;
  30586. RGBDLIGHTMAP: boolean;
  30587. RGBDREFLECTION: boolean;
  30588. RGBDREFRACTION: boolean;
  30589. IMAGEPROCESSING: boolean;
  30590. VIGNETTE: boolean;
  30591. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30592. VIGNETTEBLENDMODEOPAQUE: boolean;
  30593. TONEMAPPING: boolean;
  30594. TONEMAPPING_ACES: boolean;
  30595. CONTRAST: boolean;
  30596. COLORCURVES: boolean;
  30597. COLORGRADING: boolean;
  30598. COLORGRADING3D: boolean;
  30599. SAMPLER3DGREENDEPTH: boolean;
  30600. SAMPLER3DBGRMAP: boolean;
  30601. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30602. MULTIVIEW: boolean;
  30603. /**
  30604. * If the reflection texture on this material is in linear color space
  30605. * @hidden
  30606. */
  30607. IS_REFLECTION_LINEAR: boolean;
  30608. /**
  30609. * If the refraction texture on this material is in linear color space
  30610. * @hidden
  30611. */
  30612. IS_REFRACTION_LINEAR: boolean;
  30613. EXPOSURE: boolean;
  30614. constructor();
  30615. setReflectionMode(modeToEnable: string): void;
  30616. }
  30617. /**
  30618. * This is the default material used in Babylon. It is the best trade off between quality
  30619. * and performances.
  30620. * @see https://doc.babylonjs.com/babylon101/materials
  30621. */
  30622. export class StandardMaterial extends PushMaterial {
  30623. private _diffuseTexture;
  30624. /**
  30625. * The basic texture of the material as viewed under a light.
  30626. */
  30627. diffuseTexture: Nullable<BaseTexture>;
  30628. private _ambientTexture;
  30629. /**
  30630. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30631. */
  30632. ambientTexture: Nullable<BaseTexture>;
  30633. private _opacityTexture;
  30634. /**
  30635. * Define the transparency of the material from a texture.
  30636. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30637. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30638. */
  30639. opacityTexture: Nullable<BaseTexture>;
  30640. private _reflectionTexture;
  30641. /**
  30642. * Define the texture used to display the reflection.
  30643. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30644. */
  30645. reflectionTexture: Nullable<BaseTexture>;
  30646. private _emissiveTexture;
  30647. /**
  30648. * Define texture of the material as if self lit.
  30649. * This will be mixed in the final result even in the absence of light.
  30650. */
  30651. emissiveTexture: Nullable<BaseTexture>;
  30652. private _specularTexture;
  30653. /**
  30654. * Define how the color and intensity of the highlight given by the light in the material.
  30655. */
  30656. specularTexture: Nullable<BaseTexture>;
  30657. private _bumpTexture;
  30658. /**
  30659. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30660. * 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.
  30661. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30662. */
  30663. bumpTexture: Nullable<BaseTexture>;
  30664. private _lightmapTexture;
  30665. /**
  30666. * Complex lighting can be computationally expensive to compute at runtime.
  30667. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30668. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30669. */
  30670. lightmapTexture: Nullable<BaseTexture>;
  30671. private _refractionTexture;
  30672. /**
  30673. * Define the texture used to display the refraction.
  30674. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30675. */
  30676. refractionTexture: Nullable<BaseTexture>;
  30677. /**
  30678. * The color of the material lit by the environmental background lighting.
  30679. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30680. */
  30681. ambientColor: Color3;
  30682. /**
  30683. * The basic color of the material as viewed under a light.
  30684. */
  30685. diffuseColor: Color3;
  30686. /**
  30687. * Define how the color and intensity of the highlight given by the light in the material.
  30688. */
  30689. specularColor: Color3;
  30690. /**
  30691. * Define the color of the material as if self lit.
  30692. * This will be mixed in the final result even in the absence of light.
  30693. */
  30694. emissiveColor: Color3;
  30695. /**
  30696. * Defines how sharp are the highlights in the material.
  30697. * The bigger the value the sharper giving a more glossy feeling to the result.
  30698. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30699. */
  30700. specularPower: number;
  30701. private _useAlphaFromDiffuseTexture;
  30702. /**
  30703. * Does the transparency come from the diffuse texture alpha channel.
  30704. */
  30705. useAlphaFromDiffuseTexture: boolean;
  30706. private _useEmissiveAsIllumination;
  30707. /**
  30708. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30709. */
  30710. useEmissiveAsIllumination: boolean;
  30711. private _linkEmissiveWithDiffuse;
  30712. /**
  30713. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30714. * the emissive level when the final color is close to one.
  30715. */
  30716. linkEmissiveWithDiffuse: boolean;
  30717. private _useSpecularOverAlpha;
  30718. /**
  30719. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30720. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30721. */
  30722. useSpecularOverAlpha: boolean;
  30723. private _useReflectionOverAlpha;
  30724. /**
  30725. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30726. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30727. */
  30728. useReflectionOverAlpha: boolean;
  30729. private _disableLighting;
  30730. /**
  30731. * Does lights from the scene impacts this material.
  30732. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30733. */
  30734. disableLighting: boolean;
  30735. private _useObjectSpaceNormalMap;
  30736. /**
  30737. * Allows using an object space normal map (instead of tangent space).
  30738. */
  30739. useObjectSpaceNormalMap: boolean;
  30740. private _useParallax;
  30741. /**
  30742. * Is parallax enabled or not.
  30743. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30744. */
  30745. useParallax: boolean;
  30746. private _useParallaxOcclusion;
  30747. /**
  30748. * Is parallax occlusion enabled or not.
  30749. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30750. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30751. */
  30752. useParallaxOcclusion: boolean;
  30753. /**
  30754. * 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.
  30755. */
  30756. parallaxScaleBias: number;
  30757. private _roughness;
  30758. /**
  30759. * Helps to define how blurry the reflections should appears in the material.
  30760. */
  30761. roughness: number;
  30762. /**
  30763. * In case of refraction, define the value of the index of refraction.
  30764. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30765. */
  30766. indexOfRefraction: number;
  30767. /**
  30768. * Invert the refraction texture alongside the y axis.
  30769. * It can be useful with procedural textures or probe for instance.
  30770. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30771. */
  30772. invertRefractionY: boolean;
  30773. /**
  30774. * Defines the alpha limits in alpha test mode.
  30775. */
  30776. alphaCutOff: number;
  30777. private _useLightmapAsShadowmap;
  30778. /**
  30779. * In case of light mapping, define whether the map contains light or shadow informations.
  30780. */
  30781. useLightmapAsShadowmap: boolean;
  30782. private _diffuseFresnelParameters;
  30783. /**
  30784. * Define the diffuse fresnel parameters of the material.
  30785. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30786. */
  30787. diffuseFresnelParameters: FresnelParameters;
  30788. private _opacityFresnelParameters;
  30789. /**
  30790. * Define the opacity fresnel parameters of the material.
  30791. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30792. */
  30793. opacityFresnelParameters: FresnelParameters;
  30794. private _reflectionFresnelParameters;
  30795. /**
  30796. * Define the reflection fresnel parameters of the material.
  30797. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30798. */
  30799. reflectionFresnelParameters: FresnelParameters;
  30800. private _refractionFresnelParameters;
  30801. /**
  30802. * Define the refraction fresnel parameters of the material.
  30803. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30804. */
  30805. refractionFresnelParameters: FresnelParameters;
  30806. private _emissiveFresnelParameters;
  30807. /**
  30808. * Define the emissive fresnel parameters of the material.
  30809. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30810. */
  30811. emissiveFresnelParameters: FresnelParameters;
  30812. private _useReflectionFresnelFromSpecular;
  30813. /**
  30814. * If true automatically deducts the fresnels values from the material specularity.
  30815. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30816. */
  30817. useReflectionFresnelFromSpecular: boolean;
  30818. private _useGlossinessFromSpecularMapAlpha;
  30819. /**
  30820. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30821. */
  30822. useGlossinessFromSpecularMapAlpha: boolean;
  30823. private _maxSimultaneousLights;
  30824. /**
  30825. * Defines the maximum number of lights that can be used in the material
  30826. */
  30827. maxSimultaneousLights: number;
  30828. private _invertNormalMapX;
  30829. /**
  30830. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30831. */
  30832. invertNormalMapX: boolean;
  30833. private _invertNormalMapY;
  30834. /**
  30835. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30836. */
  30837. invertNormalMapY: boolean;
  30838. private _twoSidedLighting;
  30839. /**
  30840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30841. */
  30842. twoSidedLighting: boolean;
  30843. /**
  30844. * Default configuration related to image processing available in the standard Material.
  30845. */
  30846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30847. /**
  30848. * Gets the image processing configuration used either in this material.
  30849. */
  30850. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30851. /**
  30852. * Sets the Default image processing configuration used either in the this material.
  30853. *
  30854. * If sets to null, the scene one is in use.
  30855. */
  30856. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30857. /**
  30858. * Keep track of the image processing observer to allow dispose and replace.
  30859. */
  30860. private _imageProcessingObserver;
  30861. /**
  30862. * Attaches a new image processing configuration to the Standard Material.
  30863. * @param configuration
  30864. */
  30865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30866. /**
  30867. * Gets wether the color curves effect is enabled.
  30868. */
  30869. get cameraColorCurvesEnabled(): boolean;
  30870. /**
  30871. * Sets wether the color curves effect is enabled.
  30872. */
  30873. set cameraColorCurvesEnabled(value: boolean);
  30874. /**
  30875. * Gets wether the color grading effect is enabled.
  30876. */
  30877. get cameraColorGradingEnabled(): boolean;
  30878. /**
  30879. * Gets wether the color grading effect is enabled.
  30880. */
  30881. set cameraColorGradingEnabled(value: boolean);
  30882. /**
  30883. * Gets wether tonemapping is enabled or not.
  30884. */
  30885. get cameraToneMappingEnabled(): boolean;
  30886. /**
  30887. * Sets wether tonemapping is enabled or not
  30888. */
  30889. set cameraToneMappingEnabled(value: boolean);
  30890. /**
  30891. * The camera exposure used on this material.
  30892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30893. * This corresponds to a photographic exposure.
  30894. */
  30895. get cameraExposure(): number;
  30896. /**
  30897. * The camera exposure used on this material.
  30898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30899. * This corresponds to a photographic exposure.
  30900. */
  30901. set cameraExposure(value: number);
  30902. /**
  30903. * Gets The camera contrast used on this material.
  30904. */
  30905. get cameraContrast(): number;
  30906. /**
  30907. * Sets The camera contrast used on this material.
  30908. */
  30909. set cameraContrast(value: number);
  30910. /**
  30911. * Gets the Color Grading 2D Lookup Texture.
  30912. */
  30913. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30914. /**
  30915. * Sets the Color Grading 2D Lookup Texture.
  30916. */
  30917. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30918. /**
  30919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30921. * 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;
  30922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30923. */
  30924. get cameraColorCurves(): Nullable<ColorCurves>;
  30925. /**
  30926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30928. * 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;
  30929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30930. */
  30931. set cameraColorCurves(value: Nullable<ColorCurves>);
  30932. /**
  30933. * Can this material render to several textures at once
  30934. */
  30935. get canRenderToMRT(): boolean;
  30936. /**
  30937. * Defines the detail map parameters for the material.
  30938. */
  30939. readonly detailMap: DetailMapConfiguration;
  30940. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30941. protected _worldViewProjectionMatrix: Matrix;
  30942. protected _globalAmbientColor: Color3;
  30943. protected _useLogarithmicDepth: boolean;
  30944. protected _rebuildInParallel: boolean;
  30945. /**
  30946. * Instantiates a new standard material.
  30947. * This is the default material used in Babylon. It is the best trade off between quality
  30948. * and performances.
  30949. * @see https://doc.babylonjs.com/babylon101/materials
  30950. * @param name Define the name of the material in the scene
  30951. * @param scene Define the scene the material belong to
  30952. */
  30953. constructor(name: string, scene: Scene);
  30954. /**
  30955. * Gets a boolean indicating that current material needs to register RTT
  30956. */
  30957. get hasRenderTargetTextures(): boolean;
  30958. /**
  30959. * Gets the current class name of the material e.g. "StandardMaterial"
  30960. * Mainly use in serialization.
  30961. * @returns the class name
  30962. */
  30963. getClassName(): string;
  30964. /**
  30965. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30966. * You can try switching to logarithmic depth.
  30967. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30968. */
  30969. get useLogarithmicDepth(): boolean;
  30970. set useLogarithmicDepth(value: boolean);
  30971. /**
  30972. * Specifies if the material will require alpha blending
  30973. * @returns a boolean specifying if alpha blending is needed
  30974. */
  30975. needAlphaBlending(): boolean;
  30976. /**
  30977. * Specifies if this material should be rendered in alpha test mode
  30978. * @returns a boolean specifying if an alpha test is needed.
  30979. */
  30980. needAlphaTesting(): boolean;
  30981. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30982. /**
  30983. * Get the texture used for alpha test purpose.
  30984. * @returns the diffuse texture in case of the standard material.
  30985. */
  30986. getAlphaTestTexture(): Nullable<BaseTexture>;
  30987. /**
  30988. * Get if the submesh is ready to be used and all its information available.
  30989. * Child classes can use it to update shaders
  30990. * @param mesh defines the mesh to check
  30991. * @param subMesh defines which submesh to check
  30992. * @param useInstances specifies that instances should be used
  30993. * @returns a boolean indicating that the submesh is ready or not
  30994. */
  30995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30996. /**
  30997. * Builds the material UBO layouts.
  30998. * Used internally during the effect preparation.
  30999. */
  31000. buildUniformLayout(): void;
  31001. /**
  31002. * Unbinds the material from the mesh
  31003. */
  31004. unbind(): void;
  31005. /**
  31006. * Binds the submesh to this material by preparing the effect and shader to draw
  31007. * @param world defines the world transformation matrix
  31008. * @param mesh defines the mesh containing the submesh
  31009. * @param subMesh defines the submesh to bind the material to
  31010. */
  31011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31012. /**
  31013. * Get the list of animatables in the material.
  31014. * @returns the list of animatables object used in the material
  31015. */
  31016. getAnimatables(): IAnimatable[];
  31017. /**
  31018. * Gets the active textures from the material
  31019. * @returns an array of textures
  31020. */
  31021. getActiveTextures(): BaseTexture[];
  31022. /**
  31023. * Specifies if the material uses a texture
  31024. * @param texture defines the texture to check against the material
  31025. * @returns a boolean specifying if the material uses the texture
  31026. */
  31027. hasTexture(texture: BaseTexture): boolean;
  31028. /**
  31029. * Disposes the material
  31030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31032. */
  31033. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31034. /**
  31035. * Makes a duplicate of the material, and gives it a new name
  31036. * @param name defines the new name for the duplicated material
  31037. * @returns the cloned material
  31038. */
  31039. clone(name: string): StandardMaterial;
  31040. /**
  31041. * Serializes this material in a JSON representation
  31042. * @returns the serialized material object
  31043. */
  31044. serialize(): any;
  31045. /**
  31046. * Creates a standard material from parsed material data
  31047. * @param source defines the JSON representation of the material
  31048. * @param scene defines the hosting scene
  31049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31050. * @returns a new standard material
  31051. */
  31052. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31053. /**
  31054. * Are diffuse textures enabled in the application.
  31055. */
  31056. static get DiffuseTextureEnabled(): boolean;
  31057. static set DiffuseTextureEnabled(value: boolean);
  31058. /**
  31059. * Are detail textures enabled in the application.
  31060. */
  31061. static get DetailTextureEnabled(): boolean;
  31062. static set DetailTextureEnabled(value: boolean);
  31063. /**
  31064. * Are ambient textures enabled in the application.
  31065. */
  31066. static get AmbientTextureEnabled(): boolean;
  31067. static set AmbientTextureEnabled(value: boolean);
  31068. /**
  31069. * Are opacity textures enabled in the application.
  31070. */
  31071. static get OpacityTextureEnabled(): boolean;
  31072. static set OpacityTextureEnabled(value: boolean);
  31073. /**
  31074. * Are reflection textures enabled in the application.
  31075. */
  31076. static get ReflectionTextureEnabled(): boolean;
  31077. static set ReflectionTextureEnabled(value: boolean);
  31078. /**
  31079. * Are emissive textures enabled in the application.
  31080. */
  31081. static get EmissiveTextureEnabled(): boolean;
  31082. static set EmissiveTextureEnabled(value: boolean);
  31083. /**
  31084. * Are specular textures enabled in the application.
  31085. */
  31086. static get SpecularTextureEnabled(): boolean;
  31087. static set SpecularTextureEnabled(value: boolean);
  31088. /**
  31089. * Are bump textures enabled in the application.
  31090. */
  31091. static get BumpTextureEnabled(): boolean;
  31092. static set BumpTextureEnabled(value: boolean);
  31093. /**
  31094. * Are lightmap textures enabled in the application.
  31095. */
  31096. static get LightmapTextureEnabled(): boolean;
  31097. static set LightmapTextureEnabled(value: boolean);
  31098. /**
  31099. * Are refraction textures enabled in the application.
  31100. */
  31101. static get RefractionTextureEnabled(): boolean;
  31102. static set RefractionTextureEnabled(value: boolean);
  31103. /**
  31104. * Are color grading textures enabled in the application.
  31105. */
  31106. static get ColorGradingTextureEnabled(): boolean;
  31107. static set ColorGradingTextureEnabled(value: boolean);
  31108. /**
  31109. * Are fresnels enabled in the application.
  31110. */
  31111. static get FresnelEnabled(): boolean;
  31112. static set FresnelEnabled(value: boolean);
  31113. }
  31114. }
  31115. declare module BABYLON {
  31116. /**
  31117. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31118. *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.
  31119. * The SPS is also a particle system. It provides some methods to manage the particles.
  31120. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31121. *
  31122. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31123. */
  31124. export class SolidParticleSystem implements IDisposable {
  31125. /**
  31126. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31127. * Example : var p = SPS.particles[i];
  31128. */
  31129. particles: SolidParticle[];
  31130. /**
  31131. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31132. */
  31133. nbParticles: number;
  31134. /**
  31135. * If the particles must ever face the camera (default false). Useful for planar particles.
  31136. */
  31137. billboard: boolean;
  31138. /**
  31139. * Recompute normals when adding a shape
  31140. */
  31141. recomputeNormals: boolean;
  31142. /**
  31143. * This a counter ofr your own usage. It's not set by any SPS functions.
  31144. */
  31145. counter: number;
  31146. /**
  31147. * The SPS name. This name is also given to the underlying mesh.
  31148. */
  31149. name: string;
  31150. /**
  31151. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31152. */
  31153. mesh: Mesh;
  31154. /**
  31155. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31156. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31157. */
  31158. vars: any;
  31159. /**
  31160. * This array is populated when the SPS is set as 'pickable'.
  31161. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31162. * Each element of this array is an object `{idx: int, faceId: int}`.
  31163. * `idx` is the picked particle index in the `SPS.particles` array
  31164. * `faceId` is the picked face index counted within this particle.
  31165. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31166. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31167. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31168. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31169. */
  31170. pickedParticles: {
  31171. idx: number;
  31172. faceId: number;
  31173. }[];
  31174. /**
  31175. * This array is populated when the SPS is set as 'pickable'
  31176. * Each key of this array is a submesh index.
  31177. * Each element of this array is a second array defined like this :
  31178. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31179. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31180. * `idx` is the picked particle index in the `SPS.particles` array
  31181. * `faceId` is the picked face index counted within this particle.
  31182. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31183. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31184. */
  31185. pickedBySubMesh: {
  31186. idx: number;
  31187. faceId: number;
  31188. }[][];
  31189. /**
  31190. * This array is populated when `enableDepthSort` is set to true.
  31191. * Each element of this array is an instance of the class DepthSortedParticle.
  31192. */
  31193. depthSortedParticles: DepthSortedParticle[];
  31194. /**
  31195. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31196. * @hidden
  31197. */
  31198. _bSphereOnly: boolean;
  31199. /**
  31200. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31201. * @hidden
  31202. */
  31203. _bSphereRadiusFactor: number;
  31204. private _scene;
  31205. private _positions;
  31206. private _indices;
  31207. private _normals;
  31208. private _colors;
  31209. private _uvs;
  31210. private _indices32;
  31211. private _positions32;
  31212. private _normals32;
  31213. private _fixedNormal32;
  31214. private _colors32;
  31215. private _uvs32;
  31216. private _index;
  31217. private _updatable;
  31218. private _pickable;
  31219. private _isVisibilityBoxLocked;
  31220. private _alwaysVisible;
  31221. private _depthSort;
  31222. private _expandable;
  31223. private _shapeCounter;
  31224. private _copy;
  31225. private _color;
  31226. private _computeParticleColor;
  31227. private _computeParticleTexture;
  31228. private _computeParticleRotation;
  31229. private _computeParticleVertex;
  31230. private _computeBoundingBox;
  31231. private _depthSortParticles;
  31232. private _camera;
  31233. private _mustUnrotateFixedNormals;
  31234. private _particlesIntersect;
  31235. private _needs32Bits;
  31236. private _isNotBuilt;
  31237. private _lastParticleId;
  31238. private _idxOfId;
  31239. private _multimaterialEnabled;
  31240. private _useModelMaterial;
  31241. private _indicesByMaterial;
  31242. private _materialIndexes;
  31243. private _depthSortFunction;
  31244. private _materialSortFunction;
  31245. private _materials;
  31246. private _multimaterial;
  31247. private _materialIndexesById;
  31248. private _defaultMaterial;
  31249. private _autoUpdateSubMeshes;
  31250. private _tmpVertex;
  31251. /**
  31252. * Creates a SPS (Solid Particle System) object.
  31253. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31254. * @param scene (Scene) is the scene in which the SPS is added.
  31255. * @param options defines the options of the sps e.g.
  31256. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31257. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31258. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31259. * * 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.
  31260. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31261. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31262. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31263. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31264. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31265. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31266. */
  31267. constructor(name: string, scene: Scene, options?: {
  31268. updatable?: boolean;
  31269. isPickable?: boolean;
  31270. enableDepthSort?: boolean;
  31271. particleIntersection?: boolean;
  31272. boundingSphereOnly?: boolean;
  31273. bSphereRadiusFactor?: number;
  31274. expandable?: boolean;
  31275. useModelMaterial?: boolean;
  31276. enableMultiMaterial?: boolean;
  31277. });
  31278. /**
  31279. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31280. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31281. * @returns the created mesh
  31282. */
  31283. buildMesh(): Mesh;
  31284. /**
  31285. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31286. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31287. * Thus the particles generated from `digest()` have their property `position` set yet.
  31288. * @param mesh ( Mesh ) is the mesh to be digested
  31289. * @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
  31290. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31291. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31292. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31293. * @returns the current SPS
  31294. */
  31295. digest(mesh: Mesh, options?: {
  31296. facetNb?: number;
  31297. number?: number;
  31298. delta?: number;
  31299. storage?: [];
  31300. }): SolidParticleSystem;
  31301. /**
  31302. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31303. * @hidden
  31304. */
  31305. private _unrotateFixedNormals;
  31306. /**
  31307. * Resets the temporary working copy particle
  31308. * @hidden
  31309. */
  31310. private _resetCopy;
  31311. /**
  31312. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31313. * @param p the current index in the positions array to be updated
  31314. * @param ind the current index in the indices array
  31315. * @param shape a Vector3 array, the shape geometry
  31316. * @param positions the positions array to be updated
  31317. * @param meshInd the shape indices array
  31318. * @param indices the indices array to be updated
  31319. * @param meshUV the shape uv array
  31320. * @param uvs the uv array to be updated
  31321. * @param meshCol the shape color array
  31322. * @param colors the color array to be updated
  31323. * @param meshNor the shape normals array
  31324. * @param normals the normals array to be updated
  31325. * @param idx the particle index
  31326. * @param idxInShape the particle index in its shape
  31327. * @param options the addShape() method passed options
  31328. * @model the particle model
  31329. * @hidden
  31330. */
  31331. private _meshBuilder;
  31332. /**
  31333. * Returns a shape Vector3 array from positions float array
  31334. * @param positions float array
  31335. * @returns a vector3 array
  31336. * @hidden
  31337. */
  31338. private _posToShape;
  31339. /**
  31340. * Returns a shapeUV array from a float uvs (array deep copy)
  31341. * @param uvs as a float array
  31342. * @returns a shapeUV array
  31343. * @hidden
  31344. */
  31345. private _uvsToShapeUV;
  31346. /**
  31347. * Adds a new particle object in the particles array
  31348. * @param idx particle index in particles array
  31349. * @param id particle id
  31350. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31351. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31352. * @param model particle ModelShape object
  31353. * @param shapeId model shape identifier
  31354. * @param idxInShape index of the particle in the current model
  31355. * @param bInfo model bounding info object
  31356. * @param storage target storage array, if any
  31357. * @hidden
  31358. */
  31359. private _addParticle;
  31360. /**
  31361. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31362. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31363. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31364. * @param nb (positive integer) the number of particles to be created from this model
  31365. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31366. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31367. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31368. * @returns the number of shapes in the system
  31369. */
  31370. addShape(mesh: Mesh, nb: number, options?: {
  31371. positionFunction?: any;
  31372. vertexFunction?: any;
  31373. storage?: [];
  31374. }): number;
  31375. /**
  31376. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31377. * @hidden
  31378. */
  31379. private _rebuildParticle;
  31380. /**
  31381. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31382. * @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.
  31383. * @returns the SPS.
  31384. */
  31385. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31386. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31387. * Returns an array with the removed particles.
  31388. * 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.
  31389. * The SPS can't be empty so at least one particle needs to remain in place.
  31390. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31391. * @param start index of the first particle to remove
  31392. * @param end index of the last particle to remove (included)
  31393. * @returns an array populated with the removed particles
  31394. */
  31395. removeParticles(start: number, end: number): SolidParticle[];
  31396. /**
  31397. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31398. * @param solidParticleArray an array populated with Solid Particles objects
  31399. * @returns the SPS
  31400. */
  31401. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31402. /**
  31403. * Creates a new particle and modifies the SPS mesh geometry :
  31404. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31405. * - calls _addParticle() to populate the particle array
  31406. * factorized code from addShape() and insertParticlesFromArray()
  31407. * @param idx particle index in the particles array
  31408. * @param i particle index in its shape
  31409. * @param modelShape particle ModelShape object
  31410. * @param shape shape vertex array
  31411. * @param meshInd shape indices array
  31412. * @param meshUV shape uv array
  31413. * @param meshCol shape color array
  31414. * @param meshNor shape normals array
  31415. * @param bbInfo shape bounding info
  31416. * @param storage target particle storage
  31417. * @options addShape() passed options
  31418. * @hidden
  31419. */
  31420. private _insertNewParticle;
  31421. /**
  31422. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31423. * This method calls `updateParticle()` for each particle of the SPS.
  31424. * For an animated SPS, it is usually called within the render loop.
  31425. * 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.
  31426. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31427. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31428. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31429. * @returns the SPS.
  31430. */
  31431. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31432. /**
  31433. * Disposes the SPS.
  31434. */
  31435. dispose(): void;
  31436. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31437. * idx is the particle index in the SPS
  31438. * faceId is the picked face index counted within this particle.
  31439. * Returns null if the pickInfo can't identify a picked particle.
  31440. * @param pickingInfo (PickingInfo object)
  31441. * @returns {idx: number, faceId: number} or null
  31442. */
  31443. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31444. idx: number;
  31445. faceId: number;
  31446. }>;
  31447. /**
  31448. * Returns a SolidParticle object from its identifier : particle.id
  31449. * @param id (integer) the particle Id
  31450. * @returns the searched particle or null if not found in the SPS.
  31451. */
  31452. getParticleById(id: number): Nullable<SolidParticle>;
  31453. /**
  31454. * Returns a new array populated with the particles having the passed shapeId.
  31455. * @param shapeId (integer) the shape identifier
  31456. * @returns a new solid particle array
  31457. */
  31458. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31459. /**
  31460. * Populates the passed array "ref" with the particles having the passed shapeId.
  31461. * @param shapeId the shape identifier
  31462. * @returns the SPS
  31463. * @param ref
  31464. */
  31465. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31466. /**
  31467. * Computes the required SubMeshes according the materials assigned to the particles.
  31468. * @returns the solid particle system.
  31469. * Does nothing if called before the SPS mesh is built.
  31470. */
  31471. computeSubMeshes(): SolidParticleSystem;
  31472. /**
  31473. * Sorts the solid particles by material when MultiMaterial is enabled.
  31474. * Updates the indices32 array.
  31475. * Updates the indicesByMaterial array.
  31476. * Updates the mesh indices array.
  31477. * @returns the SPS
  31478. * @hidden
  31479. */
  31480. private _sortParticlesByMaterial;
  31481. /**
  31482. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31483. * @hidden
  31484. */
  31485. private _setMaterialIndexesById;
  31486. /**
  31487. * Returns an array with unique values of Materials from the passed array
  31488. * @param array the material array to be checked and filtered
  31489. * @hidden
  31490. */
  31491. private _filterUniqueMaterialId;
  31492. /**
  31493. * Sets a new Standard Material as _defaultMaterial if not already set.
  31494. * @hidden
  31495. */
  31496. private _setDefaultMaterial;
  31497. /**
  31498. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31499. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31500. * @returns the SPS.
  31501. */
  31502. refreshVisibleSize(): SolidParticleSystem;
  31503. /**
  31504. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31505. * @param size the size (float) of the visibility box
  31506. * note : this doesn't lock the SPS mesh bounding box.
  31507. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31508. */
  31509. setVisibilityBox(size: number): void;
  31510. /**
  31511. * Gets whether the SPS as always visible or not
  31512. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31513. */
  31514. get isAlwaysVisible(): boolean;
  31515. /**
  31516. * Sets the SPS as always visible or not
  31517. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31518. */
  31519. set isAlwaysVisible(val: boolean);
  31520. /**
  31521. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31523. */
  31524. set isVisibilityBoxLocked(val: boolean);
  31525. /**
  31526. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31528. */
  31529. get isVisibilityBoxLocked(): boolean;
  31530. /**
  31531. * Tells to `setParticles()` to compute the particle rotations or not.
  31532. * Default value : true. The SPS is faster when it's set to false.
  31533. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31534. */
  31535. set computeParticleRotation(val: boolean);
  31536. /**
  31537. * Tells to `setParticles()` to compute the particle colors or not.
  31538. * Default value : true. The SPS is faster when it's set to false.
  31539. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31540. */
  31541. set computeParticleColor(val: boolean);
  31542. set computeParticleTexture(val: boolean);
  31543. /**
  31544. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31545. * Default value : false. The SPS is faster when it's set to false.
  31546. * Note : the particle custom vertex positions aren't stored values.
  31547. */
  31548. set computeParticleVertex(val: boolean);
  31549. /**
  31550. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31551. */
  31552. set computeBoundingBox(val: boolean);
  31553. /**
  31554. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31555. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31556. * Default : `true`
  31557. */
  31558. set depthSortParticles(val: boolean);
  31559. /**
  31560. * Gets if `setParticles()` computes the particle rotations or not.
  31561. * Default value : true. The SPS is faster when it's set to false.
  31562. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31563. */
  31564. get computeParticleRotation(): boolean;
  31565. /**
  31566. * Gets if `setParticles()` computes the particle colors or not.
  31567. * Default value : true. The SPS is faster when it's set to false.
  31568. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31569. */
  31570. get computeParticleColor(): boolean;
  31571. /**
  31572. * Gets if `setParticles()` computes the particle textures or not.
  31573. * Default value : true. The SPS is faster when it's set to false.
  31574. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31575. */
  31576. get computeParticleTexture(): boolean;
  31577. /**
  31578. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31579. * Default value : false. The SPS is faster when it's set to false.
  31580. * Note : the particle custom vertex positions aren't stored values.
  31581. */
  31582. get computeParticleVertex(): boolean;
  31583. /**
  31584. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31585. */
  31586. get computeBoundingBox(): boolean;
  31587. /**
  31588. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31589. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31590. * Default : `true`
  31591. */
  31592. get depthSortParticles(): boolean;
  31593. /**
  31594. * Gets if the SPS is created as expandable at construction time.
  31595. * Default : `false`
  31596. */
  31597. get expandable(): boolean;
  31598. /**
  31599. * Gets if the SPS supports the Multi Materials
  31600. */
  31601. get multimaterialEnabled(): boolean;
  31602. /**
  31603. * Gets if the SPS uses the model materials for its own multimaterial.
  31604. */
  31605. get useModelMaterial(): boolean;
  31606. /**
  31607. * The SPS used material array.
  31608. */
  31609. get materials(): Material[];
  31610. /**
  31611. * Sets the SPS MultiMaterial from the passed materials.
  31612. * Note : the passed array is internally copied and not used then by reference.
  31613. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31614. */
  31615. setMultiMaterial(materials: Material[]): void;
  31616. /**
  31617. * The SPS computed multimaterial object
  31618. */
  31619. get multimaterial(): MultiMaterial;
  31620. set multimaterial(mm: MultiMaterial);
  31621. /**
  31622. * If the subMeshes must be updated on the next call to setParticles()
  31623. */
  31624. get autoUpdateSubMeshes(): boolean;
  31625. set autoUpdateSubMeshes(val: boolean);
  31626. /**
  31627. * This function does nothing. It may be overwritten to set all the particle first values.
  31628. * The SPS doesn't call this function, you may have to call it by your own.
  31629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31630. */
  31631. initParticles(): void;
  31632. /**
  31633. * This function does nothing. It may be overwritten to recycle a particle.
  31634. * The SPS doesn't call this function, you may have to call it by your own.
  31635. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31636. * @param particle The particle to recycle
  31637. * @returns the recycled particle
  31638. */
  31639. recycleParticle(particle: SolidParticle): SolidParticle;
  31640. /**
  31641. * Updates a particle : this function should be overwritten by the user.
  31642. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31643. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31644. * @example : just set a particle position or velocity and recycle conditions
  31645. * @param particle The particle to update
  31646. * @returns the updated particle
  31647. */
  31648. updateParticle(particle: SolidParticle): SolidParticle;
  31649. /**
  31650. * Updates a vertex of a particle : it can be overwritten by the user.
  31651. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31652. * @param particle the current particle
  31653. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31654. * @param pt the index of the current vertex in the particle shape
  31655. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31656. * @example : just set a vertex particle position or color
  31657. * @returns the sps
  31658. */
  31659. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31660. /**
  31661. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31662. * This does nothing and may be overwritten by the user.
  31663. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31665. * @param update the boolean update value actually passed to setParticles()
  31666. */
  31667. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31668. /**
  31669. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31670. * This will be passed three parameters.
  31671. * This does nothing and may be overwritten by the user.
  31672. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31674. * @param update the boolean update value actually passed to setParticles()
  31675. */
  31676. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31677. }
  31678. }
  31679. declare module BABYLON {
  31680. /**
  31681. * Represents one particle of a solid particle system.
  31682. */
  31683. export class SolidParticle {
  31684. /**
  31685. * particle global index
  31686. */
  31687. idx: number;
  31688. /**
  31689. * particle identifier
  31690. */
  31691. id: number;
  31692. /**
  31693. * The color of the particle
  31694. */
  31695. color: Nullable<Color4>;
  31696. /**
  31697. * The world space position of the particle.
  31698. */
  31699. position: Vector3;
  31700. /**
  31701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31702. */
  31703. rotation: Vector3;
  31704. /**
  31705. * The world space rotation quaternion of the particle.
  31706. */
  31707. rotationQuaternion: Nullable<Quaternion>;
  31708. /**
  31709. * The scaling of the particle.
  31710. */
  31711. scaling: Vector3;
  31712. /**
  31713. * The uvs of the particle.
  31714. */
  31715. uvs: Vector4;
  31716. /**
  31717. * The current speed of the particle.
  31718. */
  31719. velocity: Vector3;
  31720. /**
  31721. * The pivot point in the particle local space.
  31722. */
  31723. pivot: Vector3;
  31724. /**
  31725. * Must the particle be translated from its pivot point in its local space ?
  31726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31727. * Default : false
  31728. */
  31729. translateFromPivot: boolean;
  31730. /**
  31731. * Is the particle active or not ?
  31732. */
  31733. alive: boolean;
  31734. /**
  31735. * Is the particle visible or not ?
  31736. */
  31737. isVisible: boolean;
  31738. /**
  31739. * Index of this particle in the global "positions" array (Internal use)
  31740. * @hidden
  31741. */
  31742. _pos: number;
  31743. /**
  31744. * @hidden Index of this particle in the global "indices" array (Internal use)
  31745. */
  31746. _ind: number;
  31747. /**
  31748. * @hidden ModelShape of this particle (Internal use)
  31749. */
  31750. _model: ModelShape;
  31751. /**
  31752. * ModelShape id of this particle
  31753. */
  31754. shapeId: number;
  31755. /**
  31756. * Index of the particle in its shape id
  31757. */
  31758. idxInShape: number;
  31759. /**
  31760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31761. */
  31762. _modelBoundingInfo: BoundingInfo;
  31763. /**
  31764. * @hidden Particle BoundingInfo object (Internal use)
  31765. */
  31766. _boundingInfo: BoundingInfo;
  31767. /**
  31768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31769. */
  31770. _sps: SolidParticleSystem;
  31771. /**
  31772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31773. */
  31774. _stillInvisible: boolean;
  31775. /**
  31776. * @hidden Last computed particle rotation matrix
  31777. */
  31778. _rotationMatrix: number[];
  31779. /**
  31780. * Parent particle Id, if any.
  31781. * Default null.
  31782. */
  31783. parentId: Nullable<number>;
  31784. /**
  31785. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31786. */
  31787. materialIndex: Nullable<number>;
  31788. /**
  31789. * Custom object or properties.
  31790. */
  31791. props: Nullable<any>;
  31792. /**
  31793. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31794. * The possible values are :
  31795. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31796. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31797. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31798. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31799. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31800. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31801. * */
  31802. cullingStrategy: number;
  31803. /**
  31804. * @hidden Internal global position in the SPS.
  31805. */
  31806. _globalPosition: Vector3;
  31807. /**
  31808. * Creates a Solid Particle object.
  31809. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31810. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31811. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31812. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31813. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31814. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31815. * @param shapeId (integer) is the model shape identifier in the SPS.
  31816. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31817. * @param sps defines the sps it is associated to
  31818. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31819. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31820. */
  31821. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31822. /**
  31823. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31824. * @param target the particle target
  31825. * @returns the current particle
  31826. */
  31827. copyToRef(target: SolidParticle): SolidParticle;
  31828. /**
  31829. * Legacy support, changed scale to scaling
  31830. */
  31831. get scale(): Vector3;
  31832. /**
  31833. * Legacy support, changed scale to scaling
  31834. */
  31835. set scale(scale: Vector3);
  31836. /**
  31837. * Legacy support, changed quaternion to rotationQuaternion
  31838. */
  31839. get quaternion(): Nullable<Quaternion>;
  31840. /**
  31841. * Legacy support, changed quaternion to rotationQuaternion
  31842. */
  31843. set quaternion(q: Nullable<Quaternion>);
  31844. /**
  31845. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31846. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31847. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31848. * @returns true if it intersects
  31849. */
  31850. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31851. /**
  31852. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31853. * A particle is in the frustum if its bounding box intersects the frustum
  31854. * @param frustumPlanes defines the frustum to test
  31855. * @returns true if the particle is in the frustum planes
  31856. */
  31857. isInFrustum(frustumPlanes: Plane[]): boolean;
  31858. /**
  31859. * get the rotation matrix of the particle
  31860. * @hidden
  31861. */
  31862. getRotationMatrix(m: Matrix): void;
  31863. }
  31864. /**
  31865. * Represents the shape of the model used by one particle of a solid particle system.
  31866. * SPS internal tool, don't use it manually.
  31867. */
  31868. export class ModelShape {
  31869. /**
  31870. * The shape id
  31871. * @hidden
  31872. */
  31873. shapeID: number;
  31874. /**
  31875. * flat array of model positions (internal use)
  31876. * @hidden
  31877. */
  31878. _shape: Vector3[];
  31879. /**
  31880. * flat array of model UVs (internal use)
  31881. * @hidden
  31882. */
  31883. _shapeUV: number[];
  31884. /**
  31885. * color array of the model
  31886. * @hidden
  31887. */
  31888. _shapeColors: number[];
  31889. /**
  31890. * indices array of the model
  31891. * @hidden
  31892. */
  31893. _indices: number[];
  31894. /**
  31895. * normals array of the model
  31896. * @hidden
  31897. */
  31898. _normals: number[];
  31899. /**
  31900. * length of the shape in the model indices array (internal use)
  31901. * @hidden
  31902. */
  31903. _indicesLength: number;
  31904. /**
  31905. * Custom position function (internal use)
  31906. * @hidden
  31907. */
  31908. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31909. /**
  31910. * Custom vertex function (internal use)
  31911. * @hidden
  31912. */
  31913. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31914. /**
  31915. * Model material (internal use)
  31916. * @hidden
  31917. */
  31918. _material: Nullable<Material>;
  31919. /**
  31920. * 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.
  31921. * SPS internal tool, don't use it manually.
  31922. * @hidden
  31923. */
  31924. 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>);
  31925. }
  31926. /**
  31927. * Represents a Depth Sorted Particle in the solid particle system.
  31928. * @hidden
  31929. */
  31930. export class DepthSortedParticle {
  31931. /**
  31932. * Particle index
  31933. */
  31934. idx: number;
  31935. /**
  31936. * Index of the particle in the "indices" array
  31937. */
  31938. ind: number;
  31939. /**
  31940. * Length of the particle shape in the "indices" array
  31941. */
  31942. indicesLength: number;
  31943. /**
  31944. * Squared distance from the particle to the camera
  31945. */
  31946. sqDistance: number;
  31947. /**
  31948. * Material index when used with MultiMaterials
  31949. */
  31950. materialIndex: number;
  31951. /**
  31952. * Creates a new sorted particle
  31953. * @param materialIndex
  31954. */
  31955. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31956. }
  31957. /**
  31958. * Represents a solid particle vertex
  31959. */
  31960. export class SolidParticleVertex {
  31961. /**
  31962. * Vertex position
  31963. */
  31964. position: Vector3;
  31965. /**
  31966. * Vertex color
  31967. */
  31968. color: Color4;
  31969. /**
  31970. * Vertex UV
  31971. */
  31972. uv: Vector2;
  31973. /**
  31974. * Creates a new solid particle vertex
  31975. */
  31976. constructor();
  31977. /** Vertex x coordinate */
  31978. get x(): number;
  31979. set x(val: number);
  31980. /** Vertex y coordinate */
  31981. get y(): number;
  31982. set y(val: number);
  31983. /** Vertex z coordinate */
  31984. get z(): number;
  31985. set z(val: number);
  31986. }
  31987. }
  31988. declare module BABYLON {
  31989. /**
  31990. * @hidden
  31991. */
  31992. export class _MeshCollisionData {
  31993. _checkCollisions: boolean;
  31994. _collisionMask: number;
  31995. _collisionGroup: number;
  31996. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31997. _collider: Nullable<Collider>;
  31998. _oldPositionForCollisions: Vector3;
  31999. _diffPositionForCollisions: Vector3;
  32000. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32001. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32002. _collisionResponse: boolean;
  32003. }
  32004. }
  32005. declare module BABYLON {
  32006. /** @hidden */
  32007. class _FacetDataStorage {
  32008. facetPositions: Vector3[];
  32009. facetNormals: Vector3[];
  32010. facetPartitioning: number[][];
  32011. facetNb: number;
  32012. partitioningSubdivisions: number;
  32013. partitioningBBoxRatio: number;
  32014. facetDataEnabled: boolean;
  32015. facetParameters: any;
  32016. bbSize: Vector3;
  32017. subDiv: {
  32018. max: number;
  32019. X: number;
  32020. Y: number;
  32021. Z: number;
  32022. };
  32023. facetDepthSort: boolean;
  32024. facetDepthSortEnabled: boolean;
  32025. depthSortedIndices: IndicesArray;
  32026. depthSortedFacets: {
  32027. ind: number;
  32028. sqDistance: number;
  32029. }[];
  32030. facetDepthSortFunction: (f1: {
  32031. ind: number;
  32032. sqDistance: number;
  32033. }, f2: {
  32034. ind: number;
  32035. sqDistance: number;
  32036. }) => number;
  32037. facetDepthSortFrom: Vector3;
  32038. facetDepthSortOrigin: Vector3;
  32039. invertedMatrix: Matrix;
  32040. }
  32041. /**
  32042. * @hidden
  32043. **/
  32044. class _InternalAbstractMeshDataInfo {
  32045. _hasVertexAlpha: boolean;
  32046. _useVertexColors: boolean;
  32047. _numBoneInfluencers: number;
  32048. _applyFog: boolean;
  32049. _receiveShadows: boolean;
  32050. _facetData: _FacetDataStorage;
  32051. _visibility: number;
  32052. _skeleton: Nullable<Skeleton>;
  32053. _layerMask: number;
  32054. _computeBonesUsingShaders: boolean;
  32055. _isActive: boolean;
  32056. _onlyForInstances: boolean;
  32057. _isActiveIntermediate: boolean;
  32058. _onlyForInstancesIntermediate: boolean;
  32059. _actAsRegularMesh: boolean;
  32060. }
  32061. /**
  32062. * Class used to store all common mesh properties
  32063. */
  32064. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32065. /** No occlusion */
  32066. static OCCLUSION_TYPE_NONE: number;
  32067. /** Occlusion set to optimisitic */
  32068. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32069. /** Occlusion set to strict */
  32070. static OCCLUSION_TYPE_STRICT: number;
  32071. /** Use an accurante occlusion algorithm */
  32072. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32073. /** Use a conservative occlusion algorithm */
  32074. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32075. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32076. * Test order :
  32077. * Is the bounding sphere outside the frustum ?
  32078. * If not, are the bounding box vertices outside the frustum ?
  32079. * It not, then the cullable object is in the frustum.
  32080. */
  32081. static readonly CULLINGSTRATEGY_STANDARD: number;
  32082. /** Culling strategy : Bounding Sphere Only.
  32083. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32084. * It's also less accurate than the standard because some not visible objects can still be selected.
  32085. * Test : is the bounding sphere outside the frustum ?
  32086. * If not, then the cullable object is in the frustum.
  32087. */
  32088. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32089. /** Culling strategy : Optimistic Inclusion.
  32090. * This in an inclusion test first, then the standard exclusion test.
  32091. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32092. * 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.
  32093. * Anyway, it's as accurate as the standard strategy.
  32094. * Test :
  32095. * Is the cullable object bounding sphere center in the frustum ?
  32096. * If not, apply the default culling strategy.
  32097. */
  32098. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32099. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32100. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32101. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32102. * 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.
  32103. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32104. * Test :
  32105. * Is the cullable object bounding sphere center in the frustum ?
  32106. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32107. */
  32108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32109. /**
  32110. * No billboard
  32111. */
  32112. static get BILLBOARDMODE_NONE(): number;
  32113. /** Billboard on X axis */
  32114. static get BILLBOARDMODE_X(): number;
  32115. /** Billboard on Y axis */
  32116. static get BILLBOARDMODE_Y(): number;
  32117. /** Billboard on Z axis */
  32118. static get BILLBOARDMODE_Z(): number;
  32119. /** Billboard on all axes */
  32120. static get BILLBOARDMODE_ALL(): number;
  32121. /** Billboard on using position instead of orientation */
  32122. static get BILLBOARDMODE_USE_POSITION(): number;
  32123. /** @hidden */
  32124. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32125. /**
  32126. * The culling strategy to use to check whether the mesh must be rendered or not.
  32127. * This value can be changed at any time and will be used on the next render mesh selection.
  32128. * The possible values are :
  32129. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32130. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32132. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32133. * Please read each static variable documentation to get details about the culling process.
  32134. * */
  32135. cullingStrategy: number;
  32136. /**
  32137. * Gets the number of facets in the mesh
  32138. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32139. */
  32140. get facetNb(): number;
  32141. /**
  32142. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32143. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32144. */
  32145. get partitioningSubdivisions(): number;
  32146. set partitioningSubdivisions(nb: number);
  32147. /**
  32148. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32149. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32151. */
  32152. get partitioningBBoxRatio(): number;
  32153. set partitioningBBoxRatio(ratio: number);
  32154. /**
  32155. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32156. * Works only for updatable meshes.
  32157. * Doesn't work with multi-materials
  32158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32159. */
  32160. get mustDepthSortFacets(): boolean;
  32161. set mustDepthSortFacets(sort: boolean);
  32162. /**
  32163. * The location (Vector3) where the facet depth sort must be computed from.
  32164. * By default, the active camera position.
  32165. * Used only when facet depth sort is enabled
  32166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32167. */
  32168. get facetDepthSortFrom(): Vector3;
  32169. set facetDepthSortFrom(location: Vector3);
  32170. /**
  32171. * gets a boolean indicating if facetData is enabled
  32172. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32173. */
  32174. get isFacetDataEnabled(): boolean;
  32175. /** @hidden */
  32176. _updateNonUniformScalingState(value: boolean): boolean;
  32177. /**
  32178. * An event triggered when this mesh collides with another one
  32179. */
  32180. onCollideObservable: Observable<AbstractMesh>;
  32181. /** Set a function to call when this mesh collides with another one */
  32182. set onCollide(callback: () => void);
  32183. /**
  32184. * An event triggered when the collision's position changes
  32185. */
  32186. onCollisionPositionChangeObservable: Observable<Vector3>;
  32187. /** Set a function to call when the collision's position changes */
  32188. set onCollisionPositionChange(callback: () => void);
  32189. /**
  32190. * An event triggered when material is changed
  32191. */
  32192. onMaterialChangedObservable: Observable<AbstractMesh>;
  32193. /**
  32194. * Gets or sets the orientation for POV movement & rotation
  32195. */
  32196. definedFacingForward: boolean;
  32197. /** @hidden */
  32198. _occlusionQuery: Nullable<WebGLQuery>;
  32199. /** @hidden */
  32200. _renderingGroup: Nullable<RenderingGroup>;
  32201. /**
  32202. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32203. */
  32204. get visibility(): number;
  32205. /**
  32206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32207. */
  32208. set visibility(value: number);
  32209. /** Gets or sets the alpha index used to sort transparent meshes
  32210. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32211. */
  32212. alphaIndex: number;
  32213. /**
  32214. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32215. */
  32216. isVisible: boolean;
  32217. /**
  32218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32219. */
  32220. isPickable: boolean;
  32221. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32222. showSubMeshesBoundingBox: boolean;
  32223. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32224. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32225. */
  32226. isBlocker: boolean;
  32227. /**
  32228. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32229. */
  32230. enablePointerMoveEvents: boolean;
  32231. private _renderingGroupId;
  32232. /**
  32233. * Specifies the rendering group id for this mesh (0 by default)
  32234. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32235. */
  32236. get renderingGroupId(): number;
  32237. set renderingGroupId(value: number);
  32238. private _material;
  32239. /** Gets or sets current material */
  32240. get material(): Nullable<Material>;
  32241. set material(value: Nullable<Material>);
  32242. /**
  32243. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32244. * @see https://doc.babylonjs.com/babylon101/shadows
  32245. */
  32246. get receiveShadows(): boolean;
  32247. set receiveShadows(value: boolean);
  32248. /** Defines color to use when rendering outline */
  32249. outlineColor: Color3;
  32250. /** Define width to use when rendering outline */
  32251. outlineWidth: number;
  32252. /** Defines color to use when rendering overlay */
  32253. overlayColor: Color3;
  32254. /** Defines alpha to use when rendering overlay */
  32255. overlayAlpha: number;
  32256. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32257. get hasVertexAlpha(): boolean;
  32258. set hasVertexAlpha(value: boolean);
  32259. /** 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) */
  32260. get useVertexColors(): boolean;
  32261. set useVertexColors(value: boolean);
  32262. /**
  32263. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32264. */
  32265. get computeBonesUsingShaders(): boolean;
  32266. set computeBonesUsingShaders(value: boolean);
  32267. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32268. get numBoneInfluencers(): number;
  32269. set numBoneInfluencers(value: number);
  32270. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32271. get applyFog(): boolean;
  32272. set applyFog(value: boolean);
  32273. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32274. useOctreeForRenderingSelection: boolean;
  32275. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32276. useOctreeForPicking: boolean;
  32277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32278. useOctreeForCollisions: boolean;
  32279. /**
  32280. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32281. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32282. */
  32283. get layerMask(): number;
  32284. set layerMask(value: number);
  32285. /**
  32286. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32287. */
  32288. alwaysSelectAsActiveMesh: boolean;
  32289. /**
  32290. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32291. */
  32292. doNotSyncBoundingInfo: boolean;
  32293. /**
  32294. * Gets or sets the current action manager
  32295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32296. */
  32297. actionManager: Nullable<AbstractActionManager>;
  32298. private _meshCollisionData;
  32299. /**
  32300. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32301. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32302. */
  32303. ellipsoid: Vector3;
  32304. /**
  32305. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32306. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32307. */
  32308. ellipsoidOffset: Vector3;
  32309. /**
  32310. * Gets or sets a collision mask used to mask collisions (default is -1).
  32311. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32312. */
  32313. get collisionMask(): number;
  32314. set collisionMask(mask: number);
  32315. /**
  32316. * Gets or sets a collision response flag (default is true).
  32317. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32318. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32319. * to respond to the collision.
  32320. */
  32321. get collisionResponse(): boolean;
  32322. set collisionResponse(response: boolean);
  32323. /**
  32324. * Gets or sets the current collision group mask (-1 by default).
  32325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32326. */
  32327. get collisionGroup(): number;
  32328. set collisionGroup(mask: number);
  32329. /**
  32330. * Gets or sets current surrounding meshes (null by default).
  32331. *
  32332. * By default collision detection is tested against every mesh in the scene.
  32333. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32334. * meshes will be tested for the collision.
  32335. *
  32336. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32337. */
  32338. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32339. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32340. /**
  32341. * Defines edge width used when edgesRenderer is enabled
  32342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32343. */
  32344. edgesWidth: number;
  32345. /**
  32346. * Defines edge color used when edgesRenderer is enabled
  32347. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32348. */
  32349. edgesColor: Color4;
  32350. /** @hidden */
  32351. _edgesRenderer: Nullable<IEdgesRenderer>;
  32352. /** @hidden */
  32353. _masterMesh: Nullable<AbstractMesh>;
  32354. /** @hidden */
  32355. _boundingInfo: Nullable<BoundingInfo>;
  32356. /** @hidden */
  32357. _renderId: number;
  32358. /**
  32359. * Gets or sets the list of subMeshes
  32360. * @see https://doc.babylonjs.com/how_to/multi_materials
  32361. */
  32362. subMeshes: SubMesh[];
  32363. /** @hidden */
  32364. _intersectionsInProgress: AbstractMesh[];
  32365. /** @hidden */
  32366. _unIndexed: boolean;
  32367. /** @hidden */
  32368. _lightSources: Light[];
  32369. /** Gets the list of lights affecting that mesh */
  32370. get lightSources(): Light[];
  32371. /** @hidden */
  32372. get _positions(): Nullable<Vector3[]>;
  32373. /** @hidden */
  32374. _waitingData: {
  32375. lods: Nullable<any>;
  32376. actions: Nullable<any>;
  32377. freezeWorldMatrix: Nullable<boolean>;
  32378. };
  32379. /** @hidden */
  32380. _bonesTransformMatrices: Nullable<Float32Array>;
  32381. /** @hidden */
  32382. _transformMatrixTexture: Nullable<RawTexture>;
  32383. /**
  32384. * Gets or sets a skeleton to apply skining transformations
  32385. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32386. */
  32387. set skeleton(value: Nullable<Skeleton>);
  32388. get skeleton(): Nullable<Skeleton>;
  32389. /**
  32390. * An event triggered when the mesh is rebuilt.
  32391. */
  32392. onRebuildObservable: Observable<AbstractMesh>;
  32393. /**
  32394. * Creates a new AbstractMesh
  32395. * @param name defines the name of the mesh
  32396. * @param scene defines the hosting scene
  32397. */
  32398. constructor(name: string, scene?: Nullable<Scene>);
  32399. /**
  32400. * Returns the string "AbstractMesh"
  32401. * @returns "AbstractMesh"
  32402. */
  32403. getClassName(): string;
  32404. /**
  32405. * Gets a string representation of the current mesh
  32406. * @param fullDetails defines a boolean indicating if full details must be included
  32407. * @returns a string representation of the current mesh
  32408. */
  32409. toString(fullDetails?: boolean): string;
  32410. /**
  32411. * @hidden
  32412. */
  32413. protected _getEffectiveParent(): Nullable<Node>;
  32414. /** @hidden */
  32415. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32416. /** @hidden */
  32417. _rebuild(): void;
  32418. /** @hidden */
  32419. _resyncLightSources(): void;
  32420. /** @hidden */
  32421. _resyncLightSource(light: Light): void;
  32422. /** @hidden */
  32423. _unBindEffect(): void;
  32424. /** @hidden */
  32425. _removeLightSource(light: Light, dispose: boolean): void;
  32426. private _markSubMeshesAsDirty;
  32427. /** @hidden */
  32428. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32429. /** @hidden */
  32430. _markSubMeshesAsAttributesDirty(): void;
  32431. /** @hidden */
  32432. _markSubMeshesAsMiscDirty(): void;
  32433. /**
  32434. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32435. */
  32436. get scaling(): Vector3;
  32437. set scaling(newScaling: Vector3);
  32438. /**
  32439. * Returns true if the mesh is blocked. Implemented by child classes
  32440. */
  32441. get isBlocked(): boolean;
  32442. /**
  32443. * Returns the mesh itself by default. Implemented by child classes
  32444. * @param camera defines the camera to use to pick the right LOD level
  32445. * @returns the currentAbstractMesh
  32446. */
  32447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32448. /**
  32449. * Returns 0 by default. Implemented by child classes
  32450. * @returns an integer
  32451. */
  32452. getTotalVertices(): number;
  32453. /**
  32454. * Returns a positive integer : the total number of indices in this mesh geometry.
  32455. * @returns the numner of indices or zero if the mesh has no geometry.
  32456. */
  32457. getTotalIndices(): number;
  32458. /**
  32459. * Returns null by default. Implemented by child classes
  32460. * @returns null
  32461. */
  32462. getIndices(): Nullable<IndicesArray>;
  32463. /**
  32464. * Returns the array of the requested vertex data kind. Implemented by child classes
  32465. * @param kind defines the vertex data kind to use
  32466. * @returns null
  32467. */
  32468. getVerticesData(kind: string): Nullable<FloatArray>;
  32469. /**
  32470. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32471. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32472. * Note that a new underlying VertexBuffer object is created each call.
  32473. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32474. * @param kind defines vertex data kind:
  32475. * * VertexBuffer.PositionKind
  32476. * * VertexBuffer.UVKind
  32477. * * VertexBuffer.UV2Kind
  32478. * * VertexBuffer.UV3Kind
  32479. * * VertexBuffer.UV4Kind
  32480. * * VertexBuffer.UV5Kind
  32481. * * VertexBuffer.UV6Kind
  32482. * * VertexBuffer.ColorKind
  32483. * * VertexBuffer.MatricesIndicesKind
  32484. * * VertexBuffer.MatricesIndicesExtraKind
  32485. * * VertexBuffer.MatricesWeightsKind
  32486. * * VertexBuffer.MatricesWeightsExtraKind
  32487. * @param data defines the data source
  32488. * @param updatable defines if the data must be flagged as updatable (or static)
  32489. * @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
  32490. * @returns the current mesh
  32491. */
  32492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32493. /**
  32494. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32495. * If the mesh has no geometry, it is simply returned as it is.
  32496. * @param kind defines vertex data kind:
  32497. * * VertexBuffer.PositionKind
  32498. * * VertexBuffer.UVKind
  32499. * * VertexBuffer.UV2Kind
  32500. * * VertexBuffer.UV3Kind
  32501. * * VertexBuffer.UV4Kind
  32502. * * VertexBuffer.UV5Kind
  32503. * * VertexBuffer.UV6Kind
  32504. * * VertexBuffer.ColorKind
  32505. * * VertexBuffer.MatricesIndicesKind
  32506. * * VertexBuffer.MatricesIndicesExtraKind
  32507. * * VertexBuffer.MatricesWeightsKind
  32508. * * VertexBuffer.MatricesWeightsExtraKind
  32509. * @param data defines the data source
  32510. * @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
  32511. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32512. * @returns the current mesh
  32513. */
  32514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32515. /**
  32516. * Sets the mesh indices,
  32517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32518. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32519. * @param totalVertices Defines the total number of vertices
  32520. * @returns the current mesh
  32521. */
  32522. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32523. /**
  32524. * Gets a boolean indicating if specific vertex data is present
  32525. * @param kind defines the vertex data kind to use
  32526. * @returns true is data kind is present
  32527. */
  32528. isVerticesDataPresent(kind: string): boolean;
  32529. /**
  32530. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32531. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32532. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32533. * @returns a BoundingInfo
  32534. */
  32535. getBoundingInfo(): BoundingInfo;
  32536. /**
  32537. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32538. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32539. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32540. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32541. * @returns the current mesh
  32542. */
  32543. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32544. /**
  32545. * Overwrite the current bounding info
  32546. * @param boundingInfo defines the new bounding info
  32547. * @returns the current mesh
  32548. */
  32549. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32550. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32551. get useBones(): boolean;
  32552. /** @hidden */
  32553. _preActivate(): void;
  32554. /** @hidden */
  32555. _preActivateForIntermediateRendering(renderId: number): void;
  32556. /** @hidden */
  32557. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32558. /** @hidden */
  32559. _postActivate(): void;
  32560. /** @hidden */
  32561. _freeze(): void;
  32562. /** @hidden */
  32563. _unFreeze(): void;
  32564. /**
  32565. * Gets the current world matrix
  32566. * @returns a Matrix
  32567. */
  32568. getWorldMatrix(): Matrix;
  32569. /** @hidden */
  32570. _getWorldMatrixDeterminant(): number;
  32571. /**
  32572. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32573. */
  32574. get isAnInstance(): boolean;
  32575. /**
  32576. * Gets a boolean indicating if this mesh has instances
  32577. */
  32578. get hasInstances(): boolean;
  32579. /**
  32580. * Gets a boolean indicating if this mesh has thin instances
  32581. */
  32582. get hasThinInstances(): boolean;
  32583. /**
  32584. * Perform relative position change from the point of view of behind the front of the mesh.
  32585. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32586. * Supports definition of mesh facing forward or backward
  32587. * @param amountRight defines the distance on the right axis
  32588. * @param amountUp defines the distance on the up axis
  32589. * @param amountForward defines the distance on the forward axis
  32590. * @returns the current mesh
  32591. */
  32592. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32593. /**
  32594. * Calculate relative position change from the point of view of behind the front of the mesh.
  32595. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32596. * Supports definition of mesh facing forward or backward
  32597. * @param amountRight defines the distance on the right axis
  32598. * @param amountUp defines the distance on the up axis
  32599. * @param amountForward defines the distance on the forward axis
  32600. * @returns the new displacement vector
  32601. */
  32602. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32603. /**
  32604. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32605. * Supports definition of mesh facing forward or backward
  32606. * @param flipBack defines the flip
  32607. * @param twirlClockwise defines the twirl
  32608. * @param tiltRight defines the tilt
  32609. * @returns the current mesh
  32610. */
  32611. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32612. /**
  32613. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32614. * Supports definition of mesh facing forward or backward.
  32615. * @param flipBack defines the flip
  32616. * @param twirlClockwise defines the twirl
  32617. * @param tiltRight defines the tilt
  32618. * @returns the new rotation vector
  32619. */
  32620. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32621. /**
  32622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32623. * This means the mesh underlying bounding box and sphere are recomputed.
  32624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32625. * @returns the current mesh
  32626. */
  32627. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32628. /** @hidden */
  32629. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32630. /** @hidden */
  32631. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32632. /** @hidden */
  32633. _updateBoundingInfo(): AbstractMesh;
  32634. /** @hidden */
  32635. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32636. /** @hidden */
  32637. protected _afterComputeWorldMatrix(): void;
  32638. /** @hidden */
  32639. get _effectiveMesh(): AbstractMesh;
  32640. /**
  32641. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32642. * A mesh is in the frustum if its bounding box intersects the frustum
  32643. * @param frustumPlanes defines the frustum to test
  32644. * @returns true if the mesh is in the frustum planes
  32645. */
  32646. isInFrustum(frustumPlanes: Plane[]): boolean;
  32647. /**
  32648. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32649. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32650. * @param frustumPlanes defines the frustum to test
  32651. * @returns true if the mesh is completely in the frustum planes
  32652. */
  32653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32654. /**
  32655. * True if the mesh intersects another mesh or a SolidParticle object
  32656. * @param mesh defines a target mesh or SolidParticle to test
  32657. * @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)
  32658. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32659. * @returns true if there is an intersection
  32660. */
  32661. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32662. /**
  32663. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32664. * @param point defines the point to test
  32665. * @returns true if there is an intersection
  32666. */
  32667. intersectsPoint(point: Vector3): boolean;
  32668. /**
  32669. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32670. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32671. */
  32672. get checkCollisions(): boolean;
  32673. set checkCollisions(collisionEnabled: boolean);
  32674. /**
  32675. * Gets Collider object used to compute collisions (not physics)
  32676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32677. */
  32678. get collider(): Nullable<Collider>;
  32679. /**
  32680. * Move the mesh using collision engine
  32681. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32682. * @param displacement defines the requested displacement vector
  32683. * @returns the current mesh
  32684. */
  32685. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32686. private _onCollisionPositionChange;
  32687. /** @hidden */
  32688. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32689. /** @hidden */
  32690. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32691. /** @hidden */
  32692. _checkCollision(collider: Collider): AbstractMesh;
  32693. /** @hidden */
  32694. _generatePointsArray(): boolean;
  32695. /**
  32696. * Checks if the passed Ray intersects with the mesh
  32697. * @param ray defines the ray to use
  32698. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32699. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32700. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32701. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32702. * @returns the picking info
  32703. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32704. */
  32705. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32706. /**
  32707. * Clones the current mesh
  32708. * @param name defines the mesh name
  32709. * @param newParent defines the new mesh parent
  32710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32711. * @returns the new mesh
  32712. */
  32713. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32714. /**
  32715. * Disposes all the submeshes of the current meshnp
  32716. * @returns the current mesh
  32717. */
  32718. releaseSubMeshes(): AbstractMesh;
  32719. /**
  32720. * Releases resources associated with this abstract mesh.
  32721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32723. */
  32724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32725. /**
  32726. * Adds the passed mesh as a child to the current mesh
  32727. * @param mesh defines the child mesh
  32728. * @returns the current mesh
  32729. */
  32730. addChild(mesh: AbstractMesh): AbstractMesh;
  32731. /**
  32732. * Removes the passed mesh from the current mesh children list
  32733. * @param mesh defines the child mesh
  32734. * @returns the current mesh
  32735. */
  32736. removeChild(mesh: AbstractMesh): AbstractMesh;
  32737. /** @hidden */
  32738. private _initFacetData;
  32739. /**
  32740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32741. * This method can be called within the render loop.
  32742. * 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
  32743. * @returns the current mesh
  32744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32745. */
  32746. updateFacetData(): AbstractMesh;
  32747. /**
  32748. * Returns the facetLocalNormals array.
  32749. * The normals are expressed in the mesh local spac
  32750. * @returns an array of Vector3
  32751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32752. */
  32753. getFacetLocalNormals(): Vector3[];
  32754. /**
  32755. * Returns the facetLocalPositions array.
  32756. * The facet positions are expressed in the mesh local space
  32757. * @returns an array of Vector3
  32758. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32759. */
  32760. getFacetLocalPositions(): Vector3[];
  32761. /**
  32762. * Returns the facetLocalPartioning array
  32763. * @returns an array of array of numbers
  32764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32765. */
  32766. getFacetLocalPartitioning(): number[][];
  32767. /**
  32768. * Returns the i-th facet position in the world system.
  32769. * This method allocates a new Vector3 per call
  32770. * @param i defines the facet index
  32771. * @returns a new Vector3
  32772. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32773. */
  32774. getFacetPosition(i: number): Vector3;
  32775. /**
  32776. * Sets the reference Vector3 with the i-th facet position in the world system
  32777. * @param i defines the facet index
  32778. * @param ref defines the target vector
  32779. * @returns the current mesh
  32780. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32781. */
  32782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32783. /**
  32784. * Returns the i-th facet normal in the world system.
  32785. * This method allocates a new Vector3 per call
  32786. * @param i defines the facet index
  32787. * @returns a new Vector3
  32788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32789. */
  32790. getFacetNormal(i: number): Vector3;
  32791. /**
  32792. * Sets the reference Vector3 with the i-th facet normal in the world system
  32793. * @param i defines the facet index
  32794. * @param ref defines the target vector
  32795. * @returns the current mesh
  32796. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32797. */
  32798. getFacetNormalToRef(i: number, ref: Vector3): this;
  32799. /**
  32800. * 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)
  32801. * @param x defines x coordinate
  32802. * @param y defines y coordinate
  32803. * @param z defines z coordinate
  32804. * @returns the array of facet indexes
  32805. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32806. */
  32807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32808. /**
  32809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32810. * @param projected sets as the (x,y,z) world projection on the facet
  32811. * @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
  32812. * @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
  32813. * @param x defines x coordinate
  32814. * @param y defines y coordinate
  32815. * @param z defines z coordinate
  32816. * @returns the face index if found (or null instead)
  32817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32818. */
  32819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32820. /**
  32821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32822. * @param projected sets as the (x,y,z) local projection on the facet
  32823. * @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
  32824. * @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
  32825. * @param x defines x coordinate
  32826. * @param y defines y coordinate
  32827. * @param z defines z coordinate
  32828. * @returns the face index if found (or null instead)
  32829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32830. */
  32831. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32832. /**
  32833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32834. * @returns the parameters
  32835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32836. */
  32837. getFacetDataParameters(): any;
  32838. /**
  32839. * Disables the feature FacetData and frees the related memory
  32840. * @returns the current mesh
  32841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32842. */
  32843. disableFacetData(): AbstractMesh;
  32844. /**
  32845. * Updates the AbstractMesh indices array
  32846. * @param indices defines the data source
  32847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32848. * @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)
  32849. * @returns the current mesh
  32850. */
  32851. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32852. /**
  32853. * Creates new normals data for the mesh
  32854. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32855. * @returns the current mesh
  32856. */
  32857. createNormals(updatable: boolean): AbstractMesh;
  32858. /**
  32859. * Align the mesh with a normal
  32860. * @param normal defines the normal to use
  32861. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32862. * @returns the current mesh
  32863. */
  32864. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32865. /** @hidden */
  32866. _checkOcclusionQuery(): boolean;
  32867. /**
  32868. * Disables the mesh edge rendering mode
  32869. * @returns the currentAbstractMesh
  32870. */
  32871. disableEdgesRendering(): AbstractMesh;
  32872. /**
  32873. * Enables the edge rendering mode on the mesh.
  32874. * This mode makes the mesh edges visible
  32875. * @param epsilon defines the maximal distance between two angles to detect a face
  32876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32877. * @returns the currentAbstractMesh
  32878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32879. */
  32880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32881. /**
  32882. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32883. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32884. */
  32885. getConnectedParticleSystems(): IParticleSystem[];
  32886. }
  32887. }
  32888. declare module BABYLON {
  32889. /**
  32890. * Interface used to define ActionEvent
  32891. */
  32892. export interface IActionEvent {
  32893. /** The mesh or sprite that triggered the action */
  32894. source: any;
  32895. /** The X mouse cursor position at the time of the event */
  32896. pointerX: number;
  32897. /** The Y mouse cursor position at the time of the event */
  32898. pointerY: number;
  32899. /** The mesh that is currently pointed at (can be null) */
  32900. meshUnderPointer: Nullable<AbstractMesh>;
  32901. /** the original (browser) event that triggered the ActionEvent */
  32902. sourceEvent?: any;
  32903. /** additional data for the event */
  32904. additionalData?: any;
  32905. }
  32906. /**
  32907. * ActionEvent is the event being sent when an action is triggered.
  32908. */
  32909. export class ActionEvent implements IActionEvent {
  32910. /** The mesh or sprite that triggered the action */
  32911. source: any;
  32912. /** The X mouse cursor position at the time of the event */
  32913. pointerX: number;
  32914. /** The Y mouse cursor position at the time of the event */
  32915. pointerY: number;
  32916. /** The mesh that is currently pointed at (can be null) */
  32917. meshUnderPointer: Nullable<AbstractMesh>;
  32918. /** the original (browser) event that triggered the ActionEvent */
  32919. sourceEvent?: any;
  32920. /** additional data for the event */
  32921. additionalData?: any;
  32922. /**
  32923. * Creates a new ActionEvent
  32924. * @param source The mesh or sprite that triggered the action
  32925. * @param pointerX The X mouse cursor position at the time of the event
  32926. * @param pointerY The Y mouse cursor position at the time of the event
  32927. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32928. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32929. * @param additionalData additional data for the event
  32930. */
  32931. constructor(
  32932. /** The mesh or sprite that triggered the action */
  32933. source: any,
  32934. /** The X mouse cursor position at the time of the event */
  32935. pointerX: number,
  32936. /** The Y mouse cursor position at the time of the event */
  32937. pointerY: number,
  32938. /** The mesh that is currently pointed at (can be null) */
  32939. meshUnderPointer: Nullable<AbstractMesh>,
  32940. /** the original (browser) event that triggered the ActionEvent */
  32941. sourceEvent?: any,
  32942. /** additional data for the event */
  32943. additionalData?: any);
  32944. /**
  32945. * Helper function to auto-create an ActionEvent from a source mesh.
  32946. * @param source The source mesh that triggered the event
  32947. * @param evt The original (browser) event
  32948. * @param additionalData additional data for the event
  32949. * @returns the new ActionEvent
  32950. */
  32951. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32952. /**
  32953. * Helper function to auto-create an ActionEvent from a source sprite
  32954. * @param source The source sprite that triggered the event
  32955. * @param scene Scene associated with the sprite
  32956. * @param evt The original (browser) event
  32957. * @param additionalData additional data for the event
  32958. * @returns the new ActionEvent
  32959. */
  32960. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32961. /**
  32962. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32963. * @param scene the scene where the event occurred
  32964. * @param evt The original (browser) event
  32965. * @returns the new ActionEvent
  32966. */
  32967. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32968. /**
  32969. * Helper function to auto-create an ActionEvent from a primitive
  32970. * @param prim defines the target primitive
  32971. * @param pointerPos defines the pointer position
  32972. * @param evt The original (browser) event
  32973. * @param additionalData additional data for the event
  32974. * @returns the new ActionEvent
  32975. */
  32976. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32977. }
  32978. }
  32979. declare module BABYLON {
  32980. /**
  32981. * Abstract class used to decouple action Manager from scene and meshes.
  32982. * Do not instantiate.
  32983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32984. */
  32985. export abstract class AbstractActionManager implements IDisposable {
  32986. /** Gets the list of active triggers */
  32987. static Triggers: {
  32988. [key: string]: number;
  32989. };
  32990. /** Gets the cursor to use when hovering items */
  32991. hoverCursor: string;
  32992. /** Gets the list of actions */
  32993. actions: IAction[];
  32994. /**
  32995. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32996. */
  32997. isRecursive: boolean;
  32998. /**
  32999. * Releases all associated resources
  33000. */
  33001. abstract dispose(): void;
  33002. /**
  33003. * Does this action manager has pointer triggers
  33004. */
  33005. abstract get hasPointerTriggers(): boolean;
  33006. /**
  33007. * Does this action manager has pick triggers
  33008. */
  33009. abstract get hasPickTriggers(): boolean;
  33010. /**
  33011. * Process a specific trigger
  33012. * @param trigger defines the trigger to process
  33013. * @param evt defines the event details to be processed
  33014. */
  33015. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33016. /**
  33017. * Does this action manager handles actions of any of the given triggers
  33018. * @param triggers defines the triggers to be tested
  33019. * @return a boolean indicating whether one (or more) of the triggers is handled
  33020. */
  33021. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33022. /**
  33023. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33024. * speed.
  33025. * @param triggerA defines the trigger to be tested
  33026. * @param triggerB defines the trigger to be tested
  33027. * @return a boolean indicating whether one (or more) of the triggers is handled
  33028. */
  33029. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33030. /**
  33031. * Does this action manager handles actions of a given trigger
  33032. * @param trigger defines the trigger to be tested
  33033. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33034. * @return whether the trigger is handled
  33035. */
  33036. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33037. /**
  33038. * Serialize this manager to a JSON object
  33039. * @param name defines the property name to store this manager
  33040. * @returns a JSON representation of this manager
  33041. */
  33042. abstract serialize(name: string): any;
  33043. /**
  33044. * Registers an action to this action manager
  33045. * @param action defines the action to be registered
  33046. * @return the action amended (prepared) after registration
  33047. */
  33048. abstract registerAction(action: IAction): Nullable<IAction>;
  33049. /**
  33050. * Unregisters an action to this action manager
  33051. * @param action defines the action to be unregistered
  33052. * @return a boolean indicating whether the action has been unregistered
  33053. */
  33054. abstract unregisterAction(action: IAction): Boolean;
  33055. /**
  33056. * Does exist one action manager with at least one trigger
  33057. **/
  33058. static get HasTriggers(): boolean;
  33059. /**
  33060. * Does exist one action manager with at least one pick trigger
  33061. **/
  33062. static get HasPickTriggers(): boolean;
  33063. /**
  33064. * Does exist one action manager that handles actions of a given trigger
  33065. * @param trigger defines the trigger to be tested
  33066. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33067. **/
  33068. static HasSpecificTrigger(trigger: number): boolean;
  33069. }
  33070. }
  33071. declare module BABYLON {
  33072. /**
  33073. * Defines how a node can be built from a string name.
  33074. */
  33075. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33076. /**
  33077. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33078. */
  33079. export class Node implements IBehaviorAware<Node> {
  33080. /** @hidden */
  33081. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33082. private static _NodeConstructors;
  33083. /**
  33084. * Add a new node constructor
  33085. * @param type defines the type name of the node to construct
  33086. * @param constructorFunc defines the constructor function
  33087. */
  33088. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33089. /**
  33090. * Returns a node constructor based on type name
  33091. * @param type defines the type name
  33092. * @param name defines the new node name
  33093. * @param scene defines the hosting scene
  33094. * @param options defines optional options to transmit to constructors
  33095. * @returns the new constructor or null
  33096. */
  33097. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33098. /**
  33099. * Gets or sets the name of the node
  33100. */
  33101. name: string;
  33102. /**
  33103. * Gets or sets the id of the node
  33104. */
  33105. id: string;
  33106. /**
  33107. * Gets or sets the unique id of the node
  33108. */
  33109. uniqueId: number;
  33110. /**
  33111. * Gets or sets a string used to store user defined state for the node
  33112. */
  33113. state: string;
  33114. /**
  33115. * Gets or sets an object used to store user defined information for the node
  33116. */
  33117. metadata: any;
  33118. /**
  33119. * For internal use only. Please do not use.
  33120. */
  33121. reservedDataStore: any;
  33122. /**
  33123. * List of inspectable custom properties (used by the Inspector)
  33124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33125. */
  33126. inspectableCustomProperties: IInspectable[];
  33127. private _doNotSerialize;
  33128. /**
  33129. * Gets or sets a boolean used to define if the node must be serialized
  33130. */
  33131. get doNotSerialize(): boolean;
  33132. set doNotSerialize(value: boolean);
  33133. /** @hidden */
  33134. _isDisposed: boolean;
  33135. /**
  33136. * Gets a list of Animations associated with the node
  33137. */
  33138. animations: Animation[];
  33139. protected _ranges: {
  33140. [name: string]: Nullable<AnimationRange>;
  33141. };
  33142. /**
  33143. * Callback raised when the node is ready to be used
  33144. */
  33145. onReady: Nullable<(node: Node) => void>;
  33146. private _isEnabled;
  33147. private _isParentEnabled;
  33148. private _isReady;
  33149. /** @hidden */
  33150. _currentRenderId: number;
  33151. private _parentUpdateId;
  33152. /** @hidden */
  33153. _childUpdateId: number;
  33154. /** @hidden */
  33155. _waitingParentId: Nullable<string>;
  33156. /** @hidden */
  33157. _scene: Scene;
  33158. /** @hidden */
  33159. _cache: any;
  33160. private _parentNode;
  33161. private _children;
  33162. /** @hidden */
  33163. _worldMatrix: Matrix;
  33164. /** @hidden */
  33165. _worldMatrixDeterminant: number;
  33166. /** @hidden */
  33167. _worldMatrixDeterminantIsDirty: boolean;
  33168. /** @hidden */
  33169. private _sceneRootNodesIndex;
  33170. /**
  33171. * Gets a boolean indicating if the node has been disposed
  33172. * @returns true if the node was disposed
  33173. */
  33174. isDisposed(): boolean;
  33175. /**
  33176. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33177. * @see https://doc.babylonjs.com/how_to/parenting
  33178. */
  33179. set parent(parent: Nullable<Node>);
  33180. get parent(): Nullable<Node>;
  33181. /** @hidden */
  33182. _addToSceneRootNodes(): void;
  33183. /** @hidden */
  33184. _removeFromSceneRootNodes(): void;
  33185. private _animationPropertiesOverride;
  33186. /**
  33187. * Gets or sets the animation properties override
  33188. */
  33189. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33190. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33191. /**
  33192. * Gets a string identifying the name of the class
  33193. * @returns "Node" string
  33194. */
  33195. getClassName(): string;
  33196. /** @hidden */
  33197. readonly _isNode: boolean;
  33198. /**
  33199. * An event triggered when the mesh is disposed
  33200. */
  33201. onDisposeObservable: Observable<Node>;
  33202. private _onDisposeObserver;
  33203. /**
  33204. * Sets a callback that will be raised when the node will be disposed
  33205. */
  33206. set onDispose(callback: () => void);
  33207. /**
  33208. * Creates a new Node
  33209. * @param name the name and id to be given to this node
  33210. * @param scene the scene this node will be added to
  33211. */
  33212. constructor(name: string, scene?: Nullable<Scene>);
  33213. /**
  33214. * Gets the scene of the node
  33215. * @returns a scene
  33216. */
  33217. getScene(): Scene;
  33218. /**
  33219. * Gets the engine of the node
  33220. * @returns a Engine
  33221. */
  33222. getEngine(): Engine;
  33223. private _behaviors;
  33224. /**
  33225. * Attach a behavior to the node
  33226. * @see https://doc.babylonjs.com/features/behaviour
  33227. * @param behavior defines the behavior to attach
  33228. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33229. * @returns the current Node
  33230. */
  33231. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33232. /**
  33233. * Remove an attached behavior
  33234. * @see https://doc.babylonjs.com/features/behaviour
  33235. * @param behavior defines the behavior to attach
  33236. * @returns the current Node
  33237. */
  33238. removeBehavior(behavior: Behavior<Node>): Node;
  33239. /**
  33240. * Gets the list of attached behaviors
  33241. * @see https://doc.babylonjs.com/features/behaviour
  33242. */
  33243. get behaviors(): Behavior<Node>[];
  33244. /**
  33245. * Gets an attached behavior by name
  33246. * @param name defines the name of the behavior to look for
  33247. * @see https://doc.babylonjs.com/features/behaviour
  33248. * @returns null if behavior was not found else the requested behavior
  33249. */
  33250. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33251. /**
  33252. * Returns the latest update of the World matrix
  33253. * @returns a Matrix
  33254. */
  33255. getWorldMatrix(): Matrix;
  33256. /** @hidden */
  33257. _getWorldMatrixDeterminant(): number;
  33258. /**
  33259. * Returns directly the latest state of the mesh World matrix.
  33260. * A Matrix is returned.
  33261. */
  33262. get worldMatrixFromCache(): Matrix;
  33263. /** @hidden */
  33264. _initCache(): void;
  33265. /** @hidden */
  33266. updateCache(force?: boolean): void;
  33267. /** @hidden */
  33268. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33269. /** @hidden */
  33270. _updateCache(ignoreParentClass?: boolean): void;
  33271. /** @hidden */
  33272. _isSynchronized(): boolean;
  33273. /** @hidden */
  33274. _markSyncedWithParent(): void;
  33275. /** @hidden */
  33276. isSynchronizedWithParent(): boolean;
  33277. /** @hidden */
  33278. isSynchronized(): boolean;
  33279. /**
  33280. * Is this node ready to be used/rendered
  33281. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33282. * @return true if the node is ready
  33283. */
  33284. isReady(completeCheck?: boolean): boolean;
  33285. /**
  33286. * Is this node enabled?
  33287. * 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
  33288. * @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
  33289. * @return whether this node (and its parent) is enabled
  33290. */
  33291. isEnabled(checkAncestors?: boolean): boolean;
  33292. /** @hidden */
  33293. protected _syncParentEnabledState(): void;
  33294. /**
  33295. * Set the enabled state of this node
  33296. * @param value defines the new enabled state
  33297. */
  33298. setEnabled(value: boolean): void;
  33299. /**
  33300. * Is this node a descendant of the given node?
  33301. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33302. * @param ancestor defines the parent node to inspect
  33303. * @returns a boolean indicating if this node is a descendant of the given node
  33304. */
  33305. isDescendantOf(ancestor: Node): boolean;
  33306. /** @hidden */
  33307. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33308. /**
  33309. * Will return all nodes that have this node as ascendant
  33310. * @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
  33311. * @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
  33312. * @return all children nodes of all types
  33313. */
  33314. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33315. /**
  33316. * Get all child-meshes of this node
  33317. * @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)
  33318. * @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
  33319. * @returns an array of AbstractMesh
  33320. */
  33321. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33322. /**
  33323. * Get all direct children of this node
  33324. * @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
  33325. * @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)
  33326. * @returns an array of Node
  33327. */
  33328. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33329. /** @hidden */
  33330. _setReady(state: boolean): void;
  33331. /**
  33332. * Get an animation by name
  33333. * @param name defines the name of the animation to look for
  33334. * @returns null if not found else the requested animation
  33335. */
  33336. getAnimationByName(name: string): Nullable<Animation>;
  33337. /**
  33338. * Creates an animation range for this node
  33339. * @param name defines the name of the range
  33340. * @param from defines the starting key
  33341. * @param to defines the end key
  33342. */
  33343. createAnimationRange(name: string, from: number, to: number): void;
  33344. /**
  33345. * Delete a specific animation range
  33346. * @param name defines the name of the range to delete
  33347. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33348. */
  33349. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33350. /**
  33351. * Get an animation range by name
  33352. * @param name defines the name of the animation range to look for
  33353. * @returns null if not found else the requested animation range
  33354. */
  33355. getAnimationRange(name: string): Nullable<AnimationRange>;
  33356. /**
  33357. * Gets the list of all animation ranges defined on this node
  33358. * @returns an array
  33359. */
  33360. getAnimationRanges(): Nullable<AnimationRange>[];
  33361. /**
  33362. * Will start the animation sequence
  33363. * @param name defines the range frames for animation sequence
  33364. * @param loop defines if the animation should loop (false by default)
  33365. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33366. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33367. * @returns the object created for this animation. If range does not exist, it will return null
  33368. */
  33369. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33370. /**
  33371. * Serialize animation ranges into a JSON compatible object
  33372. * @returns serialization object
  33373. */
  33374. serializeAnimationRanges(): any;
  33375. /**
  33376. * Computes the world matrix of the node
  33377. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33378. * @returns the world matrix
  33379. */
  33380. computeWorldMatrix(force?: boolean): Matrix;
  33381. /**
  33382. * Releases resources associated with this node.
  33383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33385. */
  33386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33387. /**
  33388. * Parse animation range data from a serialization object and store them into a given node
  33389. * @param node defines where to store the animation ranges
  33390. * @param parsedNode defines the serialization object to read data from
  33391. * @param scene defines the hosting scene
  33392. */
  33393. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33394. /**
  33395. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33396. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33397. * @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
  33398. * @returns the new bounding vectors
  33399. */
  33400. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33401. min: Vector3;
  33402. max: Vector3;
  33403. };
  33404. }
  33405. }
  33406. declare module BABYLON {
  33407. /**
  33408. * @hidden
  33409. */
  33410. export class _IAnimationState {
  33411. key: number;
  33412. repeatCount: number;
  33413. workValue?: any;
  33414. loopMode?: number;
  33415. offsetValue?: any;
  33416. highLimitValue?: any;
  33417. }
  33418. /**
  33419. * Class used to store any kind of animation
  33420. */
  33421. export class Animation {
  33422. /**Name of the animation */
  33423. name: string;
  33424. /**Property to animate */
  33425. targetProperty: string;
  33426. /**The frames per second of the animation */
  33427. framePerSecond: number;
  33428. /**The data type of the animation */
  33429. dataType: number;
  33430. /**The loop mode of the animation */
  33431. loopMode?: number | undefined;
  33432. /**Specifies if blending should be enabled */
  33433. enableBlending?: boolean | undefined;
  33434. /**
  33435. * Use matrix interpolation instead of using direct key value when animating matrices
  33436. */
  33437. static AllowMatricesInterpolation: boolean;
  33438. /**
  33439. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33440. */
  33441. static AllowMatrixDecomposeForInterpolation: boolean;
  33442. /** Define the Url to load snippets */
  33443. static SnippetUrl: string;
  33444. /** Snippet ID if the animation was created from the snippet server */
  33445. snippetId: string;
  33446. /**
  33447. * Stores the key frames of the animation
  33448. */
  33449. private _keys;
  33450. /**
  33451. * Stores the easing function of the animation
  33452. */
  33453. private _easingFunction;
  33454. /**
  33455. * @hidden Internal use only
  33456. */
  33457. _runtimeAnimations: RuntimeAnimation[];
  33458. /**
  33459. * The set of event that will be linked to this animation
  33460. */
  33461. private _events;
  33462. /**
  33463. * Stores an array of target property paths
  33464. */
  33465. targetPropertyPath: string[];
  33466. /**
  33467. * Stores the blending speed of the animation
  33468. */
  33469. blendingSpeed: number;
  33470. /**
  33471. * Stores the animation ranges for the animation
  33472. */
  33473. private _ranges;
  33474. /**
  33475. * @hidden Internal use
  33476. */
  33477. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33478. /**
  33479. * Sets up an animation
  33480. * @param property The property to animate
  33481. * @param animationType The animation type to apply
  33482. * @param framePerSecond The frames per second of the animation
  33483. * @param easingFunction The easing function used in the animation
  33484. * @returns The created animation
  33485. */
  33486. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33487. /**
  33488. * Create and start an animation on a node
  33489. * @param name defines the name of the global animation that will be run on all nodes
  33490. * @param node defines the root node where the animation will take place
  33491. * @param targetProperty defines property to animate
  33492. * @param framePerSecond defines the number of frame per second yo use
  33493. * @param totalFrame defines the number of frames in total
  33494. * @param from defines the initial value
  33495. * @param to defines the final value
  33496. * @param loopMode defines which loop mode you want to use (off by default)
  33497. * @param easingFunction defines the easing function to use (linear by default)
  33498. * @param onAnimationEnd defines the callback to call when animation end
  33499. * @returns the animatable created for this animation
  33500. */
  33501. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33502. /**
  33503. * Create and start an animation on a node and its descendants
  33504. * @param name defines the name of the global animation that will be run on all nodes
  33505. * @param node defines the root node where the animation will take place
  33506. * @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
  33507. * @param targetProperty defines property to animate
  33508. * @param framePerSecond defines the number of frame per second to use
  33509. * @param totalFrame defines the number of frames in total
  33510. * @param from defines the initial value
  33511. * @param to defines the final value
  33512. * @param loopMode defines which loop mode you want to use (off by default)
  33513. * @param easingFunction defines the easing function to use (linear by default)
  33514. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33515. * @returns the list of animatables created for all nodes
  33516. * @example https://www.babylonjs-playground.com/#MH0VLI
  33517. */
  33518. 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[]>;
  33519. /**
  33520. * Creates a new animation, merges it with the existing animations and starts it
  33521. * @param name Name of the animation
  33522. * @param node Node which contains the scene that begins the animations
  33523. * @param targetProperty Specifies which property to animate
  33524. * @param framePerSecond The frames per second of the animation
  33525. * @param totalFrame The total number of frames
  33526. * @param from The frame at the beginning of the animation
  33527. * @param to The frame at the end of the animation
  33528. * @param loopMode Specifies the loop mode of the animation
  33529. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33530. * @param onAnimationEnd Callback to run once the animation is complete
  33531. * @returns Nullable animation
  33532. */
  33533. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33534. /**
  33535. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33536. * @param sourceAnimation defines the Animation containing keyframes to convert
  33537. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33538. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33539. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33540. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33541. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33542. */
  33543. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33544. /**
  33545. * Transition property of an host to the target Value
  33546. * @param property The property to transition
  33547. * @param targetValue The target Value of the property
  33548. * @param host The object where the property to animate belongs
  33549. * @param scene Scene used to run the animation
  33550. * @param frameRate Framerate (in frame/s) to use
  33551. * @param transition The transition type we want to use
  33552. * @param duration The duration of the animation, in milliseconds
  33553. * @param onAnimationEnd Callback trigger at the end of the animation
  33554. * @returns Nullable animation
  33555. */
  33556. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33557. /**
  33558. * Return the array of runtime animations currently using this animation
  33559. */
  33560. get runtimeAnimations(): RuntimeAnimation[];
  33561. /**
  33562. * Specifies if any of the runtime animations are currently running
  33563. */
  33564. get hasRunningRuntimeAnimations(): boolean;
  33565. /**
  33566. * Initializes the animation
  33567. * @param name Name of the animation
  33568. * @param targetProperty Property to animate
  33569. * @param framePerSecond The frames per second of the animation
  33570. * @param dataType The data type of the animation
  33571. * @param loopMode The loop mode of the animation
  33572. * @param enableBlending Specifies if blending should be enabled
  33573. */
  33574. constructor(
  33575. /**Name of the animation */
  33576. name: string,
  33577. /**Property to animate */
  33578. targetProperty: string,
  33579. /**The frames per second of the animation */
  33580. framePerSecond: number,
  33581. /**The data type of the animation */
  33582. dataType: number,
  33583. /**The loop mode of the animation */
  33584. loopMode?: number | undefined,
  33585. /**Specifies if blending should be enabled */
  33586. enableBlending?: boolean | undefined);
  33587. /**
  33588. * Converts the animation to a string
  33589. * @param fullDetails support for multiple levels of logging within scene loading
  33590. * @returns String form of the animation
  33591. */
  33592. toString(fullDetails?: boolean): string;
  33593. /**
  33594. * Add an event to this animation
  33595. * @param event Event to add
  33596. */
  33597. addEvent(event: AnimationEvent): void;
  33598. /**
  33599. * Remove all events found at the given frame
  33600. * @param frame The frame to remove events from
  33601. */
  33602. removeEvents(frame: number): void;
  33603. /**
  33604. * Retrieves all the events from the animation
  33605. * @returns Events from the animation
  33606. */
  33607. getEvents(): AnimationEvent[];
  33608. /**
  33609. * Creates an animation range
  33610. * @param name Name of the animation range
  33611. * @param from Starting frame of the animation range
  33612. * @param to Ending frame of the animation
  33613. */
  33614. createRange(name: string, from: number, to: number): void;
  33615. /**
  33616. * Deletes an animation range by name
  33617. * @param name Name of the animation range to delete
  33618. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33619. */
  33620. deleteRange(name: string, deleteFrames?: boolean): void;
  33621. /**
  33622. * Gets the animation range by name, or null if not defined
  33623. * @param name Name of the animation range
  33624. * @returns Nullable animation range
  33625. */
  33626. getRange(name: string): Nullable<AnimationRange>;
  33627. /**
  33628. * Gets the key frames from the animation
  33629. * @returns The key frames of the animation
  33630. */
  33631. getKeys(): Array<IAnimationKey>;
  33632. /**
  33633. * Gets the highest frame rate of the animation
  33634. * @returns Highest frame rate of the animation
  33635. */
  33636. getHighestFrame(): number;
  33637. /**
  33638. * Gets the easing function of the animation
  33639. * @returns Easing function of the animation
  33640. */
  33641. getEasingFunction(): IEasingFunction;
  33642. /**
  33643. * Sets the easing function of the animation
  33644. * @param easingFunction A custom mathematical formula for animation
  33645. */
  33646. setEasingFunction(easingFunction: EasingFunction): void;
  33647. /**
  33648. * Interpolates a scalar linearly
  33649. * @param startValue Start value of the animation curve
  33650. * @param endValue End value of the animation curve
  33651. * @param gradient Scalar amount to interpolate
  33652. * @returns Interpolated scalar value
  33653. */
  33654. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33655. /**
  33656. * Interpolates a scalar cubically
  33657. * @param startValue Start value of the animation curve
  33658. * @param outTangent End tangent of the animation
  33659. * @param endValue End value of the animation curve
  33660. * @param inTangent Start tangent of the animation curve
  33661. * @param gradient Scalar amount to interpolate
  33662. * @returns Interpolated scalar value
  33663. */
  33664. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33665. /**
  33666. * Interpolates a quaternion using a spherical linear interpolation
  33667. * @param startValue Start value of the animation curve
  33668. * @param endValue End value of the animation curve
  33669. * @param gradient Scalar amount to interpolate
  33670. * @returns Interpolated quaternion value
  33671. */
  33672. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33673. /**
  33674. * Interpolates a quaternion cubically
  33675. * @param startValue Start value of the animation curve
  33676. * @param outTangent End tangent of the animation curve
  33677. * @param endValue End value of the animation curve
  33678. * @param inTangent Start tangent of the animation curve
  33679. * @param gradient Scalar amount to interpolate
  33680. * @returns Interpolated quaternion value
  33681. */
  33682. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33683. /**
  33684. * Interpolates a Vector3 linearl
  33685. * @param startValue Start value of the animation curve
  33686. * @param endValue End value of the animation curve
  33687. * @param gradient Scalar amount to interpolate
  33688. * @returns Interpolated scalar value
  33689. */
  33690. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33691. /**
  33692. * Interpolates a Vector3 cubically
  33693. * @param startValue Start value of the animation curve
  33694. * @param outTangent End tangent of the animation
  33695. * @param endValue End value of the animation curve
  33696. * @param inTangent Start tangent of the animation curve
  33697. * @param gradient Scalar amount to interpolate
  33698. * @returns InterpolatedVector3 value
  33699. */
  33700. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33701. /**
  33702. * Interpolates a Vector2 linearly
  33703. * @param startValue Start value of the animation curve
  33704. * @param endValue End value of the animation curve
  33705. * @param gradient Scalar amount to interpolate
  33706. * @returns Interpolated Vector2 value
  33707. */
  33708. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33709. /**
  33710. * Interpolates a Vector2 cubically
  33711. * @param startValue Start value of the animation curve
  33712. * @param outTangent End tangent of the animation
  33713. * @param endValue End value of the animation curve
  33714. * @param inTangent Start tangent of the animation curve
  33715. * @param gradient Scalar amount to interpolate
  33716. * @returns Interpolated Vector2 value
  33717. */
  33718. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33719. /**
  33720. * Interpolates a size linearly
  33721. * @param startValue Start value of the animation curve
  33722. * @param endValue End value of the animation curve
  33723. * @param gradient Scalar amount to interpolate
  33724. * @returns Interpolated Size value
  33725. */
  33726. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33727. /**
  33728. * Interpolates a Color3 linearly
  33729. * @param startValue Start value of the animation curve
  33730. * @param endValue End value of the animation curve
  33731. * @param gradient Scalar amount to interpolate
  33732. * @returns Interpolated Color3 value
  33733. */
  33734. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33735. /**
  33736. * Interpolates a Color4 linearly
  33737. * @param startValue Start value of the animation curve
  33738. * @param endValue End value of the animation curve
  33739. * @param gradient Scalar amount to interpolate
  33740. * @returns Interpolated Color3 value
  33741. */
  33742. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33743. /**
  33744. * @hidden Internal use only
  33745. */
  33746. _getKeyValue(value: any): any;
  33747. /**
  33748. * @hidden Internal use only
  33749. */
  33750. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33751. /**
  33752. * Defines the function to use to interpolate matrices
  33753. * @param startValue defines the start matrix
  33754. * @param endValue defines the end matrix
  33755. * @param gradient defines the gradient between both matrices
  33756. * @param result defines an optional target matrix where to store the interpolation
  33757. * @returns the interpolated matrix
  33758. */
  33759. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33760. /**
  33761. * Makes a copy of the animation
  33762. * @returns Cloned animation
  33763. */
  33764. clone(): Animation;
  33765. /**
  33766. * Sets the key frames of the animation
  33767. * @param values The animation key frames to set
  33768. */
  33769. setKeys(values: Array<IAnimationKey>): void;
  33770. /**
  33771. * Serializes the animation to an object
  33772. * @returns Serialized object
  33773. */
  33774. serialize(): any;
  33775. /**
  33776. * Float animation type
  33777. */
  33778. static readonly ANIMATIONTYPE_FLOAT: number;
  33779. /**
  33780. * Vector3 animation type
  33781. */
  33782. static readonly ANIMATIONTYPE_VECTOR3: number;
  33783. /**
  33784. * Quaternion animation type
  33785. */
  33786. static readonly ANIMATIONTYPE_QUATERNION: number;
  33787. /**
  33788. * Matrix animation type
  33789. */
  33790. static readonly ANIMATIONTYPE_MATRIX: number;
  33791. /**
  33792. * Color3 animation type
  33793. */
  33794. static readonly ANIMATIONTYPE_COLOR3: number;
  33795. /**
  33796. * Color3 animation type
  33797. */
  33798. static readonly ANIMATIONTYPE_COLOR4: number;
  33799. /**
  33800. * Vector2 animation type
  33801. */
  33802. static readonly ANIMATIONTYPE_VECTOR2: number;
  33803. /**
  33804. * Size animation type
  33805. */
  33806. static readonly ANIMATIONTYPE_SIZE: number;
  33807. /**
  33808. * Relative Loop Mode
  33809. */
  33810. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33811. /**
  33812. * Cycle Loop Mode
  33813. */
  33814. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33815. /**
  33816. * Constant Loop Mode
  33817. */
  33818. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33819. /** @hidden */
  33820. static _UniversalLerp(left: any, right: any, amount: number): any;
  33821. /**
  33822. * Parses an animation object and creates an animation
  33823. * @param parsedAnimation Parsed animation object
  33824. * @returns Animation object
  33825. */
  33826. static Parse(parsedAnimation: any): Animation;
  33827. /**
  33828. * Appends the serialized animations from the source animations
  33829. * @param source Source containing the animations
  33830. * @param destination Target to store the animations
  33831. */
  33832. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33833. /**
  33834. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33835. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33836. * @param url defines the url to load from
  33837. * @returns a promise that will resolve to the new animation or an array of animations
  33838. */
  33839. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33840. /**
  33841. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33842. * @param snippetId defines the snippet to load
  33843. * @returns a promise that will resolve to the new animation or a new array of animations
  33844. */
  33845. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33846. }
  33847. }
  33848. declare module BABYLON {
  33849. /**
  33850. * Interface containing an array of animations
  33851. */
  33852. export interface IAnimatable {
  33853. /**
  33854. * Array of animations
  33855. */
  33856. animations: Nullable<Array<Animation>>;
  33857. }
  33858. }
  33859. declare module BABYLON {
  33860. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33861. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33862. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33863. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33864. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33865. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33866. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33867. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33868. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33869. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33870. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33871. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33872. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33873. /**
  33874. * Decorator used to define property that can be serialized as reference to a camera
  33875. * @param sourceName defines the name of the property to decorate
  33876. */
  33877. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33878. /**
  33879. * Class used to help serialization objects
  33880. */
  33881. export class SerializationHelper {
  33882. /** @hidden */
  33883. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33884. /** @hidden */
  33885. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33886. /** @hidden */
  33887. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33888. /** @hidden */
  33889. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33890. /**
  33891. * Appends the serialized animations from the source animations
  33892. * @param source Source containing the animations
  33893. * @param destination Target to store the animations
  33894. */
  33895. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33896. /**
  33897. * Static function used to serialized a specific entity
  33898. * @param entity defines the entity to serialize
  33899. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33900. * @returns a JSON compatible object representing the serialization of the entity
  33901. */
  33902. static Serialize<T>(entity: T, serializationObject?: any): any;
  33903. /**
  33904. * Creates a new entity from a serialization data object
  33905. * @param creationFunction defines a function used to instanciated the new entity
  33906. * @param source defines the source serialization data
  33907. * @param scene defines the hosting scene
  33908. * @param rootUrl defines the root url for resources
  33909. * @returns a new entity
  33910. */
  33911. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33912. /**
  33913. * Clones an object
  33914. * @param creationFunction defines the function used to instanciate the new object
  33915. * @param source defines the source object
  33916. * @returns the cloned object
  33917. */
  33918. static Clone<T>(creationFunction: () => T, source: T): T;
  33919. /**
  33920. * Instanciates a new object based on a source one (some data will be shared between both object)
  33921. * @param creationFunction defines the function used to instanciate the new object
  33922. * @param source defines the source object
  33923. * @returns the new object
  33924. */
  33925. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * Base class of all the textures in babylon.
  33931. * It groups all the common properties the materials, post process, lights... might need
  33932. * in order to make a correct use of the texture.
  33933. */
  33934. export class BaseTexture implements IAnimatable {
  33935. /**
  33936. * Default anisotropic filtering level for the application.
  33937. * It is set to 4 as a good tradeoff between perf and quality.
  33938. */
  33939. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33940. /**
  33941. * Gets or sets the unique id of the texture
  33942. */
  33943. uniqueId: number;
  33944. /**
  33945. * Define the name of the texture.
  33946. */
  33947. name: string;
  33948. /**
  33949. * Gets or sets an object used to store user defined information.
  33950. */
  33951. metadata: any;
  33952. /**
  33953. * For internal use only. Please do not use.
  33954. */
  33955. reservedDataStore: any;
  33956. private _hasAlpha;
  33957. /**
  33958. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33959. */
  33960. set hasAlpha(value: boolean);
  33961. get hasAlpha(): boolean;
  33962. /**
  33963. * Defines if the alpha value should be determined via the rgb values.
  33964. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33965. */
  33966. getAlphaFromRGB: boolean;
  33967. /**
  33968. * Intensity or strength of the texture.
  33969. * It is commonly used by materials to fine tune the intensity of the texture
  33970. */
  33971. level: number;
  33972. /**
  33973. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33974. * This is part of the texture as textures usually maps to one uv set.
  33975. */
  33976. coordinatesIndex: number;
  33977. protected _coordinatesMode: number;
  33978. /**
  33979. * How a texture is mapped.
  33980. *
  33981. * | Value | Type | Description |
  33982. * | ----- | ----------------------------------- | ----------- |
  33983. * | 0 | EXPLICIT_MODE | |
  33984. * | 1 | SPHERICAL_MODE | |
  33985. * | 2 | PLANAR_MODE | |
  33986. * | 3 | CUBIC_MODE | |
  33987. * | 4 | PROJECTION_MODE | |
  33988. * | 5 | SKYBOX_MODE | |
  33989. * | 6 | INVCUBIC_MODE | |
  33990. * | 7 | EQUIRECTANGULAR_MODE | |
  33991. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33992. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33993. */
  33994. set coordinatesMode(value: number);
  33995. get coordinatesMode(): number;
  33996. private _wrapU;
  33997. /**
  33998. * | Value | Type | Description |
  33999. * | ----- | ------------------ | ----------- |
  34000. * | 0 | CLAMP_ADDRESSMODE | |
  34001. * | 1 | WRAP_ADDRESSMODE | |
  34002. * | 2 | MIRROR_ADDRESSMODE | |
  34003. */
  34004. get wrapU(): number;
  34005. set wrapU(value: number);
  34006. private _wrapV;
  34007. /**
  34008. * | Value | Type | Description |
  34009. * | ----- | ------------------ | ----------- |
  34010. * | 0 | CLAMP_ADDRESSMODE | |
  34011. * | 1 | WRAP_ADDRESSMODE | |
  34012. * | 2 | MIRROR_ADDRESSMODE | |
  34013. */
  34014. get wrapV(): number;
  34015. set wrapV(value: number);
  34016. /**
  34017. * | Value | Type | Description |
  34018. * | ----- | ------------------ | ----------- |
  34019. * | 0 | CLAMP_ADDRESSMODE | |
  34020. * | 1 | WRAP_ADDRESSMODE | |
  34021. * | 2 | MIRROR_ADDRESSMODE | |
  34022. */
  34023. wrapR: number;
  34024. /**
  34025. * With compliant hardware and browser (supporting anisotropic filtering)
  34026. * this defines the level of anisotropic filtering in the texture.
  34027. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34028. */
  34029. anisotropicFilteringLevel: number;
  34030. /**
  34031. * Define if the texture is a cube texture or if false a 2d texture.
  34032. */
  34033. get isCube(): boolean;
  34034. set isCube(value: boolean);
  34035. /**
  34036. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34037. */
  34038. get is3D(): boolean;
  34039. set is3D(value: boolean);
  34040. /**
  34041. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34042. */
  34043. get is2DArray(): boolean;
  34044. set is2DArray(value: boolean);
  34045. private _gammaSpace;
  34046. /**
  34047. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34048. * HDR texture are usually stored in linear space.
  34049. * This only impacts the PBR and Background materials
  34050. */
  34051. get gammaSpace(): boolean;
  34052. set gammaSpace(gamma: boolean);
  34053. /**
  34054. * Gets or sets whether or not the texture contains RGBD data.
  34055. */
  34056. get isRGBD(): boolean;
  34057. set isRGBD(value: boolean);
  34058. /**
  34059. * Is Z inverted in the texture (useful in a cube texture).
  34060. */
  34061. invertZ: boolean;
  34062. /**
  34063. * Are mip maps generated for this texture or not.
  34064. */
  34065. get noMipmap(): boolean;
  34066. /**
  34067. * @hidden
  34068. */
  34069. lodLevelInAlpha: boolean;
  34070. /**
  34071. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34072. */
  34073. get lodGenerationOffset(): number;
  34074. set lodGenerationOffset(value: number);
  34075. /**
  34076. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34077. */
  34078. get lodGenerationScale(): number;
  34079. set lodGenerationScale(value: number);
  34080. /**
  34081. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34082. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34083. * average roughness values.
  34084. */
  34085. get linearSpecularLOD(): boolean;
  34086. set linearSpecularLOD(value: boolean);
  34087. /**
  34088. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34089. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34090. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34091. */
  34092. get irradianceTexture(): Nullable<BaseTexture>;
  34093. set irradianceTexture(value: Nullable<BaseTexture>);
  34094. /**
  34095. * Define if the texture is a render target.
  34096. */
  34097. isRenderTarget: boolean;
  34098. /**
  34099. * Define the unique id of the texture in the scene.
  34100. */
  34101. get uid(): string;
  34102. /** @hidden */
  34103. _prefiltered: boolean;
  34104. /**
  34105. * Return a string representation of the texture.
  34106. * @returns the texture as a string
  34107. */
  34108. toString(): string;
  34109. /**
  34110. * Get the class name of the texture.
  34111. * @returns "BaseTexture"
  34112. */
  34113. getClassName(): string;
  34114. /**
  34115. * Define the list of animation attached to the texture.
  34116. */
  34117. animations: Animation[];
  34118. /**
  34119. * An event triggered when the texture is disposed.
  34120. */
  34121. onDisposeObservable: Observable<BaseTexture>;
  34122. private _onDisposeObserver;
  34123. /**
  34124. * Callback triggered when the texture has been disposed.
  34125. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34126. */
  34127. set onDispose(callback: () => void);
  34128. /**
  34129. * Define the current state of the loading sequence when in delayed load mode.
  34130. */
  34131. delayLoadState: number;
  34132. protected _scene: Nullable<Scene>;
  34133. protected _engine: Nullable<ThinEngine>;
  34134. /** @hidden */
  34135. _texture: Nullable<InternalTexture>;
  34136. private _uid;
  34137. /**
  34138. * Define if the texture is preventinga material to render or not.
  34139. * If not and the texture is not ready, the engine will use a default black texture instead.
  34140. */
  34141. get isBlocking(): boolean;
  34142. /**
  34143. * Instantiates a new BaseTexture.
  34144. * Base class of all the textures in babylon.
  34145. * It groups all the common properties the materials, post process, lights... might need
  34146. * in order to make a correct use of the texture.
  34147. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34148. */
  34149. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34150. /**
  34151. * Get the scene the texture belongs to.
  34152. * @returns the scene or null if undefined
  34153. */
  34154. getScene(): Nullable<Scene>;
  34155. /** @hidden */
  34156. protected _getEngine(): Nullable<ThinEngine>;
  34157. /**
  34158. * Get the texture transform matrix used to offset tile the texture for istance.
  34159. * @returns the transformation matrix
  34160. */
  34161. getTextureMatrix(): Matrix;
  34162. /**
  34163. * Get the texture reflection matrix used to rotate/transform the reflection.
  34164. * @returns the reflection matrix
  34165. */
  34166. getReflectionTextureMatrix(): Matrix;
  34167. /**
  34168. * Get the underlying lower level texture from Babylon.
  34169. * @returns the insternal texture
  34170. */
  34171. getInternalTexture(): Nullable<InternalTexture>;
  34172. /**
  34173. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34174. * @returns true if ready or not blocking
  34175. */
  34176. isReadyOrNotBlocking(): boolean;
  34177. /**
  34178. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34179. * @returns true if fully ready
  34180. */
  34181. isReady(): boolean;
  34182. private _cachedSize;
  34183. /**
  34184. * Get the size of the texture.
  34185. * @returns the texture size.
  34186. */
  34187. getSize(): ISize;
  34188. /**
  34189. * Get the base size of the texture.
  34190. * It can be different from the size if the texture has been resized for POT for instance
  34191. * @returns the base size
  34192. */
  34193. getBaseSize(): ISize;
  34194. /**
  34195. * Update the sampling mode of the texture.
  34196. * Default is Trilinear mode.
  34197. *
  34198. * | Value | Type | Description |
  34199. * | ----- | ------------------ | ----------- |
  34200. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34201. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34202. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34203. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34204. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34205. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34206. * | 7 | NEAREST_LINEAR | |
  34207. * | 8 | NEAREST_NEAREST | |
  34208. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34209. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34210. * | 11 | LINEAR_LINEAR | |
  34211. * | 12 | LINEAR_NEAREST | |
  34212. *
  34213. * > _mag_: magnification filter (close to the viewer)
  34214. * > _min_: minification filter (far from the viewer)
  34215. * > _mip_: filter used between mip map levels
  34216. *@param samplingMode Define the new sampling mode of the texture
  34217. */
  34218. updateSamplingMode(samplingMode: number): void;
  34219. /**
  34220. * Scales the texture if is `canRescale()`
  34221. * @param ratio the resize factor we want to use to rescale
  34222. */
  34223. scale(ratio: number): void;
  34224. /**
  34225. * Get if the texture can rescale.
  34226. */
  34227. get canRescale(): boolean;
  34228. /** @hidden */
  34229. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34230. /** @hidden */
  34231. _rebuild(): void;
  34232. /**
  34233. * Triggers the load sequence in delayed load mode.
  34234. */
  34235. delayLoad(): void;
  34236. /**
  34237. * Clones the texture.
  34238. * @returns the cloned texture
  34239. */
  34240. clone(): Nullable<BaseTexture>;
  34241. /**
  34242. * Get the texture underlying type (INT, FLOAT...)
  34243. */
  34244. get textureType(): number;
  34245. /**
  34246. * Get the texture underlying format (RGB, RGBA...)
  34247. */
  34248. get textureFormat(): number;
  34249. /**
  34250. * Indicates that textures need to be re-calculated for all materials
  34251. */
  34252. protected _markAllSubMeshesAsTexturesDirty(): void;
  34253. /**
  34254. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34255. * This will returns an RGBA array buffer containing either in values (0-255) or
  34256. * float values (0-1) depending of the underlying buffer type.
  34257. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34258. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34259. * @param buffer defines a user defined buffer to fill with data (can be null)
  34260. * @returns The Array buffer containing the pixels data.
  34261. */
  34262. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34263. /**
  34264. * Release and destroy the underlying lower level texture aka internalTexture.
  34265. */
  34266. releaseInternalTexture(): void;
  34267. /** @hidden */
  34268. get _lodTextureHigh(): Nullable<BaseTexture>;
  34269. /** @hidden */
  34270. get _lodTextureMid(): Nullable<BaseTexture>;
  34271. /** @hidden */
  34272. get _lodTextureLow(): Nullable<BaseTexture>;
  34273. /**
  34274. * Dispose the texture and release its associated resources.
  34275. */
  34276. dispose(): void;
  34277. /**
  34278. * Serialize the texture into a JSON representation that can be parsed later on.
  34279. * @returns the JSON representation of the texture
  34280. */
  34281. serialize(): any;
  34282. /**
  34283. * Helper function to be called back once a list of texture contains only ready textures.
  34284. * @param textures Define the list of textures to wait for
  34285. * @param callback Define the callback triggered once the entire list will be ready
  34286. */
  34287. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34288. private static _isScene;
  34289. }
  34290. }
  34291. declare module BABYLON {
  34292. /**
  34293. * Options to be used when creating an effect.
  34294. */
  34295. export interface IEffectCreationOptions {
  34296. /**
  34297. * Atrributes that will be used in the shader.
  34298. */
  34299. attributes: string[];
  34300. /**
  34301. * Uniform varible names that will be set in the shader.
  34302. */
  34303. uniformsNames: string[];
  34304. /**
  34305. * Uniform buffer variable names that will be set in the shader.
  34306. */
  34307. uniformBuffersNames: string[];
  34308. /**
  34309. * Sampler texture variable names that will be set in the shader.
  34310. */
  34311. samplers: string[];
  34312. /**
  34313. * Define statements that will be set in the shader.
  34314. */
  34315. defines: any;
  34316. /**
  34317. * Possible fallbacks for this effect to improve performance when needed.
  34318. */
  34319. fallbacks: Nullable<IEffectFallbacks>;
  34320. /**
  34321. * Callback that will be called when the shader is compiled.
  34322. */
  34323. onCompiled: Nullable<(effect: Effect) => void>;
  34324. /**
  34325. * Callback that will be called if an error occurs during shader compilation.
  34326. */
  34327. onError: Nullable<(effect: Effect, errors: string) => void>;
  34328. /**
  34329. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34330. */
  34331. indexParameters?: any;
  34332. /**
  34333. * Max number of lights that can be used in the shader.
  34334. */
  34335. maxSimultaneousLights?: number;
  34336. /**
  34337. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34338. */
  34339. transformFeedbackVaryings?: Nullable<string[]>;
  34340. /**
  34341. * 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
  34342. */
  34343. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34344. /**
  34345. * Is this effect rendering to several color attachments ?
  34346. */
  34347. multiTarget?: boolean;
  34348. }
  34349. /**
  34350. * Effect containing vertex and fragment shader that can be executed on an object.
  34351. */
  34352. export class Effect implements IDisposable {
  34353. /**
  34354. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34355. */
  34356. static ShadersRepository: string;
  34357. /**
  34358. * Enable logging of the shader code when a compilation error occurs
  34359. */
  34360. static LogShaderCodeOnCompilationError: boolean;
  34361. /**
  34362. * Name of the effect.
  34363. */
  34364. name: any;
  34365. /**
  34366. * String container all the define statements that should be set on the shader.
  34367. */
  34368. defines: string;
  34369. /**
  34370. * Callback that will be called when the shader is compiled.
  34371. */
  34372. onCompiled: Nullable<(effect: Effect) => void>;
  34373. /**
  34374. * Callback that will be called if an error occurs during shader compilation.
  34375. */
  34376. onError: Nullable<(effect: Effect, errors: string) => void>;
  34377. /**
  34378. * Callback that will be called when effect is bound.
  34379. */
  34380. onBind: Nullable<(effect: Effect) => void>;
  34381. /**
  34382. * Unique ID of the effect.
  34383. */
  34384. uniqueId: number;
  34385. /**
  34386. * Observable that will be called when the shader is compiled.
  34387. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34388. */
  34389. onCompileObservable: Observable<Effect>;
  34390. /**
  34391. * Observable that will be called if an error occurs during shader compilation.
  34392. */
  34393. onErrorObservable: Observable<Effect>;
  34394. /** @hidden */
  34395. _onBindObservable: Nullable<Observable<Effect>>;
  34396. /**
  34397. * @hidden
  34398. * Specifies if the effect was previously ready
  34399. */
  34400. _wasPreviouslyReady: boolean;
  34401. /**
  34402. * Observable that will be called when effect is bound.
  34403. */
  34404. get onBindObservable(): Observable<Effect>;
  34405. /** @hidden */
  34406. _bonesComputationForcedToCPU: boolean;
  34407. /** @hidden */
  34408. _multiTarget: boolean;
  34409. private static _uniqueIdSeed;
  34410. private _engine;
  34411. private _uniformBuffersNames;
  34412. private _uniformBuffersNamesList;
  34413. private _uniformsNames;
  34414. private _samplerList;
  34415. private _samplers;
  34416. private _isReady;
  34417. private _compilationError;
  34418. private _allFallbacksProcessed;
  34419. private _attributesNames;
  34420. private _attributes;
  34421. private _attributeLocationByName;
  34422. private _uniforms;
  34423. /**
  34424. * Key for the effect.
  34425. * @hidden
  34426. */
  34427. _key: string;
  34428. private _indexParameters;
  34429. private _fallbacks;
  34430. private _vertexSourceCode;
  34431. private _fragmentSourceCode;
  34432. private _vertexSourceCodeOverride;
  34433. private _fragmentSourceCodeOverride;
  34434. private _transformFeedbackVaryings;
  34435. /**
  34436. * Compiled shader to webGL program.
  34437. * @hidden
  34438. */
  34439. _pipelineContext: Nullable<IPipelineContext>;
  34440. private _valueCache;
  34441. private static _baseCache;
  34442. /**
  34443. * Instantiates an effect.
  34444. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34445. * @param baseName Name of the effect.
  34446. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34447. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34448. * @param samplers List of sampler variables that will be passed to the shader.
  34449. * @param engine Engine to be used to render the effect
  34450. * @param defines Define statements to be added to the shader.
  34451. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34452. * @param onCompiled Callback that will be called when the shader is compiled.
  34453. * @param onError Callback that will be called if an error occurs during shader compilation.
  34454. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34455. */
  34456. 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);
  34457. private _useFinalCode;
  34458. /**
  34459. * Unique key for this effect
  34460. */
  34461. get key(): string;
  34462. /**
  34463. * If the effect has been compiled and prepared.
  34464. * @returns if the effect is compiled and prepared.
  34465. */
  34466. isReady(): boolean;
  34467. private _isReadyInternal;
  34468. /**
  34469. * The engine the effect was initialized with.
  34470. * @returns the engine.
  34471. */
  34472. getEngine(): Engine;
  34473. /**
  34474. * The pipeline context for this effect
  34475. * @returns the associated pipeline context
  34476. */
  34477. getPipelineContext(): Nullable<IPipelineContext>;
  34478. /**
  34479. * The set of names of attribute variables for the shader.
  34480. * @returns An array of attribute names.
  34481. */
  34482. getAttributesNames(): string[];
  34483. /**
  34484. * Returns the attribute at the given index.
  34485. * @param index The index of the attribute.
  34486. * @returns The location of the attribute.
  34487. */
  34488. getAttributeLocation(index: number): number;
  34489. /**
  34490. * Returns the attribute based on the name of the variable.
  34491. * @param name of the attribute to look up.
  34492. * @returns the attribute location.
  34493. */
  34494. getAttributeLocationByName(name: string): number;
  34495. /**
  34496. * The number of attributes.
  34497. * @returns the numnber of attributes.
  34498. */
  34499. getAttributesCount(): number;
  34500. /**
  34501. * Gets the index of a uniform variable.
  34502. * @param uniformName of the uniform to look up.
  34503. * @returns the index.
  34504. */
  34505. getUniformIndex(uniformName: string): number;
  34506. /**
  34507. * Returns the attribute based on the name of the variable.
  34508. * @param uniformName of the uniform to look up.
  34509. * @returns the location of the uniform.
  34510. */
  34511. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34512. /**
  34513. * Returns an array of sampler variable names
  34514. * @returns The array of sampler variable names.
  34515. */
  34516. getSamplers(): string[];
  34517. /**
  34518. * Returns an array of uniform variable names
  34519. * @returns The array of uniform variable names.
  34520. */
  34521. getUniformNames(): string[];
  34522. /**
  34523. * Returns an array of uniform buffer variable names
  34524. * @returns The array of uniform buffer variable names.
  34525. */
  34526. getUniformBuffersNames(): string[];
  34527. /**
  34528. * Returns the index parameters used to create the effect
  34529. * @returns The index parameters object
  34530. */
  34531. getIndexParameters(): any;
  34532. /**
  34533. * The error from the last compilation.
  34534. * @returns the error string.
  34535. */
  34536. getCompilationError(): string;
  34537. /**
  34538. * Gets a boolean indicating that all fallbacks were used during compilation
  34539. * @returns true if all fallbacks were used
  34540. */
  34541. allFallbacksProcessed(): boolean;
  34542. /**
  34543. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34544. * @param func The callback to be used.
  34545. */
  34546. executeWhenCompiled(func: (effect: Effect) => void): void;
  34547. private _checkIsReady;
  34548. private _loadShader;
  34549. /**
  34550. * Gets the vertex shader source code of this effect
  34551. */
  34552. get vertexSourceCode(): string;
  34553. /**
  34554. * Gets the fragment shader source code of this effect
  34555. */
  34556. get fragmentSourceCode(): string;
  34557. /**
  34558. * Recompiles the webGL program
  34559. * @param vertexSourceCode The source code for the vertex shader.
  34560. * @param fragmentSourceCode The source code for the fragment shader.
  34561. * @param onCompiled Callback called when completed.
  34562. * @param onError Callback called on error.
  34563. * @hidden
  34564. */
  34565. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34566. /**
  34567. * Prepares the effect
  34568. * @hidden
  34569. */
  34570. _prepareEffect(): void;
  34571. private _getShaderCodeAndErrorLine;
  34572. private _processCompilationErrors;
  34573. /**
  34574. * Checks if the effect is supported. (Must be called after compilation)
  34575. */
  34576. get isSupported(): boolean;
  34577. /**
  34578. * Binds a texture to the engine to be used as output of the shader.
  34579. * @param channel Name of the output variable.
  34580. * @param texture Texture to bind.
  34581. * @hidden
  34582. */
  34583. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34584. /**
  34585. * Sets a texture on the engine to be used in the shader.
  34586. * @param channel Name of the sampler variable.
  34587. * @param texture Texture to set.
  34588. */
  34589. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34590. /**
  34591. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34592. * @param channel Name of the sampler variable.
  34593. * @param texture Texture to set.
  34594. */
  34595. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34596. /**
  34597. * Sets an array of textures on the engine to be used in the shader.
  34598. * @param channel Name of the variable.
  34599. * @param textures Textures to set.
  34600. */
  34601. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34602. /**
  34603. * 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)
  34604. * @param channel Name of the sampler variable.
  34605. * @param postProcess Post process to get the input texture from.
  34606. */
  34607. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34608. /**
  34609. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34610. * 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)
  34611. * @param channel Name of the sampler variable.
  34612. * @param postProcess Post process to get the output texture from.
  34613. */
  34614. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34615. /** @hidden */
  34616. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34617. /** @hidden */
  34618. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34619. /** @hidden */
  34620. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34621. /** @hidden */
  34622. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34623. /**
  34624. * Binds a buffer to a uniform.
  34625. * @param buffer Buffer to bind.
  34626. * @param name Name of the uniform variable to bind to.
  34627. */
  34628. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34629. /**
  34630. * Binds block to a uniform.
  34631. * @param blockName Name of the block to bind.
  34632. * @param index Index to bind.
  34633. */
  34634. bindUniformBlock(blockName: string, index: number): void;
  34635. /**
  34636. * Sets an interger value on a uniform variable.
  34637. * @param uniformName Name of the variable.
  34638. * @param value Value to be set.
  34639. * @returns this effect.
  34640. */
  34641. setInt(uniformName: string, value: number): Effect;
  34642. /**
  34643. * Sets an int array on a uniform variable.
  34644. * @param uniformName Name of the variable.
  34645. * @param array array to be set.
  34646. * @returns this effect.
  34647. */
  34648. setIntArray(uniformName: string, array: Int32Array): Effect;
  34649. /**
  34650. * 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)
  34651. * @param uniformName Name of the variable.
  34652. * @param array array to be set.
  34653. * @returns this effect.
  34654. */
  34655. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34656. /**
  34657. * 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)
  34658. * @param uniformName Name of the variable.
  34659. * @param array array to be set.
  34660. * @returns this effect.
  34661. */
  34662. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34663. /**
  34664. * 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)
  34665. * @param uniformName Name of the variable.
  34666. * @param array array to be set.
  34667. * @returns this effect.
  34668. */
  34669. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34670. /**
  34671. * Sets an float array on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param array array to be set.
  34674. * @returns this effect.
  34675. */
  34676. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34677. /**
  34678. * 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)
  34679. * @param uniformName Name of the variable.
  34680. * @param array array to be set.
  34681. * @returns this effect.
  34682. */
  34683. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34684. /**
  34685. * 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)
  34686. * @param uniformName Name of the variable.
  34687. * @param array array to be set.
  34688. * @returns this effect.
  34689. */
  34690. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34691. /**
  34692. * 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)
  34693. * @param uniformName Name of the variable.
  34694. * @param array array to be set.
  34695. * @returns this effect.
  34696. */
  34697. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34698. /**
  34699. * Sets an array on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param array array to be set.
  34702. * @returns this effect.
  34703. */
  34704. setArray(uniformName: string, array: number[]): Effect;
  34705. /**
  34706. * 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)
  34707. * @param uniformName Name of the variable.
  34708. * @param array array to be set.
  34709. * @returns this effect.
  34710. */
  34711. setArray2(uniformName: string, array: number[]): Effect;
  34712. /**
  34713. * 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)
  34714. * @param uniformName Name of the variable.
  34715. * @param array array to be set.
  34716. * @returns this effect.
  34717. */
  34718. setArray3(uniformName: string, array: number[]): Effect;
  34719. /**
  34720. * 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)
  34721. * @param uniformName Name of the variable.
  34722. * @param array array to be set.
  34723. * @returns this effect.
  34724. */
  34725. setArray4(uniformName: string, array: number[]): Effect;
  34726. /**
  34727. * Sets matrices on a uniform variable.
  34728. * @param uniformName Name of the variable.
  34729. * @param matrices matrices to be set.
  34730. * @returns this effect.
  34731. */
  34732. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34733. /**
  34734. * Sets matrix on a uniform variable.
  34735. * @param uniformName Name of the variable.
  34736. * @param matrix matrix to be set.
  34737. * @returns this effect.
  34738. */
  34739. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34740. /**
  34741. * 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)
  34742. * @param uniformName Name of the variable.
  34743. * @param matrix matrix to be set.
  34744. * @returns this effect.
  34745. */
  34746. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34747. /**
  34748. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34749. * @param uniformName Name of the variable.
  34750. * @param matrix matrix to be set.
  34751. * @returns this effect.
  34752. */
  34753. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34754. /**
  34755. * Sets a float on a uniform variable.
  34756. * @param uniformName Name of the variable.
  34757. * @param value value to be set.
  34758. * @returns this effect.
  34759. */
  34760. setFloat(uniformName: string, value: number): Effect;
  34761. /**
  34762. * Sets a boolean on a uniform variable.
  34763. * @param uniformName Name of the variable.
  34764. * @param bool value to be set.
  34765. * @returns this effect.
  34766. */
  34767. setBool(uniformName: string, bool: boolean): Effect;
  34768. /**
  34769. * Sets a Vector2 on a uniform variable.
  34770. * @param uniformName Name of the variable.
  34771. * @param vector2 vector2 to be set.
  34772. * @returns this effect.
  34773. */
  34774. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34775. /**
  34776. * Sets a float2 on a uniform variable.
  34777. * @param uniformName Name of the variable.
  34778. * @param x First float in float2.
  34779. * @param y Second float in float2.
  34780. * @returns this effect.
  34781. */
  34782. setFloat2(uniformName: string, x: number, y: number): Effect;
  34783. /**
  34784. * Sets a Vector3 on a uniform variable.
  34785. * @param uniformName Name of the variable.
  34786. * @param vector3 Value to be set.
  34787. * @returns this effect.
  34788. */
  34789. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34790. /**
  34791. * Sets a float3 on a uniform variable.
  34792. * @param uniformName Name of the variable.
  34793. * @param x First float in float3.
  34794. * @param y Second float in float3.
  34795. * @param z Third float in float3.
  34796. * @returns this effect.
  34797. */
  34798. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34799. /**
  34800. * Sets a Vector4 on a uniform variable.
  34801. * @param uniformName Name of the variable.
  34802. * @param vector4 Value to be set.
  34803. * @returns this effect.
  34804. */
  34805. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34806. /**
  34807. * Sets a float4 on a uniform variable.
  34808. * @param uniformName Name of the variable.
  34809. * @param x First float in float4.
  34810. * @param y Second float in float4.
  34811. * @param z Third float in float4.
  34812. * @param w Fourth float in float4.
  34813. * @returns this effect.
  34814. */
  34815. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34816. /**
  34817. * Sets a Color3 on a uniform variable.
  34818. * @param uniformName Name of the variable.
  34819. * @param color3 Value to be set.
  34820. * @returns this effect.
  34821. */
  34822. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34823. /**
  34824. * Sets a Color4 on a uniform variable.
  34825. * @param uniformName Name of the variable.
  34826. * @param color3 Value to be set.
  34827. * @param alpha Alpha value to be set.
  34828. * @returns this effect.
  34829. */
  34830. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34831. /**
  34832. * Sets a Color4 on a uniform variable
  34833. * @param uniformName defines the name of the variable
  34834. * @param color4 defines the value to be set
  34835. * @returns this effect.
  34836. */
  34837. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34838. /** Release all associated resources */
  34839. dispose(): void;
  34840. /**
  34841. * This function will add a new shader to the shader store
  34842. * @param name the name of the shader
  34843. * @param pixelShader optional pixel shader content
  34844. * @param vertexShader optional vertex shader content
  34845. */
  34846. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34847. /**
  34848. * Store of each shader (The can be looked up using effect.key)
  34849. */
  34850. static ShadersStore: {
  34851. [key: string]: string;
  34852. };
  34853. /**
  34854. * Store of each included file for a shader (The can be looked up using effect.key)
  34855. */
  34856. static IncludesShadersStore: {
  34857. [key: string]: string;
  34858. };
  34859. /**
  34860. * Resets the cache of effects.
  34861. */
  34862. static ResetCache(): void;
  34863. }
  34864. }
  34865. declare module BABYLON {
  34866. /**
  34867. * Interface used to describe the capabilities of the engine relatively to the current browser
  34868. */
  34869. export interface EngineCapabilities {
  34870. /** Maximum textures units per fragment shader */
  34871. maxTexturesImageUnits: number;
  34872. /** Maximum texture units per vertex shader */
  34873. maxVertexTextureImageUnits: number;
  34874. /** Maximum textures units in the entire pipeline */
  34875. maxCombinedTexturesImageUnits: number;
  34876. /** Maximum texture size */
  34877. maxTextureSize: number;
  34878. /** Maximum texture samples */
  34879. maxSamples?: number;
  34880. /** Maximum cube texture size */
  34881. maxCubemapTextureSize: number;
  34882. /** Maximum render texture size */
  34883. maxRenderTextureSize: number;
  34884. /** Maximum number of vertex attributes */
  34885. maxVertexAttribs: number;
  34886. /** Maximum number of varyings */
  34887. maxVaryingVectors: number;
  34888. /** Maximum number of uniforms per vertex shader */
  34889. maxVertexUniformVectors: number;
  34890. /** Maximum number of uniforms per fragment shader */
  34891. maxFragmentUniformVectors: number;
  34892. /** Defines if standard derivates (dx/dy) are supported */
  34893. standardDerivatives: boolean;
  34894. /** Defines if s3tc texture compression is supported */
  34895. s3tc?: WEBGL_compressed_texture_s3tc;
  34896. /** Defines if pvrtc texture compression is supported */
  34897. pvrtc: any;
  34898. /** Defines if etc1 texture compression is supported */
  34899. etc1: any;
  34900. /** Defines if etc2 texture compression is supported */
  34901. etc2: any;
  34902. /** Defines if astc texture compression is supported */
  34903. astc: any;
  34904. /** Defines if bptc texture compression is supported */
  34905. bptc: any;
  34906. /** Defines if float textures are supported */
  34907. textureFloat: boolean;
  34908. /** Defines if vertex array objects are supported */
  34909. vertexArrayObject: boolean;
  34910. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34911. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34912. /** Gets the maximum level of anisotropy supported */
  34913. maxAnisotropy: number;
  34914. /** Defines if instancing is supported */
  34915. instancedArrays: boolean;
  34916. /** Defines if 32 bits indices are supported */
  34917. uintIndices: boolean;
  34918. /** Defines if high precision shaders are supported */
  34919. highPrecisionShaderSupported: boolean;
  34920. /** Defines if depth reading in the fragment shader is supported */
  34921. fragmentDepthSupported: boolean;
  34922. /** Defines if float texture linear filtering is supported*/
  34923. textureFloatLinearFiltering: boolean;
  34924. /** Defines if rendering to float textures is supported */
  34925. textureFloatRender: boolean;
  34926. /** Defines if half float textures are supported*/
  34927. textureHalfFloat: boolean;
  34928. /** Defines if half float texture linear filtering is supported*/
  34929. textureHalfFloatLinearFiltering: boolean;
  34930. /** Defines if rendering to half float textures is supported */
  34931. textureHalfFloatRender: boolean;
  34932. /** Defines if textureLOD shader command is supported */
  34933. textureLOD: boolean;
  34934. /** Defines if draw buffers extension is supported */
  34935. drawBuffersExtension: boolean;
  34936. /** Defines if depth textures are supported */
  34937. depthTextureExtension: boolean;
  34938. /** Defines if float color buffer are supported */
  34939. colorBufferFloat: boolean;
  34940. /** Gets disjoint timer query extension (null if not supported) */
  34941. timerQuery?: EXT_disjoint_timer_query;
  34942. /** Defines if timestamp can be used with timer query */
  34943. canUseTimestampForTimerQuery: boolean;
  34944. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34945. multiview?: any;
  34946. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34947. oculusMultiview?: any;
  34948. /** Function used to let the system compiles shaders in background */
  34949. parallelShaderCompile?: {
  34950. COMPLETION_STATUS_KHR: number;
  34951. };
  34952. /** Max number of texture samples for MSAA */
  34953. maxMSAASamples: number;
  34954. /** Defines if the blend min max extension is supported */
  34955. blendMinMax: boolean;
  34956. }
  34957. }
  34958. declare module BABYLON {
  34959. /**
  34960. * @hidden
  34961. **/
  34962. export class DepthCullingState {
  34963. private _isDepthTestDirty;
  34964. private _isDepthMaskDirty;
  34965. private _isDepthFuncDirty;
  34966. private _isCullFaceDirty;
  34967. private _isCullDirty;
  34968. private _isZOffsetDirty;
  34969. private _isFrontFaceDirty;
  34970. private _depthTest;
  34971. private _depthMask;
  34972. private _depthFunc;
  34973. private _cull;
  34974. private _cullFace;
  34975. private _zOffset;
  34976. private _frontFace;
  34977. /**
  34978. * Initializes the state.
  34979. */
  34980. constructor();
  34981. get isDirty(): boolean;
  34982. get zOffset(): number;
  34983. set zOffset(value: number);
  34984. get cullFace(): Nullable<number>;
  34985. set cullFace(value: Nullable<number>);
  34986. get cull(): Nullable<boolean>;
  34987. set cull(value: Nullable<boolean>);
  34988. get depthFunc(): Nullable<number>;
  34989. set depthFunc(value: Nullable<number>);
  34990. get depthMask(): boolean;
  34991. set depthMask(value: boolean);
  34992. get depthTest(): boolean;
  34993. set depthTest(value: boolean);
  34994. get frontFace(): Nullable<number>;
  34995. set frontFace(value: Nullable<number>);
  34996. reset(): void;
  34997. apply(gl: WebGLRenderingContext): void;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * @hidden
  35003. **/
  35004. export class StencilState {
  35005. /** 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 */
  35006. static readonly ALWAYS: number;
  35007. /** Passed to stencilOperation to specify that stencil value must be kept */
  35008. static readonly KEEP: number;
  35009. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35010. static readonly REPLACE: number;
  35011. private _isStencilTestDirty;
  35012. private _isStencilMaskDirty;
  35013. private _isStencilFuncDirty;
  35014. private _isStencilOpDirty;
  35015. private _stencilTest;
  35016. private _stencilMask;
  35017. private _stencilFunc;
  35018. private _stencilFuncRef;
  35019. private _stencilFuncMask;
  35020. private _stencilOpStencilFail;
  35021. private _stencilOpDepthFail;
  35022. private _stencilOpStencilDepthPass;
  35023. get isDirty(): boolean;
  35024. get stencilFunc(): number;
  35025. set stencilFunc(value: number);
  35026. get stencilFuncRef(): number;
  35027. set stencilFuncRef(value: number);
  35028. get stencilFuncMask(): number;
  35029. set stencilFuncMask(value: number);
  35030. get stencilOpStencilFail(): number;
  35031. set stencilOpStencilFail(value: number);
  35032. get stencilOpDepthFail(): number;
  35033. set stencilOpDepthFail(value: number);
  35034. get stencilOpStencilDepthPass(): number;
  35035. set stencilOpStencilDepthPass(value: number);
  35036. get stencilMask(): number;
  35037. set stencilMask(value: number);
  35038. get stencilTest(): boolean;
  35039. set stencilTest(value: boolean);
  35040. constructor();
  35041. reset(): void;
  35042. apply(gl: WebGLRenderingContext): void;
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * @hidden
  35048. **/
  35049. export class AlphaState {
  35050. private _isAlphaBlendDirty;
  35051. private _isBlendFunctionParametersDirty;
  35052. private _isBlendEquationParametersDirty;
  35053. private _isBlendConstantsDirty;
  35054. private _alphaBlend;
  35055. private _blendFunctionParameters;
  35056. private _blendEquationParameters;
  35057. private _blendConstants;
  35058. /**
  35059. * Initializes the state.
  35060. */
  35061. constructor();
  35062. get isDirty(): boolean;
  35063. get alphaBlend(): boolean;
  35064. set alphaBlend(value: boolean);
  35065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35068. reset(): void;
  35069. apply(gl: WebGLRenderingContext): void;
  35070. }
  35071. }
  35072. declare module BABYLON {
  35073. /** @hidden */
  35074. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35075. attributeProcessor(attribute: string): string;
  35076. varyingProcessor(varying: string, isFragment: boolean): string;
  35077. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35078. }
  35079. }
  35080. declare module BABYLON {
  35081. /**
  35082. * Interface for attribute information associated with buffer instanciation
  35083. */
  35084. export interface InstancingAttributeInfo {
  35085. /**
  35086. * Name of the GLSL attribute
  35087. * if attribute index is not specified, this is used to retrieve the index from the effect
  35088. */
  35089. attributeName: string;
  35090. /**
  35091. * Index/offset of the attribute in the vertex shader
  35092. * if not specified, this will be computes from the name.
  35093. */
  35094. index?: number;
  35095. /**
  35096. * size of the attribute, 1, 2, 3 or 4
  35097. */
  35098. attributeSize: number;
  35099. /**
  35100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35101. */
  35102. offset: number;
  35103. /**
  35104. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35105. * default to 1
  35106. */
  35107. divisor?: number;
  35108. /**
  35109. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35110. * default is FLOAT
  35111. */
  35112. attributeType?: number;
  35113. /**
  35114. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35115. */
  35116. normalized?: boolean;
  35117. }
  35118. }
  35119. declare module BABYLON {
  35120. interface ThinEngine {
  35121. /**
  35122. * Update a video texture
  35123. * @param texture defines the texture to update
  35124. * @param video defines the video element to use
  35125. * @param invertY defines if data must be stored with Y axis inverted
  35126. */
  35127. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35128. }
  35129. }
  35130. declare module BABYLON {
  35131. interface ThinEngine {
  35132. /**
  35133. * Creates a dynamic texture
  35134. * @param width defines the width of the texture
  35135. * @param height defines the height of the texture
  35136. * @param generateMipMaps defines if the engine should generate the mip levels
  35137. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35138. * @returns the dynamic texture inside an InternalTexture
  35139. */
  35140. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35141. /**
  35142. * Update the content of a dynamic texture
  35143. * @param texture defines the texture to update
  35144. * @param canvas defines the canvas containing the source
  35145. * @param invertY defines if data must be stored with Y axis inverted
  35146. * @param premulAlpha defines if alpha is stored as premultiplied
  35147. * @param format defines the format of the data
  35148. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35149. */
  35150. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35151. }
  35152. }
  35153. declare module BABYLON {
  35154. /**
  35155. * Settings for finer control over video usage
  35156. */
  35157. export interface VideoTextureSettings {
  35158. /**
  35159. * Applies `autoplay` to video, if specified
  35160. */
  35161. autoPlay?: boolean;
  35162. /**
  35163. * Applies `loop` to video, if specified
  35164. */
  35165. loop?: boolean;
  35166. /**
  35167. * Automatically updates internal texture from video at every frame in the render loop
  35168. */
  35169. autoUpdateTexture: boolean;
  35170. /**
  35171. * Image src displayed during the video loading or until the user interacts with the video.
  35172. */
  35173. poster?: string;
  35174. }
  35175. /**
  35176. * If you want to display a video in your scene, this is the special texture for that.
  35177. * This special texture works similar to other textures, with the exception of a few parameters.
  35178. * @see https://doc.babylonjs.com/how_to/video_texture
  35179. */
  35180. export class VideoTexture extends Texture {
  35181. /**
  35182. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35183. */
  35184. readonly autoUpdateTexture: boolean;
  35185. /**
  35186. * The video instance used by the texture internally
  35187. */
  35188. readonly video: HTMLVideoElement;
  35189. private _onUserActionRequestedObservable;
  35190. /**
  35191. * Event triggerd when a dom action is required by the user to play the video.
  35192. * This happens due to recent changes in browser policies preventing video to auto start.
  35193. */
  35194. get onUserActionRequestedObservable(): Observable<Texture>;
  35195. private _generateMipMaps;
  35196. private _stillImageCaptured;
  35197. private _displayingPosterTexture;
  35198. private _settings;
  35199. private _createInternalTextureOnEvent;
  35200. private _frameId;
  35201. private _currentSrc;
  35202. /**
  35203. * Creates a video texture.
  35204. * If you want to display a video in your scene, this is the special texture for that.
  35205. * This special texture works similar to other textures, with the exception of a few parameters.
  35206. * @see https://doc.babylonjs.com/how_to/video_texture
  35207. * @param name optional name, will detect from video source, if not defined
  35208. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35209. * @param scene is obviously the current scene.
  35210. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35211. * @param invertY is false by default but can be used to invert video on Y axis
  35212. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35213. * @param settings allows finer control over video usage
  35214. */
  35215. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35216. private _getName;
  35217. private _getVideo;
  35218. private _createInternalTexture;
  35219. private reset;
  35220. /**
  35221. * @hidden Internal method to initiate `update`.
  35222. */
  35223. _rebuild(): void;
  35224. /**
  35225. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35226. */
  35227. update(): void;
  35228. /**
  35229. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35230. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35231. */
  35232. updateTexture(isVisible: boolean): void;
  35233. protected _updateInternalTexture: () => void;
  35234. /**
  35235. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35236. * @param url New url.
  35237. */
  35238. updateURL(url: string): void;
  35239. /**
  35240. * Clones the texture.
  35241. * @returns the cloned texture
  35242. */
  35243. clone(): VideoTexture;
  35244. /**
  35245. * Dispose the texture and release its associated resources.
  35246. */
  35247. dispose(): void;
  35248. /**
  35249. * Creates a video texture straight from a stream.
  35250. * @param scene Define the scene the texture should be created in
  35251. * @param stream Define the stream the texture should be created from
  35252. * @returns The created video texture as a promise
  35253. */
  35254. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35255. /**
  35256. * Creates a video texture straight from your WebCam video feed.
  35257. * @param scene Define the scene the texture should be created in
  35258. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35259. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35260. * @returns The created video texture as a promise
  35261. */
  35262. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35263. minWidth: number;
  35264. maxWidth: number;
  35265. minHeight: number;
  35266. maxHeight: number;
  35267. deviceId: string;
  35268. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35269. /**
  35270. * Creates a video texture straight from your WebCam video feed.
  35271. * @param scene Define the scene the texture should be created in
  35272. * @param onReady Define a callback to triggered once the texture will be ready
  35273. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35274. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35275. */
  35276. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35277. minWidth: number;
  35278. maxWidth: number;
  35279. minHeight: number;
  35280. maxHeight: number;
  35281. deviceId: string;
  35282. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * Defines the interface used by objects working like Scene
  35288. * @hidden
  35289. */
  35290. export interface ISceneLike {
  35291. _addPendingData(data: any): void;
  35292. _removePendingData(data: any): void;
  35293. offlineProvider: IOfflineProvider;
  35294. }
  35295. /**
  35296. * Information about the current host
  35297. */
  35298. export interface HostInformation {
  35299. /**
  35300. * Defines if the current host is a mobile
  35301. */
  35302. isMobile: boolean;
  35303. }
  35304. /** Interface defining initialization parameters for Engine class */
  35305. export interface EngineOptions extends WebGLContextAttributes {
  35306. /**
  35307. * Defines if the engine should no exceed a specified device ratio
  35308. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35309. */
  35310. limitDeviceRatio?: number;
  35311. /**
  35312. * Defines if webvr should be enabled automatically
  35313. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35314. */
  35315. autoEnableWebVR?: boolean;
  35316. /**
  35317. * Defines if webgl2 should be turned off even if supported
  35318. * @see https://doc.babylonjs.com/features/webgl2
  35319. */
  35320. disableWebGL2Support?: boolean;
  35321. /**
  35322. * Defines if webaudio should be initialized as well
  35323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35324. */
  35325. audioEngine?: boolean;
  35326. /**
  35327. * Defines if animations should run using a deterministic lock step
  35328. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35329. */
  35330. deterministicLockstep?: boolean;
  35331. /** Defines the maximum steps to use with deterministic lock step mode */
  35332. lockstepMaxSteps?: number;
  35333. /** Defines the seconds between each deterministic lock step */
  35334. timeStep?: number;
  35335. /**
  35336. * Defines that engine should ignore context lost events
  35337. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35338. */
  35339. doNotHandleContextLost?: boolean;
  35340. /**
  35341. * Defines that engine should ignore modifying touch action attribute and style
  35342. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35343. */
  35344. doNotHandleTouchAction?: boolean;
  35345. /**
  35346. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35347. */
  35348. useHighPrecisionFloats?: boolean;
  35349. /**
  35350. * Make the canvas XR Compatible for XR sessions
  35351. */
  35352. xrCompatible?: boolean;
  35353. /**
  35354. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35355. */
  35356. useHighPrecisionMatrix?: boolean;
  35357. /**
  35358. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  35359. */
  35360. failIfMajorPerformanceCaveat?: boolean;
  35361. }
  35362. /**
  35363. * The base engine class (root of all engines)
  35364. */
  35365. export class ThinEngine {
  35366. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35367. static ExceptionList: ({
  35368. key: string;
  35369. capture: string;
  35370. captureConstraint: number;
  35371. targets: string[];
  35372. } | {
  35373. key: string;
  35374. capture: null;
  35375. captureConstraint: null;
  35376. targets: string[];
  35377. })[];
  35378. /** @hidden */
  35379. static _TextureLoaders: IInternalTextureLoader[];
  35380. /**
  35381. * Returns the current npm package of the sdk
  35382. */
  35383. static get NpmPackage(): string;
  35384. /**
  35385. * Returns the current version of the framework
  35386. */
  35387. static get Version(): string;
  35388. /**
  35389. * Returns a string describing the current engine
  35390. */
  35391. get description(): string;
  35392. /**
  35393. * Gets or sets the epsilon value used by collision engine
  35394. */
  35395. static CollisionsEpsilon: number;
  35396. /**
  35397. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35398. */
  35399. static get ShadersRepository(): string;
  35400. static set ShadersRepository(value: string);
  35401. /** @hidden */
  35402. _shaderProcessor: IShaderProcessor;
  35403. /**
  35404. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35405. */
  35406. forcePOTTextures: boolean;
  35407. /**
  35408. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35409. */
  35410. isFullscreen: boolean;
  35411. /**
  35412. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35413. */
  35414. cullBackFaces: boolean;
  35415. /**
  35416. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35417. */
  35418. renderEvenInBackground: boolean;
  35419. /**
  35420. * Gets or sets a boolean indicating that cache can be kept between frames
  35421. */
  35422. preventCacheWipeBetweenFrames: boolean;
  35423. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35424. validateShaderPrograms: boolean;
  35425. /**
  35426. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35427. * This can provide greater z depth for distant objects.
  35428. */
  35429. useReverseDepthBuffer: boolean;
  35430. /**
  35431. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35432. */
  35433. disableUniformBuffers: boolean;
  35434. /** @hidden */
  35435. _uniformBuffers: UniformBuffer[];
  35436. /**
  35437. * Gets a boolean indicating that the engine supports uniform buffers
  35438. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35439. */
  35440. get supportsUniformBuffers(): boolean;
  35441. /** @hidden */
  35442. _gl: WebGLRenderingContext;
  35443. /** @hidden */
  35444. _webGLVersion: number;
  35445. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35446. protected _windowIsBackground: boolean;
  35447. protected _creationOptions: EngineOptions;
  35448. protected _highPrecisionShadersAllowed: boolean;
  35449. /** @hidden */
  35450. get _shouldUseHighPrecisionShader(): boolean;
  35451. /**
  35452. * Gets a boolean indicating that only power of 2 textures are supported
  35453. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35454. */
  35455. get needPOTTextures(): boolean;
  35456. /** @hidden */
  35457. _badOS: boolean;
  35458. /** @hidden */
  35459. _badDesktopOS: boolean;
  35460. private _hardwareScalingLevel;
  35461. /** @hidden */
  35462. _caps: EngineCapabilities;
  35463. private _isStencilEnable;
  35464. private _glVersion;
  35465. private _glRenderer;
  35466. private _glVendor;
  35467. /** @hidden */
  35468. _videoTextureSupported: boolean;
  35469. protected _renderingQueueLaunched: boolean;
  35470. protected _activeRenderLoops: (() => void)[];
  35471. /**
  35472. * Observable signaled when a context lost event is raised
  35473. */
  35474. onContextLostObservable: Observable<ThinEngine>;
  35475. /**
  35476. * Observable signaled when a context restored event is raised
  35477. */
  35478. onContextRestoredObservable: Observable<ThinEngine>;
  35479. private _onContextLost;
  35480. private _onContextRestored;
  35481. protected _contextWasLost: boolean;
  35482. /** @hidden */
  35483. _doNotHandleContextLost: boolean;
  35484. /**
  35485. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35486. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35487. */
  35488. get doNotHandleContextLost(): boolean;
  35489. set doNotHandleContextLost(value: boolean);
  35490. /**
  35491. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35492. */
  35493. disableVertexArrayObjects: boolean;
  35494. /** @hidden */
  35495. protected _colorWrite: boolean;
  35496. /** @hidden */
  35497. protected _colorWriteChanged: boolean;
  35498. /** @hidden */
  35499. protected _depthCullingState: DepthCullingState;
  35500. /** @hidden */
  35501. protected _stencilState: StencilState;
  35502. /** @hidden */
  35503. _alphaState: AlphaState;
  35504. /** @hidden */
  35505. _alphaMode: number;
  35506. /** @hidden */
  35507. _alphaEquation: number;
  35508. /** @hidden */
  35509. _internalTexturesCache: InternalTexture[];
  35510. /** @hidden */
  35511. protected _activeChannel: number;
  35512. private _currentTextureChannel;
  35513. /** @hidden */
  35514. protected _boundTexturesCache: {
  35515. [key: string]: Nullable<InternalTexture>;
  35516. };
  35517. /** @hidden */
  35518. protected _currentEffect: Nullable<Effect>;
  35519. /** @hidden */
  35520. protected _currentProgram: Nullable<WebGLProgram>;
  35521. private _compiledEffects;
  35522. private _vertexAttribArraysEnabled;
  35523. /** @hidden */
  35524. protected _cachedViewport: Nullable<IViewportLike>;
  35525. private _cachedVertexArrayObject;
  35526. /** @hidden */
  35527. protected _cachedVertexBuffers: any;
  35528. /** @hidden */
  35529. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35530. /** @hidden */
  35531. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35532. /** @hidden */
  35533. _currentRenderTarget: Nullable<InternalTexture>;
  35534. private _uintIndicesCurrentlySet;
  35535. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35536. /** @hidden */
  35537. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35538. /** @hidden */
  35539. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35540. private _currentBufferPointers;
  35541. private _currentInstanceLocations;
  35542. private _currentInstanceBuffers;
  35543. private _textureUnits;
  35544. /** @hidden */
  35545. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35546. /** @hidden */
  35547. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35548. /** @hidden */
  35549. _boundRenderFunction: any;
  35550. private _vaoRecordInProgress;
  35551. private _mustWipeVertexAttributes;
  35552. private _emptyTexture;
  35553. private _emptyCubeTexture;
  35554. private _emptyTexture3D;
  35555. private _emptyTexture2DArray;
  35556. /** @hidden */
  35557. _frameHandler: number;
  35558. private _nextFreeTextureSlots;
  35559. private _maxSimultaneousTextures;
  35560. private _activeRequests;
  35561. /** @hidden */
  35562. _transformTextureUrl: Nullable<(url: string) => string>;
  35563. /**
  35564. * Gets information about the current host
  35565. */
  35566. hostInformation: HostInformation;
  35567. protected get _supportsHardwareTextureRescaling(): boolean;
  35568. private _framebufferDimensionsObject;
  35569. /**
  35570. * sets the object from which width and height will be taken from when getting render width and height
  35571. * Will fallback to the gl object
  35572. * @param dimensions the framebuffer width and height that will be used.
  35573. */
  35574. set framebufferDimensionsObject(dimensions: Nullable<{
  35575. framebufferWidth: number;
  35576. framebufferHeight: number;
  35577. }>);
  35578. /**
  35579. * Gets the current viewport
  35580. */
  35581. get currentViewport(): Nullable<IViewportLike>;
  35582. /**
  35583. * Gets the default empty texture
  35584. */
  35585. get emptyTexture(): InternalTexture;
  35586. /**
  35587. * Gets the default empty 3D texture
  35588. */
  35589. get emptyTexture3D(): InternalTexture;
  35590. /**
  35591. * Gets the default empty 2D array texture
  35592. */
  35593. get emptyTexture2DArray(): InternalTexture;
  35594. /**
  35595. * Gets the default empty cube texture
  35596. */
  35597. get emptyCubeTexture(): InternalTexture;
  35598. /**
  35599. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35600. */
  35601. readonly premultipliedAlpha: boolean;
  35602. /**
  35603. * Observable event triggered before each texture is initialized
  35604. */
  35605. onBeforeTextureInitObservable: Observable<Texture>;
  35606. /**
  35607. * Creates a new engine
  35608. * @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
  35609. * @param antialias defines enable antialiasing (default: false)
  35610. * @param options defines further options to be sent to the getContext() function
  35611. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35612. */
  35613. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35614. private _rebuildInternalTextures;
  35615. private _rebuildEffects;
  35616. /**
  35617. * Gets a boolean indicating if all created effects are ready
  35618. * @returns true if all effects are ready
  35619. */
  35620. areAllEffectsReady(): boolean;
  35621. protected _rebuildBuffers(): void;
  35622. protected _initGLContext(): void;
  35623. /**
  35624. * Gets version of the current webGL context
  35625. */
  35626. get webGLVersion(): number;
  35627. /**
  35628. * Gets a string identifying the name of the class
  35629. * @returns "Engine" string
  35630. */
  35631. getClassName(): string;
  35632. /**
  35633. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35634. */
  35635. get isStencilEnable(): boolean;
  35636. /** @hidden */
  35637. _prepareWorkingCanvas(): void;
  35638. /**
  35639. * Reset the texture cache to empty state
  35640. */
  35641. resetTextureCache(): void;
  35642. /**
  35643. * Gets an object containing information about the current webGL context
  35644. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35645. */
  35646. getGlInfo(): {
  35647. vendor: string;
  35648. renderer: string;
  35649. version: string;
  35650. };
  35651. /**
  35652. * Defines the hardware scaling level.
  35653. * By default the hardware scaling level is computed from the window device ratio.
  35654. * 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.
  35655. * @param level defines the level to use
  35656. */
  35657. setHardwareScalingLevel(level: number): void;
  35658. /**
  35659. * Gets the current hardware scaling level.
  35660. * By default the hardware scaling level is computed from the window device ratio.
  35661. * 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.
  35662. * @returns a number indicating the current hardware scaling level
  35663. */
  35664. getHardwareScalingLevel(): number;
  35665. /**
  35666. * Gets the list of loaded textures
  35667. * @returns an array containing all loaded textures
  35668. */
  35669. getLoadedTexturesCache(): InternalTexture[];
  35670. /**
  35671. * Gets the object containing all engine capabilities
  35672. * @returns the EngineCapabilities object
  35673. */
  35674. getCaps(): EngineCapabilities;
  35675. /**
  35676. * stop executing a render loop function and remove it from the execution array
  35677. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35678. */
  35679. stopRenderLoop(renderFunction?: () => void): void;
  35680. /** @hidden */
  35681. _renderLoop(): void;
  35682. /**
  35683. * Gets the HTML canvas attached with the current webGL context
  35684. * @returns a HTML canvas
  35685. */
  35686. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35687. /**
  35688. * Gets host window
  35689. * @returns the host window object
  35690. */
  35691. getHostWindow(): Nullable<Window>;
  35692. /**
  35693. * Gets the current render width
  35694. * @param useScreen defines if screen size must be used (or the current render target if any)
  35695. * @returns a number defining the current render width
  35696. */
  35697. getRenderWidth(useScreen?: boolean): number;
  35698. /**
  35699. * Gets the current render height
  35700. * @param useScreen defines if screen size must be used (or the current render target if any)
  35701. * @returns a number defining the current render height
  35702. */
  35703. getRenderHeight(useScreen?: boolean): number;
  35704. /**
  35705. * Can be used to override the current requestAnimationFrame requester.
  35706. * @hidden
  35707. */
  35708. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35709. /**
  35710. * Register and execute a render loop. The engine can have more than one render function
  35711. * @param renderFunction defines the function to continuously execute
  35712. */
  35713. runRenderLoop(renderFunction: () => void): void;
  35714. /**
  35715. * Clear the current render buffer or the current render target (if any is set up)
  35716. * @param color defines the color to use
  35717. * @param backBuffer defines if the back buffer must be cleared
  35718. * @param depth defines if the depth buffer must be cleared
  35719. * @param stencil defines if the stencil buffer must be cleared
  35720. */
  35721. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35722. private _viewportCached;
  35723. /** @hidden */
  35724. _viewport(x: number, y: number, width: number, height: number): void;
  35725. /**
  35726. * Set the WebGL's viewport
  35727. * @param viewport defines the viewport element to be used
  35728. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35729. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35730. */
  35731. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35732. /**
  35733. * Begin a new frame
  35734. */
  35735. beginFrame(): void;
  35736. /**
  35737. * Enf the current frame
  35738. */
  35739. endFrame(): void;
  35740. /**
  35741. * Resize the view according to the canvas' size
  35742. */
  35743. resize(): void;
  35744. /**
  35745. * Force a specific size of the canvas
  35746. * @param width defines the new canvas' width
  35747. * @param height defines the new canvas' height
  35748. * @returns true if the size was changed
  35749. */
  35750. setSize(width: number, height: number): boolean;
  35751. /**
  35752. * Binds the frame buffer to the specified texture.
  35753. * @param texture The texture to render to or null for the default canvas
  35754. * @param faceIndex The face of the texture to render to in case of cube texture
  35755. * @param requiredWidth The width of the target to render to
  35756. * @param requiredHeight The height of the target to render to
  35757. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35758. * @param lodLevel defines the lod level to bind to the frame buffer
  35759. * @param layer defines the 2d array index to bind to frame buffer to
  35760. */
  35761. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35762. /** @hidden */
  35763. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35764. /**
  35765. * Unbind the current render target texture from the webGL context
  35766. * @param texture defines the render target texture to unbind
  35767. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35768. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35769. */
  35770. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35771. /**
  35772. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35773. */
  35774. flushFramebuffer(): void;
  35775. /**
  35776. * Unbind the current render target and bind the default framebuffer
  35777. */
  35778. restoreDefaultFramebuffer(): void;
  35779. /** @hidden */
  35780. protected _resetVertexBufferBinding(): void;
  35781. /**
  35782. * Creates a vertex buffer
  35783. * @param data the data for the vertex buffer
  35784. * @returns the new WebGL static buffer
  35785. */
  35786. createVertexBuffer(data: DataArray): DataBuffer;
  35787. private _createVertexBuffer;
  35788. /**
  35789. * Creates a dynamic vertex buffer
  35790. * @param data the data for the dynamic vertex buffer
  35791. * @returns the new WebGL dynamic buffer
  35792. */
  35793. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35794. protected _resetIndexBufferBinding(): void;
  35795. /**
  35796. * Creates a new index buffer
  35797. * @param indices defines the content of the index buffer
  35798. * @param updatable defines if the index buffer must be updatable
  35799. * @returns a new webGL buffer
  35800. */
  35801. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35802. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35803. /**
  35804. * Bind a webGL buffer to the webGL context
  35805. * @param buffer defines the buffer to bind
  35806. */
  35807. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35808. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35809. private bindBuffer;
  35810. /**
  35811. * update the bound buffer with the given data
  35812. * @param data defines the data to update
  35813. */
  35814. updateArrayBuffer(data: Float32Array): void;
  35815. private _vertexAttribPointer;
  35816. /** @hidden */
  35817. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35818. private _bindVertexBuffersAttributes;
  35819. /**
  35820. * Records a vertex array object
  35821. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35822. * @param vertexBuffers defines the list of vertex buffers to store
  35823. * @param indexBuffer defines the index buffer to store
  35824. * @param effect defines the effect to store
  35825. * @returns the new vertex array object
  35826. */
  35827. recordVertexArrayObject(vertexBuffers: {
  35828. [key: string]: VertexBuffer;
  35829. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35830. /**
  35831. * Bind a specific vertex array object
  35832. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35833. * @param vertexArrayObject defines the vertex array object to bind
  35834. * @param indexBuffer defines the index buffer to bind
  35835. */
  35836. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35837. /**
  35838. * Bind webGl buffers directly to the webGL context
  35839. * @param vertexBuffer defines the vertex buffer to bind
  35840. * @param indexBuffer defines the index buffer to bind
  35841. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35842. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35843. * @param effect defines the effect associated with the vertex buffer
  35844. */
  35845. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35846. private _unbindVertexArrayObject;
  35847. /**
  35848. * Bind a list of vertex buffers to the webGL context
  35849. * @param vertexBuffers defines the list of vertex buffers to bind
  35850. * @param indexBuffer defines the index buffer to bind
  35851. * @param effect defines the effect associated with the vertex buffers
  35852. */
  35853. bindBuffers(vertexBuffers: {
  35854. [key: string]: Nullable<VertexBuffer>;
  35855. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35856. /**
  35857. * Unbind all instance attributes
  35858. */
  35859. unbindInstanceAttributes(): void;
  35860. /**
  35861. * Release and free the memory of a vertex array object
  35862. * @param vao defines the vertex array object to delete
  35863. */
  35864. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35865. /** @hidden */
  35866. _releaseBuffer(buffer: DataBuffer): boolean;
  35867. protected _deleteBuffer(buffer: DataBuffer): void;
  35868. /**
  35869. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35870. * @param instancesBuffer defines the webGL buffer to update and bind
  35871. * @param data defines the data to store in the buffer
  35872. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35873. */
  35874. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35875. /**
  35876. * Bind the content of a webGL buffer used with instantiation
  35877. * @param instancesBuffer defines the webGL buffer to bind
  35878. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35879. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35880. */
  35881. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35882. /**
  35883. * Disable the instance attribute corresponding to the name in parameter
  35884. * @param name defines the name of the attribute to disable
  35885. */
  35886. disableInstanceAttributeByName(name: string): void;
  35887. /**
  35888. * Disable the instance attribute corresponding to the location in parameter
  35889. * @param attributeLocation defines the attribute location of the attribute to disable
  35890. */
  35891. disableInstanceAttribute(attributeLocation: number): void;
  35892. /**
  35893. * Disable the attribute corresponding to the location in parameter
  35894. * @param attributeLocation defines the attribute location of the attribute to disable
  35895. */
  35896. disableAttributeByIndex(attributeLocation: number): void;
  35897. /**
  35898. * Send a draw order
  35899. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35900. * @param indexStart defines the starting index
  35901. * @param indexCount defines the number of index to draw
  35902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35903. */
  35904. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35905. /**
  35906. * Draw a list of points
  35907. * @param verticesStart defines the index of first vertex to draw
  35908. * @param verticesCount defines the count of vertices to draw
  35909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35910. */
  35911. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35912. /**
  35913. * Draw a list of unindexed primitives
  35914. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35915. * @param verticesStart defines the index of first vertex to draw
  35916. * @param verticesCount defines the count of vertices to draw
  35917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35918. */
  35919. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35920. /**
  35921. * Draw a list of indexed primitives
  35922. * @param fillMode defines the primitive to use
  35923. * @param indexStart defines the starting index
  35924. * @param indexCount defines the number of index to draw
  35925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35926. */
  35927. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35928. /**
  35929. * Draw a list of unindexed primitives
  35930. * @param fillMode defines the primitive to use
  35931. * @param verticesStart defines the index of first vertex to draw
  35932. * @param verticesCount defines the count of vertices to draw
  35933. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35934. */
  35935. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35936. private _drawMode;
  35937. /** @hidden */
  35938. protected _reportDrawCall(): void;
  35939. /** @hidden */
  35940. _releaseEffect(effect: Effect): void;
  35941. /** @hidden */
  35942. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35943. /**
  35944. * Create a new effect (used to store vertex/fragment shaders)
  35945. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35946. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35947. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35948. * @param samplers defines an array of string used to represent textures
  35949. * @param defines defines the string containing the defines to use to compile the shaders
  35950. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35951. * @param onCompiled defines a function to call when the effect creation is successful
  35952. * @param onError defines a function to call when the effect creation has failed
  35953. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35954. * @returns the new Effect
  35955. */
  35956. 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;
  35957. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35958. private _compileShader;
  35959. private _compileRawShader;
  35960. /** @hidden */
  35961. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35962. /**
  35963. * Directly creates a webGL program
  35964. * @param pipelineContext defines the pipeline context to attach to
  35965. * @param vertexCode defines the vertex shader code to use
  35966. * @param fragmentCode defines the fragment shader code to use
  35967. * @param context defines the webGL context to use (if not set, the current one will be used)
  35968. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35969. * @returns the new webGL program
  35970. */
  35971. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35972. /**
  35973. * Creates a webGL program
  35974. * @param pipelineContext defines the pipeline context to attach to
  35975. * @param vertexCode defines the vertex shader code to use
  35976. * @param fragmentCode defines the fragment shader code to use
  35977. * @param defines defines the string containing the defines to use to compile the shaders
  35978. * @param context defines the webGL context to use (if not set, the current one will be used)
  35979. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35980. * @returns the new webGL program
  35981. */
  35982. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35983. /**
  35984. * Creates a new pipeline context
  35985. * @returns the new pipeline
  35986. */
  35987. createPipelineContext(): IPipelineContext;
  35988. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35989. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35990. /** @hidden */
  35991. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35992. /** @hidden */
  35993. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35994. /** @hidden */
  35995. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35996. /**
  35997. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35998. * @param pipelineContext defines the pipeline context to use
  35999. * @param uniformsNames defines the list of uniform names
  36000. * @returns an array of webGL uniform locations
  36001. */
  36002. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36003. /**
  36004. * Gets the lsit of active attributes for a given webGL program
  36005. * @param pipelineContext defines the pipeline context to use
  36006. * @param attributesNames defines the list of attribute names to get
  36007. * @returns an array of indices indicating the offset of each attribute
  36008. */
  36009. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36010. /**
  36011. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36012. * @param effect defines the effect to activate
  36013. */
  36014. enableEffect(effect: Nullable<Effect>): void;
  36015. /**
  36016. * Set the value of an uniform to a number (int)
  36017. * @param uniform defines the webGL uniform location where to store the value
  36018. * @param value defines the int number to store
  36019. * @returns true if the value was set
  36020. */
  36021. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36022. /**
  36023. * Set the value of an uniform to an array of int32
  36024. * @param uniform defines the webGL uniform location where to store the value
  36025. * @param array defines the array of int32 to store
  36026. * @returns true if the value was set
  36027. */
  36028. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36029. /**
  36030. * Set the value of an uniform to an array of int32 (stored as vec2)
  36031. * @param uniform defines the webGL uniform location where to store the value
  36032. * @param array defines the array of int32 to store
  36033. * @returns true if the value was set
  36034. */
  36035. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36036. /**
  36037. * Set the value of an uniform to an array of int32 (stored as vec3)
  36038. * @param uniform defines the webGL uniform location where to store the value
  36039. * @param array defines the array of int32 to store
  36040. * @returns true if the value was set
  36041. */
  36042. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36043. /**
  36044. * Set the value of an uniform to an array of int32 (stored as vec4)
  36045. * @param uniform defines the webGL uniform location where to store the value
  36046. * @param array defines the array of int32 to store
  36047. * @returns true if the value was set
  36048. */
  36049. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36050. /**
  36051. * Set the value of an uniform to an array of number
  36052. * @param uniform defines the webGL uniform location where to store the value
  36053. * @param array defines the array of number to store
  36054. * @returns true if the value was set
  36055. */
  36056. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36057. /**
  36058. * Set the value of an uniform to an array of number (stored as vec2)
  36059. * @param uniform defines the webGL uniform location where to store the value
  36060. * @param array defines the array of number to store
  36061. * @returns true if the value was set
  36062. */
  36063. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36064. /**
  36065. * Set the value of an uniform to an array of number (stored as vec3)
  36066. * @param uniform defines the webGL uniform location where to store the value
  36067. * @param array defines the array of number to store
  36068. * @returns true if the value was set
  36069. */
  36070. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36071. /**
  36072. * Set the value of an uniform to an array of number (stored as vec4)
  36073. * @param uniform defines the webGL uniform location where to store the value
  36074. * @param array defines the array of number to store
  36075. * @returns true if the value was set
  36076. */
  36077. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36078. /**
  36079. * Set the value of an uniform to an array of float32 (stored as matrices)
  36080. * @param uniform defines the webGL uniform location where to store the value
  36081. * @param matrices defines the array of float32 to store
  36082. * @returns true if the value was set
  36083. */
  36084. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36085. /**
  36086. * Set the value of an uniform to a matrix (3x3)
  36087. * @param uniform defines the webGL uniform location where to store the value
  36088. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36089. * @returns true if the value was set
  36090. */
  36091. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36092. /**
  36093. * Set the value of an uniform to a matrix (2x2)
  36094. * @param uniform defines the webGL uniform location where to store the value
  36095. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36096. * @returns true if the value was set
  36097. */
  36098. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36099. /**
  36100. * Set the value of an uniform to a number (float)
  36101. * @param uniform defines the webGL uniform location where to store the value
  36102. * @param value defines the float number to store
  36103. * @returns true if the value was transfered
  36104. */
  36105. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36106. /**
  36107. * Set the value of an uniform to a vec2
  36108. * @param uniform defines the webGL uniform location where to store the value
  36109. * @param x defines the 1st component of the value
  36110. * @param y defines the 2nd component of the value
  36111. * @returns true if the value was set
  36112. */
  36113. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36114. /**
  36115. * Set the value of an uniform to a vec3
  36116. * @param uniform defines the webGL uniform location where to store the value
  36117. * @param x defines the 1st component of the value
  36118. * @param y defines the 2nd component of the value
  36119. * @param z defines the 3rd component of the value
  36120. * @returns true if the value was set
  36121. */
  36122. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36123. /**
  36124. * Set the value of an uniform to a vec4
  36125. * @param uniform defines the webGL uniform location where to store the value
  36126. * @param x defines the 1st component of the value
  36127. * @param y defines the 2nd component of the value
  36128. * @param z defines the 3rd component of the value
  36129. * @param w defines the 4th component of the value
  36130. * @returns true if the value was set
  36131. */
  36132. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36133. /**
  36134. * Apply all cached states (depth, culling, stencil and alpha)
  36135. */
  36136. applyStates(): void;
  36137. /**
  36138. * Enable or disable color writing
  36139. * @param enable defines the state to set
  36140. */
  36141. setColorWrite(enable: boolean): void;
  36142. /**
  36143. * Gets a boolean indicating if color writing is enabled
  36144. * @returns the current color writing state
  36145. */
  36146. getColorWrite(): boolean;
  36147. /**
  36148. * Gets the depth culling state manager
  36149. */
  36150. get depthCullingState(): DepthCullingState;
  36151. /**
  36152. * Gets the alpha state manager
  36153. */
  36154. get alphaState(): AlphaState;
  36155. /**
  36156. * Gets the stencil state manager
  36157. */
  36158. get stencilState(): StencilState;
  36159. /**
  36160. * Clears the list of texture accessible through engine.
  36161. * This can help preventing texture load conflict due to name collision.
  36162. */
  36163. clearInternalTexturesCache(): void;
  36164. /**
  36165. * Force the entire cache to be cleared
  36166. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36167. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36168. */
  36169. wipeCaches(bruteForce?: boolean): void;
  36170. /** @hidden */
  36171. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36172. min: number;
  36173. mag: number;
  36174. };
  36175. /** @hidden */
  36176. _createTexture(): WebGLTexture;
  36177. /**
  36178. * Usually called from Texture.ts.
  36179. * Passed information to create a WebGLTexture
  36180. * @param url defines a value which contains one of the following:
  36181. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36182. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36183. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36184. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36185. * @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)
  36186. * @param scene needed for loading to the correct scene
  36187. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36188. * @param onLoad optional callback to be called upon successful completion
  36189. * @param onError optional callback to be called upon failure
  36190. * @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
  36191. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36192. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36193. * @param forcedExtension defines the extension to use to pick the right loader
  36194. * @param mimeType defines an optional mime type
  36195. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36196. */
  36197. 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;
  36198. /**
  36199. * Loads an image as an HTMLImageElement.
  36200. * @param input url string, ArrayBuffer, or Blob to load
  36201. * @param onLoad callback called when the image successfully loads
  36202. * @param onError callback called when the image fails to load
  36203. * @param offlineProvider offline provider for caching
  36204. * @param mimeType optional mime type
  36205. * @returns the HTMLImageElement of the loaded image
  36206. * @hidden
  36207. */
  36208. 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>;
  36209. /**
  36210. * @hidden
  36211. */
  36212. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36213. private _unpackFlipYCached;
  36214. /**
  36215. * In case you are sharing the context with other applications, it might
  36216. * be interested to not cache the unpack flip y state to ensure a consistent
  36217. * value would be set.
  36218. */
  36219. enableUnpackFlipYCached: boolean;
  36220. /** @hidden */
  36221. _unpackFlipY(value: boolean): void;
  36222. /** @hidden */
  36223. _getUnpackAlignement(): number;
  36224. private _getTextureTarget;
  36225. /**
  36226. * Update the sampling mode of a given texture
  36227. * @param samplingMode defines the required sampling mode
  36228. * @param texture defines the texture to update
  36229. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36230. */
  36231. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36232. /**
  36233. * Update the sampling mode of a given texture
  36234. * @param texture defines the texture to update
  36235. * @param wrapU defines the texture wrap mode of the u coordinates
  36236. * @param wrapV defines the texture wrap mode of the v coordinates
  36237. * @param wrapR defines the texture wrap mode of the r coordinates
  36238. */
  36239. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36240. /** @hidden */
  36241. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36242. width: number;
  36243. height: number;
  36244. layers?: number;
  36245. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36246. /** @hidden */
  36247. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36248. /** @hidden */
  36249. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36250. /**
  36251. * Update a portion of an internal texture
  36252. * @param texture defines the texture to update
  36253. * @param imageData defines the data to store into the texture
  36254. * @param xOffset defines the x coordinates of the update rectangle
  36255. * @param yOffset defines the y coordinates of the update rectangle
  36256. * @param width defines the width of the update rectangle
  36257. * @param height defines the height of the update rectangle
  36258. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36259. * @param lod defines the lod level to update (0 by default)
  36260. */
  36261. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36262. /** @hidden */
  36263. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36264. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36265. private _prepareWebGLTexture;
  36266. /** @hidden */
  36267. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36268. private _getDepthStencilBuffer;
  36269. /** @hidden */
  36270. _releaseFramebufferObjects(texture: InternalTexture): void;
  36271. /** @hidden */
  36272. _releaseTexture(texture: InternalTexture): void;
  36273. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36274. protected _setProgram(program: WebGLProgram): void;
  36275. protected _boundUniforms: {
  36276. [key: number]: WebGLUniformLocation;
  36277. };
  36278. /**
  36279. * Binds an effect to the webGL context
  36280. * @param effect defines the effect to bind
  36281. */
  36282. bindSamplers(effect: Effect): void;
  36283. private _activateCurrentTexture;
  36284. /** @hidden */
  36285. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36286. /** @hidden */
  36287. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36288. /**
  36289. * Unbind all textures from the webGL context
  36290. */
  36291. unbindAllTextures(): void;
  36292. /**
  36293. * Sets a texture to the according uniform.
  36294. * @param channel The texture channel
  36295. * @param uniform The uniform to set
  36296. * @param texture The texture to apply
  36297. */
  36298. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36299. private _bindSamplerUniformToChannel;
  36300. private _getTextureWrapMode;
  36301. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36302. /**
  36303. * Sets an array of texture to the webGL context
  36304. * @param channel defines the channel where the texture array must be set
  36305. * @param uniform defines the associated uniform location
  36306. * @param textures defines the array of textures to bind
  36307. */
  36308. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36309. /** @hidden */
  36310. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36311. private _setTextureParameterFloat;
  36312. private _setTextureParameterInteger;
  36313. /**
  36314. * Unbind all vertex attributes from the webGL context
  36315. */
  36316. unbindAllAttributes(): void;
  36317. /**
  36318. * 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
  36319. */
  36320. releaseEffects(): void;
  36321. /**
  36322. * Dispose and release all associated resources
  36323. */
  36324. dispose(): void;
  36325. /**
  36326. * Attach a new callback raised when context lost event is fired
  36327. * @param callback defines the callback to call
  36328. */
  36329. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36330. /**
  36331. * Attach a new callback raised when context restored event is fired
  36332. * @param callback defines the callback to call
  36333. */
  36334. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36335. /**
  36336. * Get the current error code of the webGL context
  36337. * @returns the error code
  36338. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36339. */
  36340. getError(): number;
  36341. private _canRenderToFloatFramebuffer;
  36342. private _canRenderToHalfFloatFramebuffer;
  36343. private _canRenderToFramebuffer;
  36344. /** @hidden */
  36345. _getWebGLTextureType(type: number): number;
  36346. /** @hidden */
  36347. _getInternalFormat(format: number): number;
  36348. /** @hidden */
  36349. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36350. /** @hidden */
  36351. _getRGBAMultiSampleBufferFormat(type: number): number;
  36352. /** @hidden */
  36353. _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;
  36354. /**
  36355. * Loads a file from a url
  36356. * @param url url to load
  36357. * @param onSuccess callback called when the file successfully loads
  36358. * @param onProgress callback called while file is loading (if the server supports this mode)
  36359. * @param offlineProvider defines the offline provider for caching
  36360. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36361. * @param onError callback called when the file fails to load
  36362. * @returns a file request object
  36363. * @hidden
  36364. */
  36365. 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;
  36366. /**
  36367. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36368. * @param x defines the x coordinate of the rectangle where pixels must be read
  36369. * @param y defines the y coordinate of the rectangle where pixels must be read
  36370. * @param width defines the width of the rectangle where pixels must be read
  36371. * @param height defines the height of the rectangle where pixels must be read
  36372. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36373. * @returns a Uint8Array containing RGBA colors
  36374. */
  36375. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36376. private static _IsSupported;
  36377. private static _HasMajorPerformanceCaveat;
  36378. /**
  36379. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36380. */
  36381. static get IsSupported(): boolean;
  36382. /**
  36383. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36384. * @returns true if the engine can be created
  36385. * @ignorenaming
  36386. */
  36387. static isSupported(): boolean;
  36388. /**
  36389. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  36390. */
  36391. static get HasMajorPerformanceCaveat(): boolean;
  36392. /**
  36393. * Find the next highest power of two.
  36394. * @param x Number to start search from.
  36395. * @return Next highest power of two.
  36396. */
  36397. static CeilingPOT(x: number): number;
  36398. /**
  36399. * Find the next lowest power of two.
  36400. * @param x Number to start search from.
  36401. * @return Next lowest power of two.
  36402. */
  36403. static FloorPOT(x: number): number;
  36404. /**
  36405. * Find the nearest power of two.
  36406. * @param x Number to start search from.
  36407. * @return Next nearest power of two.
  36408. */
  36409. static NearestPOT(x: number): number;
  36410. /**
  36411. * Get the closest exponent of two
  36412. * @param value defines the value to approximate
  36413. * @param max defines the maximum value to return
  36414. * @param mode defines how to define the closest value
  36415. * @returns closest exponent of two of the given value
  36416. */
  36417. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36418. /**
  36419. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36420. * @param func - the function to be called
  36421. * @param requester - the object that will request the next frame. Falls back to window.
  36422. * @returns frame number
  36423. */
  36424. static QueueNewFrame(func: () => void, requester?: any): number;
  36425. /**
  36426. * Gets host document
  36427. * @returns the host document object
  36428. */
  36429. getHostDocument(): Nullable<Document>;
  36430. }
  36431. }
  36432. declare module BABYLON {
  36433. /**
  36434. * Class representing spherical harmonics coefficients to the 3rd degree
  36435. */
  36436. export class SphericalHarmonics {
  36437. /**
  36438. * Defines whether or not the harmonics have been prescaled for rendering.
  36439. */
  36440. preScaled: boolean;
  36441. /**
  36442. * The l0,0 coefficients of the spherical harmonics
  36443. */
  36444. l00: Vector3;
  36445. /**
  36446. * The l1,-1 coefficients of the spherical harmonics
  36447. */
  36448. l1_1: Vector3;
  36449. /**
  36450. * The l1,0 coefficients of the spherical harmonics
  36451. */
  36452. l10: Vector3;
  36453. /**
  36454. * The l1,1 coefficients of the spherical harmonics
  36455. */
  36456. l11: Vector3;
  36457. /**
  36458. * The l2,-2 coefficients of the spherical harmonics
  36459. */
  36460. l2_2: Vector3;
  36461. /**
  36462. * The l2,-1 coefficients of the spherical harmonics
  36463. */
  36464. l2_1: Vector3;
  36465. /**
  36466. * The l2,0 coefficients of the spherical harmonics
  36467. */
  36468. l20: Vector3;
  36469. /**
  36470. * The l2,1 coefficients of the spherical harmonics
  36471. */
  36472. l21: Vector3;
  36473. /**
  36474. * The l2,2 coefficients of the spherical harmonics
  36475. */
  36476. l22: Vector3;
  36477. /**
  36478. * Adds a light to the spherical harmonics
  36479. * @param direction the direction of the light
  36480. * @param color the color of the light
  36481. * @param deltaSolidAngle the delta solid angle of the light
  36482. */
  36483. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36484. /**
  36485. * Scales the spherical harmonics by the given amount
  36486. * @param scale the amount to scale
  36487. */
  36488. scaleInPlace(scale: number): void;
  36489. /**
  36490. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36491. *
  36492. * ```
  36493. * E_lm = A_l * L_lm
  36494. * ```
  36495. *
  36496. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36497. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36498. * the scaling factors are given in equation 9.
  36499. */
  36500. convertIncidentRadianceToIrradiance(): void;
  36501. /**
  36502. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36503. *
  36504. * ```
  36505. * L = (1/pi) * E * rho
  36506. * ```
  36507. *
  36508. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36509. */
  36510. convertIrradianceToLambertianRadiance(): void;
  36511. /**
  36512. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36513. * required operations at run time.
  36514. *
  36515. * This is simply done by scaling back the SH with Ylm constants parameter.
  36516. * The trigonometric part being applied by the shader at run time.
  36517. */
  36518. preScaleForRendering(): void;
  36519. /**
  36520. * Constructs a spherical harmonics from an array.
  36521. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36522. * @returns the spherical harmonics
  36523. */
  36524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36525. /**
  36526. * Gets the spherical harmonics from polynomial
  36527. * @param polynomial the spherical polynomial
  36528. * @returns the spherical harmonics
  36529. */
  36530. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36531. }
  36532. /**
  36533. * Class representing spherical polynomial coefficients to the 3rd degree
  36534. */
  36535. export class SphericalPolynomial {
  36536. private _harmonics;
  36537. /**
  36538. * The spherical harmonics used to create the polynomials.
  36539. */
  36540. get preScaledHarmonics(): SphericalHarmonics;
  36541. /**
  36542. * The x coefficients of the spherical polynomial
  36543. */
  36544. x: Vector3;
  36545. /**
  36546. * The y coefficients of the spherical polynomial
  36547. */
  36548. y: Vector3;
  36549. /**
  36550. * The z coefficients of the spherical polynomial
  36551. */
  36552. z: Vector3;
  36553. /**
  36554. * The xx coefficients of the spherical polynomial
  36555. */
  36556. xx: Vector3;
  36557. /**
  36558. * The yy coefficients of the spherical polynomial
  36559. */
  36560. yy: Vector3;
  36561. /**
  36562. * The zz coefficients of the spherical polynomial
  36563. */
  36564. zz: Vector3;
  36565. /**
  36566. * The xy coefficients of the spherical polynomial
  36567. */
  36568. xy: Vector3;
  36569. /**
  36570. * The yz coefficients of the spherical polynomial
  36571. */
  36572. yz: Vector3;
  36573. /**
  36574. * The zx coefficients of the spherical polynomial
  36575. */
  36576. zx: Vector3;
  36577. /**
  36578. * Adds an ambient color to the spherical polynomial
  36579. * @param color the color to add
  36580. */
  36581. addAmbient(color: Color3): void;
  36582. /**
  36583. * Scales the spherical polynomial by the given amount
  36584. * @param scale the amount to scale
  36585. */
  36586. scaleInPlace(scale: number): void;
  36587. /**
  36588. * Gets the spherical polynomial from harmonics
  36589. * @param harmonics the spherical harmonics
  36590. * @returns the spherical polynomial
  36591. */
  36592. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36593. /**
  36594. * Constructs a spherical polynomial from an array.
  36595. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36596. * @returns the spherical polynomial
  36597. */
  36598. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36599. }
  36600. }
  36601. declare module BABYLON {
  36602. /**
  36603. * Defines the source of the internal texture
  36604. */
  36605. export enum InternalTextureSource {
  36606. /**
  36607. * The source of the texture data is unknown
  36608. */
  36609. Unknown = 0,
  36610. /**
  36611. * Texture data comes from an URL
  36612. */
  36613. Url = 1,
  36614. /**
  36615. * Texture data is only used for temporary storage
  36616. */
  36617. Temp = 2,
  36618. /**
  36619. * Texture data comes from raw data (ArrayBuffer)
  36620. */
  36621. Raw = 3,
  36622. /**
  36623. * Texture content is dynamic (video or dynamic texture)
  36624. */
  36625. Dynamic = 4,
  36626. /**
  36627. * Texture content is generated by rendering to it
  36628. */
  36629. RenderTarget = 5,
  36630. /**
  36631. * Texture content is part of a multi render target process
  36632. */
  36633. MultiRenderTarget = 6,
  36634. /**
  36635. * Texture data comes from a cube data file
  36636. */
  36637. Cube = 7,
  36638. /**
  36639. * Texture data comes from a raw cube data
  36640. */
  36641. CubeRaw = 8,
  36642. /**
  36643. * Texture data come from a prefiltered cube data file
  36644. */
  36645. CubePrefiltered = 9,
  36646. /**
  36647. * Texture content is raw 3D data
  36648. */
  36649. Raw3D = 10,
  36650. /**
  36651. * Texture content is raw 2D array data
  36652. */
  36653. Raw2DArray = 11,
  36654. /**
  36655. * Texture content is a depth texture
  36656. */
  36657. Depth = 12,
  36658. /**
  36659. * Texture data comes from a raw cube data encoded with RGBD
  36660. */
  36661. CubeRawRGBD = 13
  36662. }
  36663. /**
  36664. * Class used to store data associated with WebGL texture data for the engine
  36665. * This class should not be used directly
  36666. */
  36667. export class InternalTexture {
  36668. /** @hidden */
  36669. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36670. /**
  36671. * Defines if the texture is ready
  36672. */
  36673. isReady: boolean;
  36674. /**
  36675. * Defines if the texture is a cube texture
  36676. */
  36677. isCube: boolean;
  36678. /**
  36679. * Defines if the texture contains 3D data
  36680. */
  36681. is3D: boolean;
  36682. /**
  36683. * Defines if the texture contains 2D array data
  36684. */
  36685. is2DArray: boolean;
  36686. /**
  36687. * Defines if the texture contains multiview data
  36688. */
  36689. isMultiview: boolean;
  36690. /**
  36691. * Gets the URL used to load this texture
  36692. */
  36693. url: string;
  36694. /**
  36695. * Gets the sampling mode of the texture
  36696. */
  36697. samplingMode: number;
  36698. /**
  36699. * Gets a boolean indicating if the texture needs mipmaps generation
  36700. */
  36701. generateMipMaps: boolean;
  36702. /**
  36703. * Gets the number of samples used by the texture (WebGL2+ only)
  36704. */
  36705. samples: number;
  36706. /**
  36707. * Gets the type of the texture (int, float...)
  36708. */
  36709. type: number;
  36710. /**
  36711. * Gets the format of the texture (RGB, RGBA...)
  36712. */
  36713. format: number;
  36714. /**
  36715. * Observable called when the texture is loaded
  36716. */
  36717. onLoadedObservable: Observable<InternalTexture>;
  36718. /**
  36719. * Gets the width of the texture
  36720. */
  36721. width: number;
  36722. /**
  36723. * Gets the height of the texture
  36724. */
  36725. height: number;
  36726. /**
  36727. * Gets the depth of the texture
  36728. */
  36729. depth: number;
  36730. /**
  36731. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36732. */
  36733. baseWidth: number;
  36734. /**
  36735. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36736. */
  36737. baseHeight: number;
  36738. /**
  36739. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36740. */
  36741. baseDepth: number;
  36742. /**
  36743. * Gets a boolean indicating if the texture is inverted on Y axis
  36744. */
  36745. invertY: boolean;
  36746. /** @hidden */
  36747. _invertVScale: boolean;
  36748. /** @hidden */
  36749. _associatedChannel: number;
  36750. /** @hidden */
  36751. _source: InternalTextureSource;
  36752. /** @hidden */
  36753. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36754. /** @hidden */
  36755. _bufferView: Nullable<ArrayBufferView>;
  36756. /** @hidden */
  36757. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36758. /** @hidden */
  36759. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36760. /** @hidden */
  36761. _size: number;
  36762. /** @hidden */
  36763. _extension: string;
  36764. /** @hidden */
  36765. _files: Nullable<string[]>;
  36766. /** @hidden */
  36767. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36768. /** @hidden */
  36769. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36770. /** @hidden */
  36771. _framebuffer: Nullable<WebGLFramebuffer>;
  36772. /** @hidden */
  36773. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36774. /** @hidden */
  36775. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36776. /** @hidden */
  36777. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36778. /** @hidden */
  36779. _attachments: Nullable<number[]>;
  36780. /** @hidden */
  36781. _textureArray: Nullable<InternalTexture[]>;
  36782. /** @hidden */
  36783. _cachedCoordinatesMode: Nullable<number>;
  36784. /** @hidden */
  36785. _cachedWrapU: Nullable<number>;
  36786. /** @hidden */
  36787. _cachedWrapV: Nullable<number>;
  36788. /** @hidden */
  36789. _cachedWrapR: Nullable<number>;
  36790. /** @hidden */
  36791. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36792. /** @hidden */
  36793. _isDisabled: boolean;
  36794. /** @hidden */
  36795. _compression: Nullable<string>;
  36796. /** @hidden */
  36797. _generateStencilBuffer: boolean;
  36798. /** @hidden */
  36799. _generateDepthBuffer: boolean;
  36800. /** @hidden */
  36801. _comparisonFunction: number;
  36802. /** @hidden */
  36803. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36804. /** @hidden */
  36805. _lodGenerationScale: number;
  36806. /** @hidden */
  36807. _lodGenerationOffset: number;
  36808. /** @hidden */
  36809. _depthStencilTexture: Nullable<InternalTexture>;
  36810. /** @hidden */
  36811. _colorTextureArray: Nullable<WebGLTexture>;
  36812. /** @hidden */
  36813. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36814. /** @hidden */
  36815. _lodTextureHigh: Nullable<BaseTexture>;
  36816. /** @hidden */
  36817. _lodTextureMid: Nullable<BaseTexture>;
  36818. /** @hidden */
  36819. _lodTextureLow: Nullable<BaseTexture>;
  36820. /** @hidden */
  36821. _isRGBD: boolean;
  36822. /** @hidden */
  36823. _linearSpecularLOD: boolean;
  36824. /** @hidden */
  36825. _irradianceTexture: Nullable<BaseTexture>;
  36826. /** @hidden */
  36827. _webGLTexture: Nullable<WebGLTexture>;
  36828. /** @hidden */
  36829. _references: number;
  36830. /** @hidden */
  36831. _gammaSpace: Nullable<boolean>;
  36832. private _engine;
  36833. /**
  36834. * Gets the Engine the texture belongs to.
  36835. * @returns The babylon engine
  36836. */
  36837. getEngine(): ThinEngine;
  36838. /**
  36839. * Gets the data source type of the texture
  36840. */
  36841. get source(): InternalTextureSource;
  36842. /**
  36843. * Creates a new InternalTexture
  36844. * @param engine defines the engine to use
  36845. * @param source defines the type of data that will be used
  36846. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36847. */
  36848. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36849. /**
  36850. * Increments the number of references (ie. the number of Texture that point to it)
  36851. */
  36852. incrementReferences(): void;
  36853. /**
  36854. * Change the size of the texture (not the size of the content)
  36855. * @param width defines the new width
  36856. * @param height defines the new height
  36857. * @param depth defines the new depth (1 by default)
  36858. */
  36859. updateSize(width: int, height: int, depth?: int): void;
  36860. /** @hidden */
  36861. _rebuild(): void;
  36862. /** @hidden */
  36863. _swapAndDie(target: InternalTexture): void;
  36864. /**
  36865. * Dispose the current allocated resources
  36866. */
  36867. dispose(): void;
  36868. }
  36869. }
  36870. declare module BABYLON {
  36871. /**
  36872. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36874. */
  36875. export class Analyser {
  36876. /**
  36877. * Gets or sets the smoothing
  36878. * @ignorenaming
  36879. */
  36880. SMOOTHING: number;
  36881. /**
  36882. * Gets or sets the FFT table size
  36883. * @ignorenaming
  36884. */
  36885. FFT_SIZE: number;
  36886. /**
  36887. * Gets or sets the bar graph amplitude
  36888. * @ignorenaming
  36889. */
  36890. BARGRAPHAMPLITUDE: number;
  36891. /**
  36892. * Gets or sets the position of the debug canvas
  36893. * @ignorenaming
  36894. */
  36895. DEBUGCANVASPOS: {
  36896. x: number;
  36897. y: number;
  36898. };
  36899. /**
  36900. * Gets or sets the debug canvas size
  36901. * @ignorenaming
  36902. */
  36903. DEBUGCANVASSIZE: {
  36904. width: number;
  36905. height: number;
  36906. };
  36907. private _byteFreqs;
  36908. private _byteTime;
  36909. private _floatFreqs;
  36910. private _webAudioAnalyser;
  36911. private _debugCanvas;
  36912. private _debugCanvasContext;
  36913. private _scene;
  36914. private _registerFunc;
  36915. private _audioEngine;
  36916. /**
  36917. * Creates a new analyser
  36918. * @param scene defines hosting scene
  36919. */
  36920. constructor(scene: Scene);
  36921. /**
  36922. * Get the number of data values you will have to play with for the visualization
  36923. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36924. * @returns a number
  36925. */
  36926. getFrequencyBinCount(): number;
  36927. /**
  36928. * Gets the current frequency data as a byte array
  36929. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36930. * @returns a Uint8Array
  36931. */
  36932. getByteFrequencyData(): Uint8Array;
  36933. /**
  36934. * Gets the current waveform as a byte array
  36935. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36936. * @returns a Uint8Array
  36937. */
  36938. getByteTimeDomainData(): Uint8Array;
  36939. /**
  36940. * Gets the current frequency data as a float array
  36941. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36942. * @returns a Float32Array
  36943. */
  36944. getFloatFrequencyData(): Float32Array;
  36945. /**
  36946. * Renders the debug canvas
  36947. */
  36948. drawDebugCanvas(): void;
  36949. /**
  36950. * Stops rendering the debug canvas and removes it
  36951. */
  36952. stopDebugCanvas(): void;
  36953. /**
  36954. * Connects two audio nodes
  36955. * @param inputAudioNode defines first node to connect
  36956. * @param outputAudioNode defines second node to connect
  36957. */
  36958. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36959. /**
  36960. * Releases all associated resources
  36961. */
  36962. dispose(): void;
  36963. }
  36964. }
  36965. declare module BABYLON {
  36966. /**
  36967. * This represents an audio engine and it is responsible
  36968. * to play, synchronize and analyse sounds throughout the application.
  36969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36970. */
  36971. export interface IAudioEngine extends IDisposable {
  36972. /**
  36973. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36974. */
  36975. readonly canUseWebAudio: boolean;
  36976. /**
  36977. * Gets the current AudioContext if available.
  36978. */
  36979. readonly audioContext: Nullable<AudioContext>;
  36980. /**
  36981. * The master gain node defines the global audio volume of your audio engine.
  36982. */
  36983. readonly masterGain: GainNode;
  36984. /**
  36985. * Gets whether or not mp3 are supported by your browser.
  36986. */
  36987. readonly isMP3supported: boolean;
  36988. /**
  36989. * Gets whether or not ogg are supported by your browser.
  36990. */
  36991. readonly isOGGsupported: boolean;
  36992. /**
  36993. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36994. * @ignoreNaming
  36995. */
  36996. WarnedWebAudioUnsupported: boolean;
  36997. /**
  36998. * Defines if the audio engine relies on a custom unlocked button.
  36999. * In this case, the embedded button will not be displayed.
  37000. */
  37001. useCustomUnlockedButton: boolean;
  37002. /**
  37003. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37004. */
  37005. readonly unlocked: boolean;
  37006. /**
  37007. * Event raised when audio has been unlocked on the browser.
  37008. */
  37009. onAudioUnlockedObservable: Observable<AudioEngine>;
  37010. /**
  37011. * Event raised when audio has been locked on the browser.
  37012. */
  37013. onAudioLockedObservable: Observable<AudioEngine>;
  37014. /**
  37015. * Flags the audio engine in Locked state.
  37016. * This happens due to new browser policies preventing audio to autoplay.
  37017. */
  37018. lock(): void;
  37019. /**
  37020. * Unlocks the audio engine once a user action has been done on the dom.
  37021. * This is helpful to resume play once browser policies have been satisfied.
  37022. */
  37023. unlock(): void;
  37024. /**
  37025. * Gets the global volume sets on the master gain.
  37026. * @returns the global volume if set or -1 otherwise
  37027. */
  37028. getGlobalVolume(): number;
  37029. /**
  37030. * Sets the global volume of your experience (sets on the master gain).
  37031. * @param newVolume Defines the new global volume of the application
  37032. */
  37033. setGlobalVolume(newVolume: number): void;
  37034. /**
  37035. * Connect the audio engine to an audio analyser allowing some amazing
  37036. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37038. * @param analyser The analyser to connect to the engine
  37039. */
  37040. connectToAnalyser(analyser: Analyser): void;
  37041. }
  37042. /**
  37043. * This represents the default audio engine used in babylon.
  37044. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37046. */
  37047. export class AudioEngine implements IAudioEngine {
  37048. private _audioContext;
  37049. private _audioContextInitialized;
  37050. private _muteButton;
  37051. private _hostElement;
  37052. /**
  37053. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37054. */
  37055. canUseWebAudio: boolean;
  37056. /**
  37057. * The master gain node defines the global audio volume of your audio engine.
  37058. */
  37059. masterGain: GainNode;
  37060. /**
  37061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37062. * @ignoreNaming
  37063. */
  37064. WarnedWebAudioUnsupported: boolean;
  37065. /**
  37066. * Gets whether or not mp3 are supported by your browser.
  37067. */
  37068. isMP3supported: boolean;
  37069. /**
  37070. * Gets whether or not ogg are supported by your browser.
  37071. */
  37072. isOGGsupported: boolean;
  37073. /**
  37074. * Gets whether audio has been unlocked on the device.
  37075. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37076. * a user interaction has happened.
  37077. */
  37078. unlocked: boolean;
  37079. /**
  37080. * Defines if the audio engine relies on a custom unlocked button.
  37081. * In this case, the embedded button will not be displayed.
  37082. */
  37083. useCustomUnlockedButton: boolean;
  37084. /**
  37085. * Event raised when audio has been unlocked on the browser.
  37086. */
  37087. onAudioUnlockedObservable: Observable<AudioEngine>;
  37088. /**
  37089. * Event raised when audio has been locked on the browser.
  37090. */
  37091. onAudioLockedObservable: Observable<AudioEngine>;
  37092. /**
  37093. * Gets the current AudioContext if available.
  37094. */
  37095. get audioContext(): Nullable<AudioContext>;
  37096. private _connectedAnalyser;
  37097. /**
  37098. * Instantiates a new audio engine.
  37099. *
  37100. * There should be only one per page as some browsers restrict the number
  37101. * of audio contexts you can create.
  37102. * @param hostElement defines the host element where to display the mute icon if necessary
  37103. */
  37104. constructor(hostElement?: Nullable<HTMLElement>);
  37105. /**
  37106. * Flags the audio engine in Locked state.
  37107. * This happens due to new browser policies preventing audio to autoplay.
  37108. */
  37109. lock(): void;
  37110. /**
  37111. * Unlocks the audio engine once a user action has been done on the dom.
  37112. * This is helpful to resume play once browser policies have been satisfied.
  37113. */
  37114. unlock(): void;
  37115. private _resumeAudioContext;
  37116. private _initializeAudioContext;
  37117. private _tryToRun;
  37118. private _triggerRunningState;
  37119. private _triggerSuspendedState;
  37120. private _displayMuteButton;
  37121. private _moveButtonToTopLeft;
  37122. private _onResize;
  37123. private _hideMuteButton;
  37124. /**
  37125. * Destroy and release the resources associated with the audio ccontext.
  37126. */
  37127. dispose(): void;
  37128. /**
  37129. * Gets the global volume sets on the master gain.
  37130. * @returns the global volume if set or -1 otherwise
  37131. */
  37132. getGlobalVolume(): number;
  37133. /**
  37134. * Sets the global volume of your experience (sets on the master gain).
  37135. * @param newVolume Defines the new global volume of the application
  37136. */
  37137. setGlobalVolume(newVolume: number): void;
  37138. /**
  37139. * Connect the audio engine to an audio analyser allowing some amazing
  37140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37142. * @param analyser The analyser to connect to the engine
  37143. */
  37144. connectToAnalyser(analyser: Analyser): void;
  37145. }
  37146. }
  37147. declare module BABYLON {
  37148. /**
  37149. * Interface used to present a loading screen while loading a scene
  37150. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37151. */
  37152. export interface ILoadingScreen {
  37153. /**
  37154. * Function called to display the loading screen
  37155. */
  37156. displayLoadingUI: () => void;
  37157. /**
  37158. * Function called to hide the loading screen
  37159. */
  37160. hideLoadingUI: () => void;
  37161. /**
  37162. * Gets or sets the color to use for the background
  37163. */
  37164. loadingUIBackgroundColor: string;
  37165. /**
  37166. * Gets or sets the text to display while loading
  37167. */
  37168. loadingUIText: string;
  37169. }
  37170. /**
  37171. * Class used for the default loading screen
  37172. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37173. */
  37174. export class DefaultLoadingScreen implements ILoadingScreen {
  37175. private _renderingCanvas;
  37176. private _loadingText;
  37177. private _loadingDivBackgroundColor;
  37178. private _loadingDiv;
  37179. private _loadingTextDiv;
  37180. /** Gets or sets the logo url to use for the default loading screen */
  37181. static DefaultLogoUrl: string;
  37182. /** Gets or sets the spinner url to use for the default loading screen */
  37183. static DefaultSpinnerUrl: string;
  37184. /**
  37185. * Creates a new default loading screen
  37186. * @param _renderingCanvas defines the canvas used to render the scene
  37187. * @param _loadingText defines the default text to display
  37188. * @param _loadingDivBackgroundColor defines the default background color
  37189. */
  37190. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37191. /**
  37192. * Function called to display the loading screen
  37193. */
  37194. displayLoadingUI(): void;
  37195. /**
  37196. * Function called to hide the loading screen
  37197. */
  37198. hideLoadingUI(): void;
  37199. /**
  37200. * Gets or sets the text to display while loading
  37201. */
  37202. set loadingUIText(text: string);
  37203. get loadingUIText(): string;
  37204. /**
  37205. * Gets or sets the color to use for the background
  37206. */
  37207. get loadingUIBackgroundColor(): string;
  37208. set loadingUIBackgroundColor(color: string);
  37209. private _resizeLoadingUI;
  37210. }
  37211. }
  37212. declare module BABYLON {
  37213. /**
  37214. * Interface for any object that can request an animation frame
  37215. */
  37216. export interface ICustomAnimationFrameRequester {
  37217. /**
  37218. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37219. */
  37220. renderFunction?: Function;
  37221. /**
  37222. * Called to request the next frame to render to
  37223. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37224. */
  37225. requestAnimationFrame: Function;
  37226. /**
  37227. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37228. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37229. */
  37230. requestID?: number;
  37231. }
  37232. }
  37233. declare module BABYLON {
  37234. /**
  37235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37236. */
  37237. export class PerformanceMonitor {
  37238. private _enabled;
  37239. private _rollingFrameTime;
  37240. private _lastFrameTimeMs;
  37241. /**
  37242. * constructor
  37243. * @param frameSampleSize The number of samples required to saturate the sliding window
  37244. */
  37245. constructor(frameSampleSize?: number);
  37246. /**
  37247. * Samples current frame
  37248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37249. */
  37250. sampleFrame(timeMs?: number): void;
  37251. /**
  37252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37253. */
  37254. get averageFrameTime(): number;
  37255. /**
  37256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37257. */
  37258. get averageFrameTimeVariance(): number;
  37259. /**
  37260. * Returns the frame time of the most recent frame
  37261. */
  37262. get instantaneousFrameTime(): number;
  37263. /**
  37264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37265. */
  37266. get averageFPS(): number;
  37267. /**
  37268. * Returns the average framerate in frames per second using the most recent frame time
  37269. */
  37270. get instantaneousFPS(): number;
  37271. /**
  37272. * Returns true if enough samples have been taken to completely fill the sliding window
  37273. */
  37274. get isSaturated(): boolean;
  37275. /**
  37276. * Enables contributions to the sliding window sample set
  37277. */
  37278. enable(): void;
  37279. /**
  37280. * Disables contributions to the sliding window sample set
  37281. * Samples will not be interpolated over the disabled period
  37282. */
  37283. disable(): void;
  37284. /**
  37285. * Returns true if sampling is enabled
  37286. */
  37287. get isEnabled(): boolean;
  37288. /**
  37289. * Resets performance monitor
  37290. */
  37291. reset(): void;
  37292. }
  37293. /**
  37294. * RollingAverage
  37295. *
  37296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37297. */
  37298. export class RollingAverage {
  37299. /**
  37300. * Current average
  37301. */
  37302. average: number;
  37303. /**
  37304. * Current variance
  37305. */
  37306. variance: number;
  37307. protected _samples: Array<number>;
  37308. protected _sampleCount: number;
  37309. protected _pos: number;
  37310. protected _m2: number;
  37311. /**
  37312. * constructor
  37313. * @param length The number of samples required to saturate the sliding window
  37314. */
  37315. constructor(length: number);
  37316. /**
  37317. * Adds a sample to the sample set
  37318. * @param v The sample value
  37319. */
  37320. add(v: number): void;
  37321. /**
  37322. * Returns previously added values or null if outside of history or outside the sliding window domain
  37323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37324. * @return Value previously recorded with add() or null if outside of range
  37325. */
  37326. history(i: number): number;
  37327. /**
  37328. * Returns true if enough samples have been taken to completely fill the sliding window
  37329. * @return true if sample-set saturated
  37330. */
  37331. isSaturated(): boolean;
  37332. /**
  37333. * Resets the rolling average (equivalent to 0 samples taken so far)
  37334. */
  37335. reset(): void;
  37336. /**
  37337. * Wraps a value around the sample range boundaries
  37338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37339. * @return Wrapped position in sample range
  37340. */
  37341. protected _wrapPosition(i: number): number;
  37342. }
  37343. }
  37344. declare module BABYLON {
  37345. /**
  37346. * This class is used to track a performance counter which is number based.
  37347. * The user has access to many properties which give statistics of different nature.
  37348. *
  37349. * The implementer can track two kinds of Performance Counter: time and count.
  37350. * 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.
  37351. * 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.
  37352. */
  37353. export class PerfCounter {
  37354. /**
  37355. * Gets or sets a global boolean to turn on and off all the counters
  37356. */
  37357. static Enabled: boolean;
  37358. /**
  37359. * Returns the smallest value ever
  37360. */
  37361. get min(): number;
  37362. /**
  37363. * Returns the biggest value ever
  37364. */
  37365. get max(): number;
  37366. /**
  37367. * Returns the average value since the performance counter is running
  37368. */
  37369. get average(): number;
  37370. /**
  37371. * Returns the average value of the last second the counter was monitored
  37372. */
  37373. get lastSecAverage(): number;
  37374. /**
  37375. * Returns the current value
  37376. */
  37377. get current(): number;
  37378. /**
  37379. * Gets the accumulated total
  37380. */
  37381. get total(): number;
  37382. /**
  37383. * Gets the total value count
  37384. */
  37385. get count(): number;
  37386. /**
  37387. * Creates a new counter
  37388. */
  37389. constructor();
  37390. /**
  37391. * Call this method to start monitoring a new frame.
  37392. * 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.
  37393. */
  37394. fetchNewFrame(): void;
  37395. /**
  37396. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37397. * @param newCount the count value to add to the monitored count
  37398. * @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.
  37399. */
  37400. addCount(newCount: number, fetchResult: boolean): void;
  37401. /**
  37402. * Start monitoring this performance counter
  37403. */
  37404. beginMonitoring(): void;
  37405. /**
  37406. * Compute the time lapsed since the previous beginMonitoring() call.
  37407. * @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
  37408. */
  37409. endMonitoring(newFrame?: boolean): void;
  37410. private _fetchResult;
  37411. private _startMonitoringTime;
  37412. private _min;
  37413. private _max;
  37414. private _average;
  37415. private _current;
  37416. private _totalValueCount;
  37417. private _totalAccumulated;
  37418. private _lastSecAverage;
  37419. private _lastSecAccumulated;
  37420. private _lastSecTime;
  37421. private _lastSecValueCount;
  37422. }
  37423. }
  37424. declare module BABYLON {
  37425. interface ThinEngine {
  37426. /** @hidden */
  37427. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37428. }
  37429. }
  37430. declare module BABYLON {
  37431. /**
  37432. * Defines the interface used by display changed events
  37433. */
  37434. export interface IDisplayChangedEventArgs {
  37435. /** Gets the vrDisplay object (if any) */
  37436. vrDisplay: Nullable<any>;
  37437. /** Gets a boolean indicating if webVR is supported */
  37438. vrSupported: boolean;
  37439. }
  37440. /**
  37441. * Defines the interface used by objects containing a viewport (like a camera)
  37442. */
  37443. interface IViewportOwnerLike {
  37444. /**
  37445. * Gets or sets the viewport
  37446. */
  37447. viewport: IViewportLike;
  37448. }
  37449. /**
  37450. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37451. */
  37452. export class Engine extends ThinEngine {
  37453. /** Defines that alpha blending is disabled */
  37454. static readonly ALPHA_DISABLE: number;
  37455. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37456. static readonly ALPHA_ADD: number;
  37457. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37458. static readonly ALPHA_COMBINE: number;
  37459. /** Defines that alpha blending to DEST - SRC * DEST */
  37460. static readonly ALPHA_SUBTRACT: number;
  37461. /** Defines that alpha blending to SRC * DEST */
  37462. static readonly ALPHA_MULTIPLY: number;
  37463. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37464. static readonly ALPHA_MAXIMIZED: number;
  37465. /** Defines that alpha blending to SRC + DEST */
  37466. static readonly ALPHA_ONEONE: number;
  37467. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37468. static readonly ALPHA_PREMULTIPLIED: number;
  37469. /**
  37470. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37471. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37472. */
  37473. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37474. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37475. static readonly ALPHA_INTERPOLATE: number;
  37476. /**
  37477. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37478. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37479. */
  37480. static readonly ALPHA_SCREENMODE: number;
  37481. /** Defines that the ressource is not delayed*/
  37482. static readonly DELAYLOADSTATE_NONE: number;
  37483. /** Defines that the ressource was successfully delay loaded */
  37484. static readonly DELAYLOADSTATE_LOADED: number;
  37485. /** Defines that the ressource is currently delay loading */
  37486. static readonly DELAYLOADSTATE_LOADING: number;
  37487. /** Defines that the ressource is delayed and has not started loading */
  37488. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37490. static readonly NEVER: number;
  37491. /** 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 */
  37492. static readonly ALWAYS: number;
  37493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37494. static readonly LESS: number;
  37495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37496. static readonly EQUAL: number;
  37497. /** 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 */
  37498. static readonly LEQUAL: number;
  37499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37500. static readonly GREATER: number;
  37501. /** 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 */
  37502. static readonly GEQUAL: number;
  37503. /** 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 */
  37504. static readonly NOTEQUAL: number;
  37505. /** Passed to stencilOperation to specify that stencil value must be kept */
  37506. static readonly KEEP: number;
  37507. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37508. static readonly REPLACE: number;
  37509. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37510. static readonly INCR: number;
  37511. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37512. static readonly DECR: number;
  37513. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37514. static readonly INVERT: number;
  37515. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37516. static readonly INCR_WRAP: number;
  37517. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37518. static readonly DECR_WRAP: number;
  37519. /** Texture is not repeating outside of 0..1 UVs */
  37520. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37521. /** Texture is repeating outside of 0..1 UVs */
  37522. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37523. /** Texture is repeating and mirrored */
  37524. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37525. /** ALPHA */
  37526. static readonly TEXTUREFORMAT_ALPHA: number;
  37527. /** LUMINANCE */
  37528. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37529. /** LUMINANCE_ALPHA */
  37530. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37531. /** RGB */
  37532. static readonly TEXTUREFORMAT_RGB: number;
  37533. /** RGBA */
  37534. static readonly TEXTUREFORMAT_RGBA: number;
  37535. /** RED */
  37536. static readonly TEXTUREFORMAT_RED: number;
  37537. /** RED (2nd reference) */
  37538. static readonly TEXTUREFORMAT_R: number;
  37539. /** RG */
  37540. static readonly TEXTUREFORMAT_RG: number;
  37541. /** RED_INTEGER */
  37542. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37543. /** RED_INTEGER (2nd reference) */
  37544. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37545. /** RG_INTEGER */
  37546. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37547. /** RGB_INTEGER */
  37548. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37549. /** RGBA_INTEGER */
  37550. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37551. /** UNSIGNED_BYTE */
  37552. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37553. /** UNSIGNED_BYTE (2nd reference) */
  37554. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37555. /** FLOAT */
  37556. static readonly TEXTURETYPE_FLOAT: number;
  37557. /** HALF_FLOAT */
  37558. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37559. /** BYTE */
  37560. static readonly TEXTURETYPE_BYTE: number;
  37561. /** SHORT */
  37562. static readonly TEXTURETYPE_SHORT: number;
  37563. /** UNSIGNED_SHORT */
  37564. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37565. /** INT */
  37566. static readonly TEXTURETYPE_INT: number;
  37567. /** UNSIGNED_INT */
  37568. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37569. /** UNSIGNED_SHORT_4_4_4_4 */
  37570. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37571. /** UNSIGNED_SHORT_5_5_5_1 */
  37572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37573. /** UNSIGNED_SHORT_5_6_5 */
  37574. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37575. /** UNSIGNED_INT_2_10_10_10_REV */
  37576. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37577. /** UNSIGNED_INT_24_8 */
  37578. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37579. /** UNSIGNED_INT_10F_11F_11F_REV */
  37580. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37581. /** UNSIGNED_INT_5_9_9_9_REV */
  37582. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37583. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37584. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37585. /** nearest is mag = nearest and min = nearest and mip = linear */
  37586. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37588. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37589. /** Trilinear is mag = linear and min = linear and mip = linear */
  37590. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37591. /** nearest is mag = nearest and min = nearest and mip = linear */
  37592. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37593. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37594. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37595. /** Trilinear is mag = linear and min = linear and mip = linear */
  37596. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37597. /** mag = nearest and min = nearest and mip = nearest */
  37598. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37599. /** mag = nearest and min = linear and mip = nearest */
  37600. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37601. /** mag = nearest and min = linear and mip = linear */
  37602. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37603. /** mag = nearest and min = linear and mip = none */
  37604. static readonly TEXTURE_NEAREST_LINEAR: number;
  37605. /** mag = nearest and min = nearest and mip = none */
  37606. static readonly TEXTURE_NEAREST_NEAREST: number;
  37607. /** mag = linear and min = nearest and mip = nearest */
  37608. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37609. /** mag = linear and min = nearest and mip = linear */
  37610. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37611. /** mag = linear and min = linear and mip = none */
  37612. static readonly TEXTURE_LINEAR_LINEAR: number;
  37613. /** mag = linear and min = nearest and mip = none */
  37614. static readonly TEXTURE_LINEAR_NEAREST: number;
  37615. /** Explicit coordinates mode */
  37616. static readonly TEXTURE_EXPLICIT_MODE: number;
  37617. /** Spherical coordinates mode */
  37618. static readonly TEXTURE_SPHERICAL_MODE: number;
  37619. /** Planar coordinates mode */
  37620. static readonly TEXTURE_PLANAR_MODE: number;
  37621. /** Cubic coordinates mode */
  37622. static readonly TEXTURE_CUBIC_MODE: number;
  37623. /** Projection coordinates mode */
  37624. static readonly TEXTURE_PROJECTION_MODE: number;
  37625. /** Skybox coordinates mode */
  37626. static readonly TEXTURE_SKYBOX_MODE: number;
  37627. /** Inverse Cubic coordinates mode */
  37628. static readonly TEXTURE_INVCUBIC_MODE: number;
  37629. /** Equirectangular coordinates mode */
  37630. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37631. /** Equirectangular Fixed coordinates mode */
  37632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37633. /** Equirectangular Fixed Mirrored coordinates mode */
  37634. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37635. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37636. static readonly SCALEMODE_FLOOR: number;
  37637. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37638. static readonly SCALEMODE_NEAREST: number;
  37639. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37640. static readonly SCALEMODE_CEILING: number;
  37641. /**
  37642. * Returns the current npm package of the sdk
  37643. */
  37644. static get NpmPackage(): string;
  37645. /**
  37646. * Returns the current version of the framework
  37647. */
  37648. static get Version(): string;
  37649. /** Gets the list of created engines */
  37650. static get Instances(): Engine[];
  37651. /**
  37652. * Gets the latest created engine
  37653. */
  37654. static get LastCreatedEngine(): Nullable<Engine>;
  37655. /**
  37656. * Gets the latest created scene
  37657. */
  37658. static get LastCreatedScene(): Nullable<Scene>;
  37659. /**
  37660. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37661. * @param flag defines which part of the materials must be marked as dirty
  37662. * @param predicate defines a predicate used to filter which materials should be affected
  37663. */
  37664. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37665. /**
  37666. * Method called to create the default loading screen.
  37667. * This can be overriden in your own app.
  37668. * @param canvas The rendering canvas element
  37669. * @returns The loading screen
  37670. */
  37671. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37672. /**
  37673. * Method called to create the default rescale post process on each engine.
  37674. */
  37675. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37676. /**
  37677. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37678. **/
  37679. enableOfflineSupport: boolean;
  37680. /**
  37681. * 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)
  37682. **/
  37683. disableManifestCheck: boolean;
  37684. /**
  37685. * Gets the list of created scenes
  37686. */
  37687. scenes: Scene[];
  37688. /**
  37689. * Event raised when a new scene is created
  37690. */
  37691. onNewSceneAddedObservable: Observable<Scene>;
  37692. /**
  37693. * Gets the list of created postprocesses
  37694. */
  37695. postProcesses: PostProcess[];
  37696. /**
  37697. * Gets a boolean indicating if the pointer is currently locked
  37698. */
  37699. isPointerLock: boolean;
  37700. /**
  37701. * Observable event triggered each time the rendering canvas is resized
  37702. */
  37703. onResizeObservable: Observable<Engine>;
  37704. /**
  37705. * Observable event triggered each time the canvas loses focus
  37706. */
  37707. onCanvasBlurObservable: Observable<Engine>;
  37708. /**
  37709. * Observable event triggered each time the canvas gains focus
  37710. */
  37711. onCanvasFocusObservable: Observable<Engine>;
  37712. /**
  37713. * Observable event triggered each time the canvas receives pointerout event
  37714. */
  37715. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37716. /**
  37717. * Observable raised when the engine begins a new frame
  37718. */
  37719. onBeginFrameObservable: Observable<Engine>;
  37720. /**
  37721. * If set, will be used to request the next animation frame for the render loop
  37722. */
  37723. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37724. /**
  37725. * Observable raised when the engine ends the current frame
  37726. */
  37727. onEndFrameObservable: Observable<Engine>;
  37728. /**
  37729. * Observable raised when the engine is about to compile a shader
  37730. */
  37731. onBeforeShaderCompilationObservable: Observable<Engine>;
  37732. /**
  37733. * Observable raised when the engine has jsut compiled a shader
  37734. */
  37735. onAfterShaderCompilationObservable: Observable<Engine>;
  37736. /**
  37737. * Gets the audio engine
  37738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37739. * @ignorenaming
  37740. */
  37741. static audioEngine: IAudioEngine;
  37742. /**
  37743. * Default AudioEngine factory responsible of creating the Audio Engine.
  37744. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37745. */
  37746. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37747. /**
  37748. * Default offline support factory responsible of creating a tool used to store data locally.
  37749. * By default, this will create a Database object if the workload has been embedded.
  37750. */
  37751. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37752. private _loadingScreen;
  37753. private _pointerLockRequested;
  37754. private _rescalePostProcess;
  37755. private _deterministicLockstep;
  37756. private _lockstepMaxSteps;
  37757. private _timeStep;
  37758. protected get _supportsHardwareTextureRescaling(): boolean;
  37759. private _fps;
  37760. private _deltaTime;
  37761. /** @hidden */
  37762. _drawCalls: PerfCounter;
  37763. /** 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 */
  37764. canvasTabIndex: number;
  37765. /**
  37766. * Turn this value on if you want to pause FPS computation when in background
  37767. */
  37768. disablePerformanceMonitorInBackground: boolean;
  37769. private _performanceMonitor;
  37770. /**
  37771. * Gets the performance monitor attached to this engine
  37772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37773. */
  37774. get performanceMonitor(): PerformanceMonitor;
  37775. private _onFocus;
  37776. private _onBlur;
  37777. private _onCanvasPointerOut;
  37778. private _onCanvasBlur;
  37779. private _onCanvasFocus;
  37780. private _onFullscreenChange;
  37781. private _onPointerLockChange;
  37782. /**
  37783. * Gets the HTML element used to attach event listeners
  37784. * @returns a HTML element
  37785. */
  37786. getInputElement(): Nullable<HTMLElement>;
  37787. /**
  37788. * Creates a new engine
  37789. * @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
  37790. * @param antialias defines enable antialiasing (default: false)
  37791. * @param options defines further options to be sent to the getContext() function
  37792. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37793. */
  37794. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37795. /**
  37796. * Gets current aspect ratio
  37797. * @param viewportOwner defines the camera to use to get the aspect ratio
  37798. * @param useScreen defines if screen size must be used (or the current render target if any)
  37799. * @returns a number defining the aspect ratio
  37800. */
  37801. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37802. /**
  37803. * Gets current screen aspect ratio
  37804. * @returns a number defining the aspect ratio
  37805. */
  37806. getScreenAspectRatio(): number;
  37807. /**
  37808. * Gets the client rect of the HTML canvas attached with the current webGL context
  37809. * @returns a client rectanglee
  37810. */
  37811. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37812. /**
  37813. * Gets the client rect of the HTML element used for events
  37814. * @returns a client rectanglee
  37815. */
  37816. getInputElementClientRect(): Nullable<ClientRect>;
  37817. /**
  37818. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37819. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37820. * @returns true if engine is in deterministic lock step mode
  37821. */
  37822. isDeterministicLockStep(): boolean;
  37823. /**
  37824. * Gets the max steps when engine is running in deterministic lock step
  37825. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37826. * @returns the max steps
  37827. */
  37828. getLockstepMaxSteps(): number;
  37829. /**
  37830. * Returns the time in ms between steps when using deterministic lock step.
  37831. * @returns time step in (ms)
  37832. */
  37833. getTimeStep(): number;
  37834. /**
  37835. * Force the mipmap generation for the given render target texture
  37836. * @param texture defines the render target texture to use
  37837. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37838. */
  37839. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37840. /** States */
  37841. /**
  37842. * Set various states to the webGL context
  37843. * @param culling defines backface culling state
  37844. * @param zOffset defines the value to apply to zOffset (0 by default)
  37845. * @param force defines if states must be applied even if cache is up to date
  37846. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37847. */
  37848. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37849. /**
  37850. * Set the z offset to apply to current rendering
  37851. * @param value defines the offset to apply
  37852. */
  37853. setZOffset(value: number): void;
  37854. /**
  37855. * Gets the current value of the zOffset
  37856. * @returns the current zOffset state
  37857. */
  37858. getZOffset(): number;
  37859. /**
  37860. * Enable or disable depth buffering
  37861. * @param enable defines the state to set
  37862. */
  37863. setDepthBuffer(enable: boolean): void;
  37864. /**
  37865. * Gets a boolean indicating if depth writing is enabled
  37866. * @returns the current depth writing state
  37867. */
  37868. getDepthWrite(): boolean;
  37869. /**
  37870. * Enable or disable depth writing
  37871. * @param enable defines the state to set
  37872. */
  37873. setDepthWrite(enable: boolean): void;
  37874. /**
  37875. * Gets a boolean indicating if stencil buffer is enabled
  37876. * @returns the current stencil buffer state
  37877. */
  37878. getStencilBuffer(): boolean;
  37879. /**
  37880. * Enable or disable the stencil buffer
  37881. * @param enable defines if the stencil buffer must be enabled or disabled
  37882. */
  37883. setStencilBuffer(enable: boolean): void;
  37884. /**
  37885. * Gets the current stencil mask
  37886. * @returns a number defining the new stencil mask to use
  37887. */
  37888. getStencilMask(): number;
  37889. /**
  37890. * Sets the current stencil mask
  37891. * @param mask defines the new stencil mask to use
  37892. */
  37893. setStencilMask(mask: number): void;
  37894. /**
  37895. * Gets the current stencil function
  37896. * @returns a number defining the stencil function to use
  37897. */
  37898. getStencilFunction(): number;
  37899. /**
  37900. * Gets the current stencil reference value
  37901. * @returns a number defining the stencil reference value to use
  37902. */
  37903. getStencilFunctionReference(): number;
  37904. /**
  37905. * Gets the current stencil mask
  37906. * @returns a number defining the stencil mask to use
  37907. */
  37908. getStencilFunctionMask(): number;
  37909. /**
  37910. * Sets the current stencil function
  37911. * @param stencilFunc defines the new stencil function to use
  37912. */
  37913. setStencilFunction(stencilFunc: number): void;
  37914. /**
  37915. * Sets the current stencil reference
  37916. * @param reference defines the new stencil reference to use
  37917. */
  37918. setStencilFunctionReference(reference: number): void;
  37919. /**
  37920. * Sets the current stencil mask
  37921. * @param mask defines the new stencil mask to use
  37922. */
  37923. setStencilFunctionMask(mask: number): void;
  37924. /**
  37925. * Gets the current stencil operation when stencil fails
  37926. * @returns a number defining stencil operation to use when stencil fails
  37927. */
  37928. getStencilOperationFail(): number;
  37929. /**
  37930. * Gets the current stencil operation when depth fails
  37931. * @returns a number defining stencil operation to use when depth fails
  37932. */
  37933. getStencilOperationDepthFail(): number;
  37934. /**
  37935. * Gets the current stencil operation when stencil passes
  37936. * @returns a number defining stencil operation to use when stencil passes
  37937. */
  37938. getStencilOperationPass(): number;
  37939. /**
  37940. * Sets the stencil operation to use when stencil fails
  37941. * @param operation defines the stencil operation to use when stencil fails
  37942. */
  37943. setStencilOperationFail(operation: number): void;
  37944. /**
  37945. * Sets the stencil operation to use when depth fails
  37946. * @param operation defines the stencil operation to use when depth fails
  37947. */
  37948. setStencilOperationDepthFail(operation: number): void;
  37949. /**
  37950. * Sets the stencil operation to use when stencil passes
  37951. * @param operation defines the stencil operation to use when stencil passes
  37952. */
  37953. setStencilOperationPass(operation: number): void;
  37954. /**
  37955. * Sets a boolean indicating if the dithering state is enabled or disabled
  37956. * @param value defines the dithering state
  37957. */
  37958. setDitheringState(value: boolean): void;
  37959. /**
  37960. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37961. * @param value defines the rasterizer state
  37962. */
  37963. setRasterizerState(value: boolean): void;
  37964. /**
  37965. * Gets the current depth function
  37966. * @returns a number defining the depth function
  37967. */
  37968. getDepthFunction(): Nullable<number>;
  37969. /**
  37970. * Sets the current depth function
  37971. * @param depthFunc defines the function to use
  37972. */
  37973. setDepthFunction(depthFunc: number): void;
  37974. /**
  37975. * Sets the current depth function to GREATER
  37976. */
  37977. setDepthFunctionToGreater(): void;
  37978. /**
  37979. * Sets the current depth function to GEQUAL
  37980. */
  37981. setDepthFunctionToGreaterOrEqual(): void;
  37982. /**
  37983. * Sets the current depth function to LESS
  37984. */
  37985. setDepthFunctionToLess(): void;
  37986. /**
  37987. * Sets the current depth function to LEQUAL
  37988. */
  37989. setDepthFunctionToLessOrEqual(): void;
  37990. private _cachedStencilBuffer;
  37991. private _cachedStencilFunction;
  37992. private _cachedStencilMask;
  37993. private _cachedStencilOperationPass;
  37994. private _cachedStencilOperationFail;
  37995. private _cachedStencilOperationDepthFail;
  37996. private _cachedStencilReference;
  37997. /**
  37998. * Caches the the state of the stencil buffer
  37999. */
  38000. cacheStencilState(): void;
  38001. /**
  38002. * Restores the state of the stencil buffer
  38003. */
  38004. restoreStencilState(): void;
  38005. /**
  38006. * Directly set the WebGL Viewport
  38007. * @param x defines the x coordinate of the viewport (in screen space)
  38008. * @param y defines the y coordinate of the viewport (in screen space)
  38009. * @param width defines the width of the viewport (in screen space)
  38010. * @param height defines the height of the viewport (in screen space)
  38011. * @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
  38012. */
  38013. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38014. /**
  38015. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38016. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38017. * @param y defines the y-coordinate of the corner of the clear rectangle
  38018. * @param width defines the width of the clear rectangle
  38019. * @param height defines the height of the clear rectangle
  38020. * @param clearColor defines the clear color
  38021. */
  38022. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38023. /**
  38024. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38025. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38026. * @param y defines the y-coordinate of the corner of the clear rectangle
  38027. * @param width defines the width of the clear rectangle
  38028. * @param height defines the height of the clear rectangle
  38029. */
  38030. enableScissor(x: number, y: number, width: number, height: number): void;
  38031. /**
  38032. * Disable previously set scissor test rectangle
  38033. */
  38034. disableScissor(): void;
  38035. protected _reportDrawCall(): void;
  38036. /**
  38037. * Initializes a webVR display and starts listening to display change events
  38038. * The onVRDisplayChangedObservable will be notified upon these changes
  38039. * @returns The onVRDisplayChangedObservable
  38040. */
  38041. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38042. /** @hidden */
  38043. _prepareVRComponent(): void;
  38044. /** @hidden */
  38045. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38046. /** @hidden */
  38047. _submitVRFrame(): void;
  38048. /**
  38049. * Call this function to leave webVR mode
  38050. * Will do nothing if webVR is not supported or if there is no webVR device
  38051. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38052. */
  38053. disableVR(): void;
  38054. /**
  38055. * Gets a boolean indicating that the system is in VR mode and is presenting
  38056. * @returns true if VR mode is engaged
  38057. */
  38058. isVRPresenting(): boolean;
  38059. /** @hidden */
  38060. _requestVRFrame(): void;
  38061. /** @hidden */
  38062. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38063. /**
  38064. * Gets the source code of the vertex shader associated with a specific webGL program
  38065. * @param program defines the program to use
  38066. * @returns a string containing the source code of the vertex shader associated with the program
  38067. */
  38068. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38069. /**
  38070. * Gets the source code of the fragment shader associated with a specific webGL program
  38071. * @param program defines the program to use
  38072. * @returns a string containing the source code of the fragment shader associated with the program
  38073. */
  38074. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38075. /**
  38076. * Sets a depth stencil texture from a render target to the according uniform.
  38077. * @param channel The texture channel
  38078. * @param uniform The uniform to set
  38079. * @param texture The render target texture containing the depth stencil texture to apply
  38080. */
  38081. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38082. /**
  38083. * Sets a texture to the webGL context from a postprocess
  38084. * @param channel defines the channel to use
  38085. * @param postProcess defines the source postprocess
  38086. */
  38087. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38088. /**
  38089. * Binds the output of the passed in post process to the texture channel specified
  38090. * @param channel The channel the texture should be bound to
  38091. * @param postProcess The post process which's output should be bound
  38092. */
  38093. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38094. protected _rebuildBuffers(): void;
  38095. /** @hidden */
  38096. _renderFrame(): void;
  38097. _renderLoop(): void;
  38098. /** @hidden */
  38099. _renderViews(): boolean;
  38100. /**
  38101. * Toggle full screen mode
  38102. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38103. */
  38104. switchFullscreen(requestPointerLock: boolean): void;
  38105. /**
  38106. * Enters full screen mode
  38107. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38108. */
  38109. enterFullscreen(requestPointerLock: boolean): void;
  38110. /**
  38111. * Exits full screen mode
  38112. */
  38113. exitFullscreen(): void;
  38114. /**
  38115. * Enters Pointerlock mode
  38116. */
  38117. enterPointerlock(): void;
  38118. /**
  38119. * Exits Pointerlock mode
  38120. */
  38121. exitPointerlock(): void;
  38122. /**
  38123. * Begin a new frame
  38124. */
  38125. beginFrame(): void;
  38126. /**
  38127. * Enf the current frame
  38128. */
  38129. endFrame(): void;
  38130. resize(): void;
  38131. /**
  38132. * Force a specific size of the canvas
  38133. * @param width defines the new canvas' width
  38134. * @param height defines the new canvas' height
  38135. * @returns true if the size was changed
  38136. */
  38137. setSize(width: number, height: number): boolean;
  38138. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38139. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38140. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38141. _releaseTexture(texture: InternalTexture): void;
  38142. /**
  38143. * @hidden
  38144. * Rescales a texture
  38145. * @param source input texutre
  38146. * @param destination destination texture
  38147. * @param scene scene to use to render the resize
  38148. * @param internalFormat format to use when resizing
  38149. * @param onComplete callback to be called when resize has completed
  38150. */
  38151. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38152. /**
  38153. * Gets the current framerate
  38154. * @returns a number representing the framerate
  38155. */
  38156. getFps(): number;
  38157. /**
  38158. * Gets the time spent between current and previous frame
  38159. * @returns a number representing the delta time in ms
  38160. */
  38161. getDeltaTime(): number;
  38162. private _measureFps;
  38163. /** @hidden */
  38164. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38165. /**
  38166. * Updates the sample count of a render target texture
  38167. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38168. * @param texture defines the texture to update
  38169. * @param samples defines the sample count to set
  38170. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38171. */
  38172. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38173. /**
  38174. * Updates a depth texture Comparison Mode and Function.
  38175. * If the comparison Function is equal to 0, the mode will be set to none.
  38176. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38177. * @param texture The texture to set the comparison function for
  38178. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38179. */
  38180. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38181. /**
  38182. * Creates a webGL buffer to use with instanciation
  38183. * @param capacity defines the size of the buffer
  38184. * @returns the webGL buffer
  38185. */
  38186. createInstancesBuffer(capacity: number): DataBuffer;
  38187. /**
  38188. * Delete a webGL buffer used with instanciation
  38189. * @param buffer defines the webGL buffer to delete
  38190. */
  38191. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38192. private _clientWaitAsync;
  38193. /** @hidden */
  38194. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38195. dispose(): void;
  38196. private _disableTouchAction;
  38197. /**
  38198. * Display the loading screen
  38199. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38200. */
  38201. displayLoadingUI(): void;
  38202. /**
  38203. * Hide the loading screen
  38204. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38205. */
  38206. hideLoadingUI(): void;
  38207. /**
  38208. * Gets the current loading screen object
  38209. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38210. */
  38211. get loadingScreen(): ILoadingScreen;
  38212. /**
  38213. * Sets the current loading screen object
  38214. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38215. */
  38216. set loadingScreen(loadingScreen: ILoadingScreen);
  38217. /**
  38218. * Sets the current loading screen text
  38219. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38220. */
  38221. set loadingUIText(text: string);
  38222. /**
  38223. * Sets the current loading screen background color
  38224. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38225. */
  38226. set loadingUIBackgroundColor(color: string);
  38227. /** Pointerlock and fullscreen */
  38228. /**
  38229. * Ask the browser to promote the current element to pointerlock mode
  38230. * @param element defines the DOM element to promote
  38231. */
  38232. static _RequestPointerlock(element: HTMLElement): void;
  38233. /**
  38234. * Asks the browser to exit pointerlock mode
  38235. */
  38236. static _ExitPointerlock(): void;
  38237. /**
  38238. * Ask the browser to promote the current element to fullscreen rendering mode
  38239. * @param element defines the DOM element to promote
  38240. */
  38241. static _RequestFullscreen(element: HTMLElement): void;
  38242. /**
  38243. * Asks the browser to exit fullscreen mode
  38244. */
  38245. static _ExitFullscreen(): void;
  38246. }
  38247. }
  38248. declare module BABYLON {
  38249. /**
  38250. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38251. * during the life time of the application.
  38252. */
  38253. export class EngineStore {
  38254. /** Gets the list of created engines */
  38255. static Instances: Engine[];
  38256. /** @hidden */
  38257. static _LastCreatedScene: Nullable<Scene>;
  38258. /**
  38259. * Gets the latest created engine
  38260. */
  38261. static get LastCreatedEngine(): Nullable<Engine>;
  38262. /**
  38263. * Gets the latest created scene
  38264. */
  38265. static get LastCreatedScene(): Nullable<Scene>;
  38266. /**
  38267. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38268. * @ignorenaming
  38269. */
  38270. static UseFallbackTexture: boolean;
  38271. /**
  38272. * Texture content used if a texture cannot loaded
  38273. * @ignorenaming
  38274. */
  38275. static FallbackTexture: string;
  38276. }
  38277. }
  38278. declare module BABYLON {
  38279. /**
  38280. * Helper class that provides a small promise polyfill
  38281. */
  38282. export class PromisePolyfill {
  38283. /**
  38284. * Static function used to check if the polyfill is required
  38285. * If this is the case then the function will inject the polyfill to window.Promise
  38286. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38287. */
  38288. static Apply(force?: boolean): void;
  38289. }
  38290. }
  38291. declare module BABYLON {
  38292. /**
  38293. * Interface for screenshot methods with describe argument called `size` as object with options
  38294. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38295. */
  38296. export interface IScreenshotSize {
  38297. /**
  38298. * number in pixels for canvas height
  38299. */
  38300. height?: number;
  38301. /**
  38302. * multiplier allowing render at a higher or lower resolution
  38303. * If value is defined then height and width will be ignored and taken from camera
  38304. */
  38305. precision?: number;
  38306. /**
  38307. * number in pixels for canvas width
  38308. */
  38309. width?: number;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. interface IColor4Like {
  38314. r: float;
  38315. g: float;
  38316. b: float;
  38317. a: float;
  38318. }
  38319. /**
  38320. * Class containing a set of static utilities functions
  38321. */
  38322. export class Tools {
  38323. /**
  38324. * Gets or sets the base URL to use to load assets
  38325. */
  38326. static get BaseUrl(): string;
  38327. static set BaseUrl(value: string);
  38328. /**
  38329. * Enable/Disable Custom HTTP Request Headers globally.
  38330. * default = false
  38331. * @see CustomRequestHeaders
  38332. */
  38333. static UseCustomRequestHeaders: boolean;
  38334. /**
  38335. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38336. * i.e. when loading files, where the server/service expects an Authorization header
  38337. */
  38338. static CustomRequestHeaders: {
  38339. [key: string]: string;
  38340. };
  38341. /**
  38342. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38343. */
  38344. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38345. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38346. /**
  38347. * Default behaviour for cors in the application.
  38348. * It can be a string if the expected behavior is identical in the entire app.
  38349. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38350. */
  38351. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38352. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38353. /**
  38354. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38355. * @ignorenaming
  38356. */
  38357. static get UseFallbackTexture(): boolean;
  38358. static set UseFallbackTexture(value: boolean);
  38359. /**
  38360. * Use this object to register external classes like custom textures or material
  38361. * to allow the laoders to instantiate them
  38362. */
  38363. static get RegisteredExternalClasses(): {
  38364. [key: string]: Object;
  38365. };
  38366. static set RegisteredExternalClasses(classes: {
  38367. [key: string]: Object;
  38368. });
  38369. /**
  38370. * Texture content used if a texture cannot loaded
  38371. * @ignorenaming
  38372. */
  38373. static get fallbackTexture(): string;
  38374. static set fallbackTexture(value: string);
  38375. /**
  38376. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38377. * @param u defines the coordinate on X axis
  38378. * @param v defines the coordinate on Y axis
  38379. * @param width defines the width of the source data
  38380. * @param height defines the height of the source data
  38381. * @param pixels defines the source byte array
  38382. * @param color defines the output color
  38383. */
  38384. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38385. /**
  38386. * Interpolates between a and b via alpha
  38387. * @param a The lower value (returned when alpha = 0)
  38388. * @param b The upper value (returned when alpha = 1)
  38389. * @param alpha The interpolation-factor
  38390. * @return The mixed value
  38391. */
  38392. static Mix(a: number, b: number, alpha: number): number;
  38393. /**
  38394. * Tries to instantiate a new object from a given class name
  38395. * @param className defines the class name to instantiate
  38396. * @returns the new object or null if the system was not able to do the instantiation
  38397. */
  38398. static Instantiate(className: string): any;
  38399. /**
  38400. * Provides a slice function that will work even on IE
  38401. * @param data defines the array to slice
  38402. * @param start defines the start of the data (optional)
  38403. * @param end defines the end of the data (optional)
  38404. * @returns the new sliced array
  38405. */
  38406. static Slice<T>(data: T, start?: number, end?: number): T;
  38407. /**
  38408. * Polyfill for setImmediate
  38409. * @param action defines the action to execute after the current execution block
  38410. */
  38411. static SetImmediate(action: () => void): void;
  38412. /**
  38413. * Function indicating if a number is an exponent of 2
  38414. * @param value defines the value to test
  38415. * @returns true if the value is an exponent of 2
  38416. */
  38417. static IsExponentOfTwo(value: number): boolean;
  38418. private static _tmpFloatArray;
  38419. /**
  38420. * Returns the nearest 32-bit single precision float representation of a Number
  38421. * @param value A Number. If the parameter is of a different type, it will get converted
  38422. * to a number or to NaN if it cannot be converted
  38423. * @returns number
  38424. */
  38425. static FloatRound(value: number): number;
  38426. /**
  38427. * Extracts the filename from a path
  38428. * @param path defines the path to use
  38429. * @returns the filename
  38430. */
  38431. static GetFilename(path: string): string;
  38432. /**
  38433. * Extracts the "folder" part of a path (everything before the filename).
  38434. * @param uri The URI to extract the info from
  38435. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38436. * @returns The "folder" part of the path
  38437. */
  38438. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38439. /**
  38440. * Extracts text content from a DOM element hierarchy
  38441. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38442. */
  38443. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38444. /**
  38445. * Convert an angle in radians to degrees
  38446. * @param angle defines the angle to convert
  38447. * @returns the angle in degrees
  38448. */
  38449. static ToDegrees(angle: number): number;
  38450. /**
  38451. * Convert an angle in degrees to radians
  38452. * @param angle defines the angle to convert
  38453. * @returns the angle in radians
  38454. */
  38455. static ToRadians(angle: number): number;
  38456. /**
  38457. * Returns an array if obj is not an array
  38458. * @param obj defines the object to evaluate as an array
  38459. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38460. * @returns either obj directly if obj is an array or a new array containing obj
  38461. */
  38462. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38463. /**
  38464. * Gets the pointer prefix to use
  38465. * @param engine defines the engine we are finding the prefix for
  38466. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38467. */
  38468. static GetPointerPrefix(engine: Engine): string;
  38469. /**
  38470. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38471. * @param url define the url we are trying
  38472. * @param element define the dom element where to configure the cors policy
  38473. */
  38474. static SetCorsBehavior(url: string | string[], element: {
  38475. crossOrigin: string | null;
  38476. }): void;
  38477. /**
  38478. * Removes unwanted characters from an url
  38479. * @param url defines the url to clean
  38480. * @returns the cleaned url
  38481. */
  38482. static CleanUrl(url: string): string;
  38483. /**
  38484. * Gets or sets a function used to pre-process url before using them to load assets
  38485. */
  38486. static get PreprocessUrl(): (url: string) => string;
  38487. static set PreprocessUrl(processor: (url: string) => string);
  38488. /**
  38489. * Loads an image as an HTMLImageElement.
  38490. * @param input url string, ArrayBuffer, or Blob to load
  38491. * @param onLoad callback called when the image successfully loads
  38492. * @param onError callback called when the image fails to load
  38493. * @param offlineProvider offline provider for caching
  38494. * @param mimeType optional mime type
  38495. * @returns the HTMLImageElement of the loaded image
  38496. */
  38497. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38498. /**
  38499. * Loads a file from a url
  38500. * @param url url string, ArrayBuffer, or Blob to load
  38501. * @param onSuccess callback called when the file successfully loads
  38502. * @param onProgress callback called while file is loading (if the server supports this mode)
  38503. * @param offlineProvider defines the offline provider for caching
  38504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38505. * @param onError callback called when the file fails to load
  38506. * @returns a file request object
  38507. */
  38508. 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;
  38509. /**
  38510. * Loads a file from a url
  38511. * @param url the file url to load
  38512. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38513. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38514. */
  38515. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38516. /**
  38517. * Load a script (identified by an url). When the url returns, the
  38518. * content of this file is added into a new script element, attached to the DOM (body element)
  38519. * @param scriptUrl defines the url of the script to laod
  38520. * @param onSuccess defines the callback called when the script is loaded
  38521. * @param onError defines the callback to call if an error occurs
  38522. * @param scriptId defines the id of the script element
  38523. */
  38524. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38525. /**
  38526. * Load an asynchronous script (identified by an url). When the url returns, the
  38527. * content of this file is added into a new script element, attached to the DOM (body element)
  38528. * @param scriptUrl defines the url of the script to laod
  38529. * @param scriptId defines the id of the script element
  38530. * @returns a promise request object
  38531. */
  38532. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38533. /**
  38534. * Loads a file from a blob
  38535. * @param fileToLoad defines the blob to use
  38536. * @param callback defines the callback to call when data is loaded
  38537. * @param progressCallback defines the callback to call during loading process
  38538. * @returns a file request object
  38539. */
  38540. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38541. /**
  38542. * Reads a file from a File object
  38543. * @param file defines the file to load
  38544. * @param onSuccess defines the callback to call when data is loaded
  38545. * @param onProgress defines the callback to call during loading process
  38546. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38547. * @param onError defines the callback to call when an error occurs
  38548. * @returns a file request object
  38549. */
  38550. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38551. /**
  38552. * Creates a data url from a given string content
  38553. * @param content defines the content to convert
  38554. * @returns the new data url link
  38555. */
  38556. static FileAsURL(content: string): string;
  38557. /**
  38558. * Format the given number to a specific decimal format
  38559. * @param value defines the number to format
  38560. * @param decimals defines the number of decimals to use
  38561. * @returns the formatted string
  38562. */
  38563. static Format(value: number, decimals?: number): string;
  38564. /**
  38565. * Tries to copy an object by duplicating every property
  38566. * @param source defines the source object
  38567. * @param destination defines the target object
  38568. * @param doNotCopyList defines a list of properties to avoid
  38569. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38570. */
  38571. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38572. /**
  38573. * Gets a boolean indicating if the given object has no own property
  38574. * @param obj defines the object to test
  38575. * @returns true if object has no own property
  38576. */
  38577. static IsEmpty(obj: any): boolean;
  38578. /**
  38579. * Function used to register events at window level
  38580. * @param windowElement defines the Window object to use
  38581. * @param events defines the events to register
  38582. */
  38583. static RegisterTopRootEvents(windowElement: Window, events: {
  38584. name: string;
  38585. handler: Nullable<(e: FocusEvent) => any>;
  38586. }[]): void;
  38587. /**
  38588. * Function used to unregister events from window level
  38589. * @param windowElement defines the Window object to use
  38590. * @param events defines the events to unregister
  38591. */
  38592. static UnregisterTopRootEvents(windowElement: Window, events: {
  38593. name: string;
  38594. handler: Nullable<(e: FocusEvent) => any>;
  38595. }[]): void;
  38596. /**
  38597. * @ignore
  38598. */
  38599. static _ScreenshotCanvas: HTMLCanvasElement;
  38600. /**
  38601. * Dumps the current bound framebuffer
  38602. * @param width defines the rendering width
  38603. * @param height defines the rendering height
  38604. * @param engine defines the hosting engine
  38605. * @param successCallback defines the callback triggered once the data are available
  38606. * @param mimeType defines the mime type of the result
  38607. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38608. */
  38609. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38610. /**
  38611. * Converts the canvas data to blob.
  38612. * This acts as a polyfill for browsers not supporting the to blob function.
  38613. * @param canvas Defines the canvas to extract the data from
  38614. * @param successCallback Defines the callback triggered once the data are available
  38615. * @param mimeType Defines the mime type of the result
  38616. */
  38617. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38618. /**
  38619. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38620. * @param successCallback defines the callback triggered once the data are available
  38621. * @param mimeType defines the mime type of the result
  38622. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38623. */
  38624. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38625. /**
  38626. * Downloads a blob in the browser
  38627. * @param blob defines the blob to download
  38628. * @param fileName defines the name of the downloaded file
  38629. */
  38630. static Download(blob: Blob, fileName: string): void;
  38631. /**
  38632. * Captures a screenshot of the current rendering
  38633. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38634. * @param engine defines the rendering engine
  38635. * @param camera defines the source camera
  38636. * @param size This parameter can be set to a single number or to an object with the
  38637. * following (optional) properties: precision, width, height. If a single number is passed,
  38638. * it will be used for both width and height. If an object is passed, the screenshot size
  38639. * will be derived from the parameters. The precision property is a multiplier allowing
  38640. * rendering at a higher or lower resolution
  38641. * @param successCallback defines the callback receives a single parameter which contains the
  38642. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38643. * src parameter of an <img> to display it
  38644. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38645. * Check your browser for supported MIME types
  38646. */
  38647. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38648. /**
  38649. * Captures a screenshot of the current rendering
  38650. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38651. * @param engine defines the rendering engine
  38652. * @param camera defines the source camera
  38653. * @param size This parameter can be set to a single number or to an object with the
  38654. * following (optional) properties: precision, width, height. If a single number is passed,
  38655. * it will be used for both width and height. If an object is passed, the screenshot size
  38656. * will be derived from the parameters. The precision property is a multiplier allowing
  38657. * rendering at a higher or lower resolution
  38658. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38659. * Check your browser for supported MIME types
  38660. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38661. * to the src parameter of an <img> to display it
  38662. */
  38663. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38664. /**
  38665. * Generates an image screenshot from the specified camera.
  38666. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38667. * @param engine The engine to use for rendering
  38668. * @param camera The camera to use for rendering
  38669. * @param size This parameter can be set to a single number or to an object with the
  38670. * following (optional) properties: precision, width, height. If a single number is passed,
  38671. * it will be used for both width and height. If an object is passed, the screenshot size
  38672. * will be derived from the parameters. The precision property is a multiplier allowing
  38673. * rendering at a higher or lower resolution
  38674. * @param successCallback The callback receives a single parameter which contains the
  38675. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38676. * src parameter of an <img> to display it
  38677. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38678. * Check your browser for supported MIME types
  38679. * @param samples Texture samples (default: 1)
  38680. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38681. * @param fileName A name for for the downloaded file.
  38682. */
  38683. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38684. /**
  38685. * Generates an image screenshot from the specified camera.
  38686. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38687. * @param engine The engine to use for rendering
  38688. * @param camera The camera to use for rendering
  38689. * @param size This parameter can be set to a single number or to an object with the
  38690. * following (optional) properties: precision, width, height. If a single number is passed,
  38691. * it will be used for both width and height. If an object is passed, the screenshot size
  38692. * will be derived from the parameters. The precision property is a multiplier allowing
  38693. * rendering at a higher or lower resolution
  38694. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38695. * Check your browser for supported MIME types
  38696. * @param samples Texture samples (default: 1)
  38697. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38698. * @param fileName A name for for the downloaded file.
  38699. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38700. * to the src parameter of an <img> to display it
  38701. */
  38702. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38703. /**
  38704. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38705. * Be aware Math.random() could cause collisions, but:
  38706. * "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"
  38707. * @returns a pseudo random id
  38708. */
  38709. static RandomId(): string;
  38710. /**
  38711. * Test if the given uri is a base64 string
  38712. * @param uri The uri to test
  38713. * @return True if the uri is a base64 string or false otherwise
  38714. */
  38715. static IsBase64(uri: string): boolean;
  38716. /**
  38717. * Decode the given base64 uri.
  38718. * @param uri The uri to decode
  38719. * @return The decoded base64 data.
  38720. */
  38721. static DecodeBase64(uri: string): ArrayBuffer;
  38722. /**
  38723. * Gets the absolute url.
  38724. * @param url the input url
  38725. * @return the absolute url
  38726. */
  38727. static GetAbsoluteUrl(url: string): string;
  38728. /**
  38729. * No log
  38730. */
  38731. static readonly NoneLogLevel: number;
  38732. /**
  38733. * Only message logs
  38734. */
  38735. static readonly MessageLogLevel: number;
  38736. /**
  38737. * Only warning logs
  38738. */
  38739. static readonly WarningLogLevel: number;
  38740. /**
  38741. * Only error logs
  38742. */
  38743. static readonly ErrorLogLevel: number;
  38744. /**
  38745. * All logs
  38746. */
  38747. static readonly AllLogLevel: number;
  38748. /**
  38749. * Gets a value indicating the number of loading errors
  38750. * @ignorenaming
  38751. */
  38752. static get errorsCount(): number;
  38753. /**
  38754. * Callback called when a new log is added
  38755. */
  38756. static OnNewCacheEntry: (entry: string) => void;
  38757. /**
  38758. * Log a message to the console
  38759. * @param message defines the message to log
  38760. */
  38761. static Log(message: string): void;
  38762. /**
  38763. * Write a warning message to the console
  38764. * @param message defines the message to log
  38765. */
  38766. static Warn(message: string): void;
  38767. /**
  38768. * Write an error message to the console
  38769. * @param message defines the message to log
  38770. */
  38771. static Error(message: string): void;
  38772. /**
  38773. * Gets current log cache (list of logs)
  38774. */
  38775. static get LogCache(): string;
  38776. /**
  38777. * Clears the log cache
  38778. */
  38779. static ClearLogCache(): void;
  38780. /**
  38781. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38782. */
  38783. static set LogLevels(level: number);
  38784. /**
  38785. * Checks if the window object exists
  38786. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38787. */
  38788. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38789. /**
  38790. * No performance log
  38791. */
  38792. static readonly PerformanceNoneLogLevel: number;
  38793. /**
  38794. * Use user marks to log performance
  38795. */
  38796. static readonly PerformanceUserMarkLogLevel: number;
  38797. /**
  38798. * Log performance to the console
  38799. */
  38800. static readonly PerformanceConsoleLogLevel: number;
  38801. private static _performance;
  38802. /**
  38803. * Sets the current performance log level
  38804. */
  38805. static set PerformanceLogLevel(level: number);
  38806. private static _StartPerformanceCounterDisabled;
  38807. private static _EndPerformanceCounterDisabled;
  38808. private static _StartUserMark;
  38809. private static _EndUserMark;
  38810. private static _StartPerformanceConsole;
  38811. private static _EndPerformanceConsole;
  38812. /**
  38813. * Starts a performance counter
  38814. */
  38815. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38816. /**
  38817. * Ends a specific performance coutner
  38818. */
  38819. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38820. /**
  38821. * Gets either window.performance.now() if supported or Date.now() else
  38822. */
  38823. static get Now(): number;
  38824. /**
  38825. * This method will return the name of the class used to create the instance of the given object.
  38826. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38827. * @param object the object to get the class name from
  38828. * @param isType defines if the object is actually a type
  38829. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38830. */
  38831. static GetClassName(object: any, isType?: boolean): string;
  38832. /**
  38833. * Gets the first element of an array satisfying a given predicate
  38834. * @param array defines the array to browse
  38835. * @param predicate defines the predicate to use
  38836. * @returns null if not found or the element
  38837. */
  38838. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38839. /**
  38840. * This method will return the name of the full name of the class, including its owning module (if any).
  38841. * 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).
  38842. * @param object the object to get the class name from
  38843. * @param isType defines if the object is actually a type
  38844. * @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.
  38845. * @ignorenaming
  38846. */
  38847. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38848. /**
  38849. * Returns a promise that resolves after the given amount of time.
  38850. * @param delay Number of milliseconds to delay
  38851. * @returns Promise that resolves after the given amount of time
  38852. */
  38853. static DelayAsync(delay: number): Promise<void>;
  38854. /**
  38855. * Utility function to detect if the current user agent is Safari
  38856. * @returns whether or not the current user agent is safari
  38857. */
  38858. static IsSafari(): boolean;
  38859. }
  38860. /**
  38861. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38862. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38863. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38864. * @param name The name of the class, case should be preserved
  38865. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38866. */
  38867. export function className(name: string, module?: string): (target: Object) => void;
  38868. /**
  38869. * An implementation of a loop for asynchronous functions.
  38870. */
  38871. export class AsyncLoop {
  38872. /**
  38873. * Defines the number of iterations for the loop
  38874. */
  38875. iterations: number;
  38876. /**
  38877. * Defines the current index of the loop.
  38878. */
  38879. index: number;
  38880. private _done;
  38881. private _fn;
  38882. private _successCallback;
  38883. /**
  38884. * Constructor.
  38885. * @param iterations the number of iterations.
  38886. * @param func the function to run each iteration
  38887. * @param successCallback the callback that will be called upon succesful execution
  38888. * @param offset starting offset.
  38889. */
  38890. constructor(
  38891. /**
  38892. * Defines the number of iterations for the loop
  38893. */
  38894. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38895. /**
  38896. * Execute the next iteration. Must be called after the last iteration was finished.
  38897. */
  38898. executeNext(): void;
  38899. /**
  38900. * Break the loop and run the success callback.
  38901. */
  38902. breakLoop(): void;
  38903. /**
  38904. * Create and run an async loop.
  38905. * @param iterations the number of iterations.
  38906. * @param fn the function to run each iteration
  38907. * @param successCallback the callback that will be called upon succesful execution
  38908. * @param offset starting offset.
  38909. * @returns the created async loop object
  38910. */
  38911. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38912. /**
  38913. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38914. * @param iterations total number of iterations
  38915. * @param syncedIterations number of synchronous iterations in each async iteration.
  38916. * @param fn the function to call each iteration.
  38917. * @param callback a success call back that will be called when iterating stops.
  38918. * @param breakFunction a break condition (optional)
  38919. * @param timeout timeout settings for the setTimeout function. default - 0.
  38920. * @returns the created async loop object
  38921. */
  38922. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38923. }
  38924. }
  38925. declare module BABYLON {
  38926. /**
  38927. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38928. * The underlying implementation relies on an associative array to ensure the best performances.
  38929. * The value can be anything including 'null' but except 'undefined'
  38930. */
  38931. export class StringDictionary<T> {
  38932. /**
  38933. * This will clear this dictionary and copy the content from the 'source' one.
  38934. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38935. * @param source the dictionary to take the content from and copy to this dictionary
  38936. */
  38937. copyFrom(source: StringDictionary<T>): void;
  38938. /**
  38939. * Get a value based from its key
  38940. * @param key the given key to get the matching value from
  38941. * @return the value if found, otherwise undefined is returned
  38942. */
  38943. get(key: string): T | undefined;
  38944. /**
  38945. * Get a value from its key or add it if it doesn't exist.
  38946. * This method will ensure you that a given key/data will be present in the dictionary.
  38947. * @param key the given key to get the matching value from
  38948. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38949. * The factory will only be invoked if there's no data for the given key.
  38950. * @return the value corresponding to the key.
  38951. */
  38952. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38953. /**
  38954. * Get a value from its key if present in the dictionary otherwise add it
  38955. * @param key the key to get the value from
  38956. * @param val if there's no such key/value pair in the dictionary add it with this value
  38957. * @return the value corresponding to the key
  38958. */
  38959. getOrAdd(key: string, val: T): T;
  38960. /**
  38961. * Check if there's a given key in the dictionary
  38962. * @param key the key to check for
  38963. * @return true if the key is present, false otherwise
  38964. */
  38965. contains(key: string): boolean;
  38966. /**
  38967. * Add a new key and its corresponding value
  38968. * @param key the key to add
  38969. * @param value the value corresponding to the key
  38970. * @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
  38971. */
  38972. add(key: string, value: T): boolean;
  38973. /**
  38974. * Update a specific value associated to a key
  38975. * @param key defines the key to use
  38976. * @param value defines the value to store
  38977. * @returns true if the value was updated (or false if the key was not found)
  38978. */
  38979. set(key: string, value: T): boolean;
  38980. /**
  38981. * Get the element of the given key and remove it from the dictionary
  38982. * @param key defines the key to search
  38983. * @returns the value associated with the key or null if not found
  38984. */
  38985. getAndRemove(key: string): Nullable<T>;
  38986. /**
  38987. * Remove a key/value from the dictionary.
  38988. * @param key the key to remove
  38989. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38990. */
  38991. remove(key: string): boolean;
  38992. /**
  38993. * Clear the whole content of the dictionary
  38994. */
  38995. clear(): void;
  38996. /**
  38997. * Gets the current count
  38998. */
  38999. get count(): number;
  39000. /**
  39001. * Execute a callback on each key/val of the dictionary.
  39002. * Note that you can remove any element in this dictionary in the callback implementation
  39003. * @param callback the callback to execute on a given key/value pair
  39004. */
  39005. forEach(callback: (key: string, val: T) => void): void;
  39006. /**
  39007. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39008. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39009. * Note that you can remove any element in this dictionary in the callback implementation
  39010. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39011. * @returns the first item
  39012. */
  39013. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39014. private _count;
  39015. private _data;
  39016. }
  39017. }
  39018. declare module BABYLON {
  39019. /** @hidden */
  39020. export interface ICollisionCoordinator {
  39021. createCollider(): Collider;
  39022. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39023. init(scene: Scene): void;
  39024. }
  39025. /** @hidden */
  39026. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39027. private _scene;
  39028. private _scaledPosition;
  39029. private _scaledVelocity;
  39030. private _finalPosition;
  39031. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39032. createCollider(): Collider;
  39033. init(scene: Scene): void;
  39034. private _collideWithWorld;
  39035. }
  39036. }
  39037. declare module BABYLON {
  39038. /**
  39039. * Class used to manage all inputs for the scene.
  39040. */
  39041. export class InputManager {
  39042. /** The distance in pixel that you have to move to prevent some events */
  39043. static DragMovementThreshold: number;
  39044. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39045. static LongPressDelay: number;
  39046. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39047. static DoubleClickDelay: number;
  39048. /** If you need to check double click without raising a single click at first click, enable this flag */
  39049. static ExclusiveDoubleClickMode: boolean;
  39050. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  39051. private _alreadyAttached;
  39052. private _wheelEventName;
  39053. private _onPointerMove;
  39054. private _onPointerDown;
  39055. private _onPointerUp;
  39056. private _initClickEvent;
  39057. private _initActionManager;
  39058. private _delayedSimpleClick;
  39059. private _delayedSimpleClickTimeout;
  39060. private _previousDelayedSimpleClickTimeout;
  39061. private _meshPickProceed;
  39062. private _previousButtonPressed;
  39063. private _currentPickResult;
  39064. private _previousPickResult;
  39065. private _totalPointersPressed;
  39066. private _doubleClickOccured;
  39067. private _pointerOverMesh;
  39068. private _pickedDownMesh;
  39069. private _pickedUpMesh;
  39070. private _pointerX;
  39071. private _pointerY;
  39072. private _unTranslatedPointerX;
  39073. private _unTranslatedPointerY;
  39074. private _startingPointerPosition;
  39075. private _previousStartingPointerPosition;
  39076. private _startingPointerTime;
  39077. private _previousStartingPointerTime;
  39078. private _pointerCaptures;
  39079. private _meshUnderPointerId;
  39080. private _onKeyDown;
  39081. private _onKeyUp;
  39082. private _onCanvasFocusObserver;
  39083. private _onCanvasBlurObserver;
  39084. private _scene;
  39085. /**
  39086. * Creates a new InputManager
  39087. * @param scene defines the hosting scene
  39088. */
  39089. constructor(scene: Scene);
  39090. /**
  39091. * Gets the mesh that is currently under the pointer
  39092. */
  39093. get meshUnderPointer(): Nullable<AbstractMesh>;
  39094. /**
  39095. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39096. * @param pointerId the pointer id to use
  39097. * @returns The mesh under this pointer id or null if not found
  39098. */
  39099. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39100. /**
  39101. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39102. */
  39103. get unTranslatedPointer(): Vector2;
  39104. /**
  39105. * Gets or sets the current on-screen X position of the pointer
  39106. */
  39107. get pointerX(): number;
  39108. set pointerX(value: number);
  39109. /**
  39110. * Gets or sets the current on-screen Y position of the pointer
  39111. */
  39112. get pointerY(): number;
  39113. set pointerY(value: number);
  39114. private _updatePointerPosition;
  39115. private _processPointerMove;
  39116. private _setRayOnPointerInfo;
  39117. private _checkPrePointerObservable;
  39118. /**
  39119. * Use this method to simulate a pointer move on a mesh
  39120. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39121. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39122. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39123. */
  39124. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39125. /**
  39126. * Use this method to simulate a pointer down on a mesh
  39127. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39128. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39129. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39130. */
  39131. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39132. private _processPointerDown;
  39133. /** @hidden */
  39134. _isPointerSwiping(): boolean;
  39135. /**
  39136. * Use this method to simulate a pointer up on a mesh
  39137. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39138. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39139. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39140. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39141. */
  39142. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39143. private _processPointerUp;
  39144. /**
  39145. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39146. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39147. * @returns true if the pointer was captured
  39148. */
  39149. isPointerCaptured(pointerId?: number): boolean;
  39150. /**
  39151. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39152. * @param attachUp defines if you want to attach events to pointerup
  39153. * @param attachDown defines if you want to attach events to pointerdown
  39154. * @param attachMove defines if you want to attach events to pointermove
  39155. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39156. */
  39157. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39158. /**
  39159. * Detaches all event handlers
  39160. */
  39161. detachControl(): void;
  39162. /**
  39163. * Force the value of meshUnderPointer
  39164. * @param mesh defines the mesh to use
  39165. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39166. */
  39167. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39168. /**
  39169. * Gets the mesh under the pointer
  39170. * @returns a Mesh or null if no mesh is under the pointer
  39171. */
  39172. getPointerOverMesh(): Nullable<AbstractMesh>;
  39173. }
  39174. }
  39175. declare module BABYLON {
  39176. /**
  39177. * This class defines the direct association between an animation and a target
  39178. */
  39179. export class TargetedAnimation {
  39180. /**
  39181. * Animation to perform
  39182. */
  39183. animation: Animation;
  39184. /**
  39185. * Target to animate
  39186. */
  39187. target: any;
  39188. /**
  39189. * Returns the string "TargetedAnimation"
  39190. * @returns "TargetedAnimation"
  39191. */
  39192. getClassName(): string;
  39193. /**
  39194. * Serialize the object
  39195. * @returns the JSON object representing the current entity
  39196. */
  39197. serialize(): any;
  39198. }
  39199. /**
  39200. * Use this class to create coordinated animations on multiple targets
  39201. */
  39202. export class AnimationGroup implements IDisposable {
  39203. /** The name of the animation group */
  39204. name: string;
  39205. private _scene;
  39206. private _targetedAnimations;
  39207. private _animatables;
  39208. private _from;
  39209. private _to;
  39210. private _isStarted;
  39211. private _isPaused;
  39212. private _speedRatio;
  39213. private _loopAnimation;
  39214. private _isAdditive;
  39215. /**
  39216. * Gets or sets the unique id of the node
  39217. */
  39218. uniqueId: number;
  39219. /**
  39220. * This observable will notify when one animation have ended
  39221. */
  39222. onAnimationEndObservable: Observable<TargetedAnimation>;
  39223. /**
  39224. * Observer raised when one animation loops
  39225. */
  39226. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39227. /**
  39228. * Observer raised when all animations have looped
  39229. */
  39230. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39231. /**
  39232. * This observable will notify when all animations have ended.
  39233. */
  39234. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39235. /**
  39236. * This observable will notify when all animations have paused.
  39237. */
  39238. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39239. /**
  39240. * This observable will notify when all animations are playing.
  39241. */
  39242. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39243. /**
  39244. * Gets the first frame
  39245. */
  39246. get from(): number;
  39247. /**
  39248. * Gets the last frame
  39249. */
  39250. get to(): number;
  39251. /**
  39252. * Define if the animations are started
  39253. */
  39254. get isStarted(): boolean;
  39255. /**
  39256. * Gets a value indicating that the current group is playing
  39257. */
  39258. get isPlaying(): boolean;
  39259. /**
  39260. * Gets or sets the speed ratio to use for all animations
  39261. */
  39262. get speedRatio(): number;
  39263. /**
  39264. * Gets or sets the speed ratio to use for all animations
  39265. */
  39266. set speedRatio(value: number);
  39267. /**
  39268. * Gets or sets if all animations should loop or not
  39269. */
  39270. get loopAnimation(): boolean;
  39271. set loopAnimation(value: boolean);
  39272. /**
  39273. * Gets or sets if all animations should be evaluated additively
  39274. */
  39275. get isAdditive(): boolean;
  39276. set isAdditive(value: boolean);
  39277. /**
  39278. * Gets the targeted animations for this animation group
  39279. */
  39280. get targetedAnimations(): Array<TargetedAnimation>;
  39281. /**
  39282. * returning the list of animatables controlled by this animation group.
  39283. */
  39284. get animatables(): Array<Animatable>;
  39285. /**
  39286. * Gets the list of target animations
  39287. */
  39288. get children(): TargetedAnimation[];
  39289. /**
  39290. * Instantiates a new Animation Group.
  39291. * This helps managing several animations at once.
  39292. * @see https://doc.babylonjs.com/how_to/group
  39293. * @param name Defines the name of the group
  39294. * @param scene Defines the scene the group belongs to
  39295. */
  39296. constructor(
  39297. /** The name of the animation group */
  39298. name: string, scene?: Nullable<Scene>);
  39299. /**
  39300. * Add an animation (with its target) in the group
  39301. * @param animation defines the animation we want to add
  39302. * @param target defines the target of the animation
  39303. * @returns the TargetedAnimation object
  39304. */
  39305. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39306. /**
  39307. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39308. * It can add constant keys at begin or end
  39309. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39310. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39311. * @returns the animation group
  39312. */
  39313. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39314. private _animationLoopCount;
  39315. private _animationLoopFlags;
  39316. private _processLoop;
  39317. /**
  39318. * Start all animations on given targets
  39319. * @param loop defines if animations must loop
  39320. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39321. * @param from defines the from key (optional)
  39322. * @param to defines the to key (optional)
  39323. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39324. * @returns the current animation group
  39325. */
  39326. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39327. /**
  39328. * Pause all animations
  39329. * @returns the animation group
  39330. */
  39331. pause(): AnimationGroup;
  39332. /**
  39333. * Play all animations to initial state
  39334. * This function will start() the animations if they were not started or will restart() them if they were paused
  39335. * @param loop defines if animations must loop
  39336. * @returns the animation group
  39337. */
  39338. play(loop?: boolean): AnimationGroup;
  39339. /**
  39340. * Reset all animations to initial state
  39341. * @returns the animation group
  39342. */
  39343. reset(): AnimationGroup;
  39344. /**
  39345. * Restart animations from key 0
  39346. * @returns the animation group
  39347. */
  39348. restart(): AnimationGroup;
  39349. /**
  39350. * Stop all animations
  39351. * @returns the animation group
  39352. */
  39353. stop(): AnimationGroup;
  39354. /**
  39355. * Set animation weight for all animatables
  39356. * @param weight defines the weight to use
  39357. * @return the animationGroup
  39358. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39359. */
  39360. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39361. /**
  39362. * Synchronize and normalize all animatables with a source animatable
  39363. * @param root defines the root animatable to synchronize with
  39364. * @return the animationGroup
  39365. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39366. */
  39367. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39368. /**
  39369. * Goes to a specific frame in this animation group
  39370. * @param frame the frame number to go to
  39371. * @return the animationGroup
  39372. */
  39373. goToFrame(frame: number): AnimationGroup;
  39374. /**
  39375. * Dispose all associated resources
  39376. */
  39377. dispose(): void;
  39378. private _checkAnimationGroupEnded;
  39379. /**
  39380. * Clone the current animation group and returns a copy
  39381. * @param newName defines the name of the new group
  39382. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39383. * @returns the new aniamtion group
  39384. */
  39385. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39386. /**
  39387. * Serializes the animationGroup to an object
  39388. * @returns Serialized object
  39389. */
  39390. serialize(): any;
  39391. /**
  39392. * Returns a new AnimationGroup object parsed from the source provided.
  39393. * @param parsedAnimationGroup defines the source
  39394. * @param scene defines the scene that will receive the animationGroup
  39395. * @returns a new AnimationGroup
  39396. */
  39397. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39398. /**
  39399. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39400. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39401. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39402. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39403. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39404. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39405. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39406. */
  39407. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39408. /**
  39409. * Returns the string "AnimationGroup"
  39410. * @returns "AnimationGroup"
  39411. */
  39412. getClassName(): string;
  39413. /**
  39414. * Creates a detailled string about the object
  39415. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39416. * @returns a string representing the object
  39417. */
  39418. toString(fullDetails?: boolean): string;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. /**
  39423. * Define an interface for all classes that will hold resources
  39424. */
  39425. export interface IDisposable {
  39426. /**
  39427. * Releases all held resources
  39428. */
  39429. dispose(): void;
  39430. }
  39431. /** Interface defining initialization parameters for Scene class */
  39432. export interface SceneOptions {
  39433. /**
  39434. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39435. * It will improve performance when the number of geometries becomes important.
  39436. */
  39437. useGeometryUniqueIdsMap?: boolean;
  39438. /**
  39439. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39440. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39441. */
  39442. useMaterialMeshMap?: boolean;
  39443. /**
  39444. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39445. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39446. */
  39447. useClonedMeshMap?: boolean;
  39448. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39449. virtual?: boolean;
  39450. }
  39451. /**
  39452. * Represents a scene to be rendered by the engine.
  39453. * @see https://doc.babylonjs.com/features/scene
  39454. */
  39455. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39456. /** The fog is deactivated */
  39457. static readonly FOGMODE_NONE: number;
  39458. /** The fog density is following an exponential function */
  39459. static readonly FOGMODE_EXP: number;
  39460. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39461. static readonly FOGMODE_EXP2: number;
  39462. /** The fog density is following a linear function. */
  39463. static readonly FOGMODE_LINEAR: number;
  39464. /**
  39465. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39466. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39467. */
  39468. static MinDeltaTime: number;
  39469. /**
  39470. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39471. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39472. */
  39473. static MaxDeltaTime: number;
  39474. /**
  39475. * Factory used to create the default material.
  39476. * @param name The name of the material to create
  39477. * @param scene The scene to create the material for
  39478. * @returns The default material
  39479. */
  39480. static DefaultMaterialFactory(scene: Scene): Material;
  39481. /**
  39482. * Factory used to create the a collision coordinator.
  39483. * @returns The collision coordinator
  39484. */
  39485. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39486. /** @hidden */
  39487. _inputManager: InputManager;
  39488. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39489. cameraToUseForPointers: Nullable<Camera>;
  39490. /** @hidden */
  39491. readonly _isScene: boolean;
  39492. /** @hidden */
  39493. _blockEntityCollection: boolean;
  39494. /**
  39495. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39496. */
  39497. autoClear: boolean;
  39498. /**
  39499. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39500. */
  39501. autoClearDepthAndStencil: boolean;
  39502. /**
  39503. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39504. */
  39505. clearColor: Color4;
  39506. /**
  39507. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39508. */
  39509. ambientColor: Color3;
  39510. /**
  39511. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39512. * It should only be one of the following (if not the default embedded one):
  39513. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39514. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39515. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39516. * The material properties need to be setup according to the type of texture in use.
  39517. */
  39518. environmentBRDFTexture: BaseTexture;
  39519. /**
  39520. * Texture used in all pbr material as the reflection texture.
  39521. * As in the majority of the scene they are the same (exception for multi room and so on),
  39522. * this is easier to reference from here than from all the materials.
  39523. */
  39524. get environmentTexture(): Nullable<BaseTexture>;
  39525. /**
  39526. * Texture used in all pbr material as the reflection texture.
  39527. * As in the majority of the scene they are the same (exception for multi room and so on),
  39528. * this is easier to set here than in all the materials.
  39529. */
  39530. set environmentTexture(value: Nullable<BaseTexture>);
  39531. /** @hidden */
  39532. protected _environmentIntensity: number;
  39533. /**
  39534. * Intensity of the environment in all pbr material.
  39535. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39536. * As in the majority of the scene they are the same (exception for multi room and so on),
  39537. * this is easier to reference from here than from all the materials.
  39538. */
  39539. get environmentIntensity(): number;
  39540. /**
  39541. * Intensity of the environment in all pbr material.
  39542. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39543. * As in the majority of the scene they are the same (exception for multi room and so on),
  39544. * this is easier to set here than in all the materials.
  39545. */
  39546. set environmentIntensity(value: number);
  39547. /** @hidden */
  39548. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39549. /**
  39550. * Default image processing configuration used either in the rendering
  39551. * Forward main pass or through the imageProcessingPostProcess if present.
  39552. * As in the majority of the scene they are the same (exception for multi camera),
  39553. * this is easier to reference from here than from all the materials and post process.
  39554. *
  39555. * No setter as we it is a shared configuration, you can set the values instead.
  39556. */
  39557. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39558. private _forceWireframe;
  39559. /**
  39560. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39561. */
  39562. set forceWireframe(value: boolean);
  39563. get forceWireframe(): boolean;
  39564. private _skipFrustumClipping;
  39565. /**
  39566. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39567. */
  39568. set skipFrustumClipping(value: boolean);
  39569. get skipFrustumClipping(): boolean;
  39570. private _forcePointsCloud;
  39571. /**
  39572. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39573. */
  39574. set forcePointsCloud(value: boolean);
  39575. get forcePointsCloud(): boolean;
  39576. /**
  39577. * Gets or sets the active clipplane 1
  39578. */
  39579. clipPlane: Nullable<Plane>;
  39580. /**
  39581. * Gets or sets the active clipplane 2
  39582. */
  39583. clipPlane2: Nullable<Plane>;
  39584. /**
  39585. * Gets or sets the active clipplane 3
  39586. */
  39587. clipPlane3: Nullable<Plane>;
  39588. /**
  39589. * Gets or sets the active clipplane 4
  39590. */
  39591. clipPlane4: Nullable<Plane>;
  39592. /**
  39593. * Gets or sets the active clipplane 5
  39594. */
  39595. clipPlane5: Nullable<Plane>;
  39596. /**
  39597. * Gets or sets the active clipplane 6
  39598. */
  39599. clipPlane6: Nullable<Plane>;
  39600. /**
  39601. * Gets or sets a boolean indicating if animations are enabled
  39602. */
  39603. animationsEnabled: boolean;
  39604. private _animationPropertiesOverride;
  39605. /**
  39606. * Gets or sets the animation properties override
  39607. */
  39608. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39609. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39610. /**
  39611. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39612. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39613. */
  39614. useConstantAnimationDeltaTime: boolean;
  39615. /**
  39616. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39617. * Please note that it requires to run a ray cast through the scene on every frame
  39618. */
  39619. constantlyUpdateMeshUnderPointer: boolean;
  39620. /**
  39621. * Defines the HTML cursor to use when hovering over interactive elements
  39622. */
  39623. hoverCursor: string;
  39624. /**
  39625. * Defines the HTML default cursor to use (empty by default)
  39626. */
  39627. defaultCursor: string;
  39628. /**
  39629. * Defines whether cursors are handled by the scene.
  39630. */
  39631. doNotHandleCursors: boolean;
  39632. /**
  39633. * This is used to call preventDefault() on pointer down
  39634. * in order to block unwanted artifacts like system double clicks
  39635. */
  39636. preventDefaultOnPointerDown: boolean;
  39637. /**
  39638. * This is used to call preventDefault() on pointer up
  39639. * in order to block unwanted artifacts like system double clicks
  39640. */
  39641. preventDefaultOnPointerUp: boolean;
  39642. /**
  39643. * Gets or sets user defined metadata
  39644. */
  39645. metadata: any;
  39646. /**
  39647. * For internal use only. Please do not use.
  39648. */
  39649. reservedDataStore: any;
  39650. /**
  39651. * Gets the name of the plugin used to load this scene (null by default)
  39652. */
  39653. loadingPluginName: string;
  39654. /**
  39655. * Use this array to add regular expressions used to disable offline support for specific urls
  39656. */
  39657. disableOfflineSupportExceptionRules: RegExp[];
  39658. /**
  39659. * An event triggered when the scene is disposed.
  39660. */
  39661. onDisposeObservable: Observable<Scene>;
  39662. private _onDisposeObserver;
  39663. /** Sets a function to be executed when this scene is disposed. */
  39664. set onDispose(callback: () => void);
  39665. /**
  39666. * An event triggered before rendering the scene (right after animations and physics)
  39667. */
  39668. onBeforeRenderObservable: Observable<Scene>;
  39669. private _onBeforeRenderObserver;
  39670. /** Sets a function to be executed before rendering this scene */
  39671. set beforeRender(callback: Nullable<() => void>);
  39672. /**
  39673. * An event triggered after rendering the scene
  39674. */
  39675. onAfterRenderObservable: Observable<Scene>;
  39676. /**
  39677. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39678. */
  39679. onAfterRenderCameraObservable: Observable<Camera>;
  39680. private _onAfterRenderObserver;
  39681. /** Sets a function to be executed after rendering this scene */
  39682. set afterRender(callback: Nullable<() => void>);
  39683. /**
  39684. * An event triggered before animating the scene
  39685. */
  39686. onBeforeAnimationsObservable: Observable<Scene>;
  39687. /**
  39688. * An event triggered after animations processing
  39689. */
  39690. onAfterAnimationsObservable: Observable<Scene>;
  39691. /**
  39692. * An event triggered before draw calls are ready to be sent
  39693. */
  39694. onBeforeDrawPhaseObservable: Observable<Scene>;
  39695. /**
  39696. * An event triggered after draw calls have been sent
  39697. */
  39698. onAfterDrawPhaseObservable: Observable<Scene>;
  39699. /**
  39700. * An event triggered when the scene is ready
  39701. */
  39702. onReadyObservable: Observable<Scene>;
  39703. /**
  39704. * An event triggered before rendering a camera
  39705. */
  39706. onBeforeCameraRenderObservable: Observable<Camera>;
  39707. private _onBeforeCameraRenderObserver;
  39708. /** Sets a function to be executed before rendering a camera*/
  39709. set beforeCameraRender(callback: () => void);
  39710. /**
  39711. * An event triggered after rendering a camera
  39712. */
  39713. onAfterCameraRenderObservable: Observable<Camera>;
  39714. private _onAfterCameraRenderObserver;
  39715. /** Sets a function to be executed after rendering a camera*/
  39716. set afterCameraRender(callback: () => void);
  39717. /**
  39718. * An event triggered when active meshes evaluation is about to start
  39719. */
  39720. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39721. /**
  39722. * An event triggered when active meshes evaluation is done
  39723. */
  39724. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39725. /**
  39726. * An event triggered when particles rendering is about to start
  39727. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39728. */
  39729. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39730. /**
  39731. * An event triggered when particles rendering is done
  39732. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39733. */
  39734. onAfterParticlesRenderingObservable: Observable<Scene>;
  39735. /**
  39736. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39737. */
  39738. onDataLoadedObservable: Observable<Scene>;
  39739. /**
  39740. * An event triggered when a camera is created
  39741. */
  39742. onNewCameraAddedObservable: Observable<Camera>;
  39743. /**
  39744. * An event triggered when a camera is removed
  39745. */
  39746. onCameraRemovedObservable: Observable<Camera>;
  39747. /**
  39748. * An event triggered when a light is created
  39749. */
  39750. onNewLightAddedObservable: Observable<Light>;
  39751. /**
  39752. * An event triggered when a light is removed
  39753. */
  39754. onLightRemovedObservable: Observable<Light>;
  39755. /**
  39756. * An event triggered when a geometry is created
  39757. */
  39758. onNewGeometryAddedObservable: Observable<Geometry>;
  39759. /**
  39760. * An event triggered when a geometry is removed
  39761. */
  39762. onGeometryRemovedObservable: Observable<Geometry>;
  39763. /**
  39764. * An event triggered when a transform node is created
  39765. */
  39766. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39767. /**
  39768. * An event triggered when a transform node is removed
  39769. */
  39770. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39771. /**
  39772. * An event triggered when a mesh is created
  39773. */
  39774. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39775. /**
  39776. * An event triggered when a mesh is removed
  39777. */
  39778. onMeshRemovedObservable: Observable<AbstractMesh>;
  39779. /**
  39780. * An event triggered when a skeleton is created
  39781. */
  39782. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39783. /**
  39784. * An event triggered when a skeleton is removed
  39785. */
  39786. onSkeletonRemovedObservable: Observable<Skeleton>;
  39787. /**
  39788. * An event triggered when a material is created
  39789. */
  39790. onNewMaterialAddedObservable: Observable<Material>;
  39791. /**
  39792. * An event triggered when a material is removed
  39793. */
  39794. onMaterialRemovedObservable: Observable<Material>;
  39795. /**
  39796. * An event triggered when a texture is created
  39797. */
  39798. onNewTextureAddedObservable: Observable<BaseTexture>;
  39799. /**
  39800. * An event triggered when a texture is removed
  39801. */
  39802. onTextureRemovedObservable: Observable<BaseTexture>;
  39803. /**
  39804. * An event triggered when render targets are about to be rendered
  39805. * Can happen multiple times per frame.
  39806. */
  39807. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39808. /**
  39809. * An event triggered when render targets were rendered.
  39810. * Can happen multiple times per frame.
  39811. */
  39812. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39813. /**
  39814. * An event triggered before calculating deterministic simulation step
  39815. */
  39816. onBeforeStepObservable: Observable<Scene>;
  39817. /**
  39818. * An event triggered after calculating deterministic simulation step
  39819. */
  39820. onAfterStepObservable: Observable<Scene>;
  39821. /**
  39822. * An event triggered when the activeCamera property is updated
  39823. */
  39824. onActiveCameraChanged: Observable<Scene>;
  39825. /**
  39826. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39827. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39828. * 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)
  39829. */
  39830. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39831. /**
  39832. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39833. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39834. * 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)
  39835. */
  39836. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39837. /**
  39838. * This Observable will when a mesh has been imported into the scene.
  39839. */
  39840. onMeshImportedObservable: Observable<AbstractMesh>;
  39841. /**
  39842. * This Observable will when an animation file has been imported into the scene.
  39843. */
  39844. onAnimationFileImportedObservable: Observable<Scene>;
  39845. /**
  39846. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39847. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39848. */
  39849. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39850. /** @hidden */
  39851. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39852. /**
  39853. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39854. */
  39855. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39856. /**
  39857. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39858. */
  39859. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39860. /**
  39861. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39862. */
  39863. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39864. /** Callback called when a pointer move is detected */
  39865. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39866. /** Callback called when a pointer down is detected */
  39867. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39868. /** Callback called when a pointer up is detected */
  39869. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39870. /** Callback called when a pointer pick is detected */
  39871. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39872. /**
  39873. * 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).
  39874. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39875. */
  39876. onPrePointerObservable: Observable<PointerInfoPre>;
  39877. /**
  39878. * Observable event triggered each time an input event is received from the rendering canvas
  39879. */
  39880. onPointerObservable: Observable<PointerInfo>;
  39881. /**
  39882. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39883. */
  39884. get unTranslatedPointer(): Vector2;
  39885. /**
  39886. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39887. */
  39888. static get DragMovementThreshold(): number;
  39889. static set DragMovementThreshold(value: number);
  39890. /**
  39891. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39892. */
  39893. static get LongPressDelay(): number;
  39894. static set LongPressDelay(value: number);
  39895. /**
  39896. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39897. */
  39898. static get DoubleClickDelay(): number;
  39899. static set DoubleClickDelay(value: number);
  39900. /** If you need to check double click without raising a single click at first click, enable this flag */
  39901. static get ExclusiveDoubleClickMode(): boolean;
  39902. static set ExclusiveDoubleClickMode(value: boolean);
  39903. /** @hidden */
  39904. _mirroredCameraPosition: Nullable<Vector3>;
  39905. /**
  39906. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39907. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39908. */
  39909. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39910. /**
  39911. * Observable event triggered each time an keyboard event is received from the hosting window
  39912. */
  39913. onKeyboardObservable: Observable<KeyboardInfo>;
  39914. private _useRightHandedSystem;
  39915. /**
  39916. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39917. */
  39918. set useRightHandedSystem(value: boolean);
  39919. get useRightHandedSystem(): boolean;
  39920. private _timeAccumulator;
  39921. private _currentStepId;
  39922. private _currentInternalStep;
  39923. /**
  39924. * Sets the step Id used by deterministic lock step
  39925. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39926. * @param newStepId defines the step Id
  39927. */
  39928. setStepId(newStepId: number): void;
  39929. /**
  39930. * Gets the step Id used by deterministic lock step
  39931. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39932. * @returns the step Id
  39933. */
  39934. getStepId(): number;
  39935. /**
  39936. * Gets the internal step used by deterministic lock step
  39937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39938. * @returns the internal step
  39939. */
  39940. getInternalStep(): number;
  39941. private _fogEnabled;
  39942. /**
  39943. * Gets or sets a boolean indicating if fog is enabled on this scene
  39944. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39945. * (Default is true)
  39946. */
  39947. set fogEnabled(value: boolean);
  39948. get fogEnabled(): boolean;
  39949. private _fogMode;
  39950. /**
  39951. * Gets or sets the fog mode to use
  39952. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39953. * | mode | value |
  39954. * | --- | --- |
  39955. * | FOGMODE_NONE | 0 |
  39956. * | FOGMODE_EXP | 1 |
  39957. * | FOGMODE_EXP2 | 2 |
  39958. * | FOGMODE_LINEAR | 3 |
  39959. */
  39960. set fogMode(value: number);
  39961. get fogMode(): number;
  39962. /**
  39963. * Gets or sets the fog color to use
  39964. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39965. * (Default is Color3(0.2, 0.2, 0.3))
  39966. */
  39967. fogColor: Color3;
  39968. /**
  39969. * Gets or sets the fog density to use
  39970. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39971. * (Default is 0.1)
  39972. */
  39973. fogDensity: number;
  39974. /**
  39975. * Gets or sets the fog start distance to use
  39976. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39977. * (Default is 0)
  39978. */
  39979. fogStart: number;
  39980. /**
  39981. * Gets or sets the fog end distance to use
  39982. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39983. * (Default is 1000)
  39984. */
  39985. fogEnd: number;
  39986. /**
  39987. * Flag indicating that the frame buffer binding is handled by another component
  39988. */
  39989. prePass: boolean;
  39990. private _shadowsEnabled;
  39991. /**
  39992. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39993. */
  39994. set shadowsEnabled(value: boolean);
  39995. get shadowsEnabled(): boolean;
  39996. private _lightsEnabled;
  39997. /**
  39998. * Gets or sets a boolean indicating if lights are enabled on this scene
  39999. */
  40000. set lightsEnabled(value: boolean);
  40001. get lightsEnabled(): boolean;
  40002. /** All of the active cameras added to this scene. */
  40003. activeCameras: Camera[];
  40004. /** @hidden */
  40005. _activeCamera: Nullable<Camera>;
  40006. /** Gets or sets the current active camera */
  40007. get activeCamera(): Nullable<Camera>;
  40008. set activeCamera(value: Nullable<Camera>);
  40009. private _defaultMaterial;
  40010. /** The default material used on meshes when no material is affected */
  40011. get defaultMaterial(): Material;
  40012. /** The default material used on meshes when no material is affected */
  40013. set defaultMaterial(value: Material);
  40014. private _texturesEnabled;
  40015. /**
  40016. * Gets or sets a boolean indicating if textures are enabled on this scene
  40017. */
  40018. set texturesEnabled(value: boolean);
  40019. get texturesEnabled(): boolean;
  40020. /**
  40021. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40022. */
  40023. physicsEnabled: boolean;
  40024. /**
  40025. * Gets or sets a boolean indicating if particles are enabled on this scene
  40026. */
  40027. particlesEnabled: boolean;
  40028. /**
  40029. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40030. */
  40031. spritesEnabled: boolean;
  40032. private _skeletonsEnabled;
  40033. /**
  40034. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40035. */
  40036. set skeletonsEnabled(value: boolean);
  40037. get skeletonsEnabled(): boolean;
  40038. /**
  40039. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40040. */
  40041. lensFlaresEnabled: boolean;
  40042. /**
  40043. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40044. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40045. */
  40046. collisionsEnabled: boolean;
  40047. private _collisionCoordinator;
  40048. /** @hidden */
  40049. get collisionCoordinator(): ICollisionCoordinator;
  40050. /**
  40051. * Defines the gravity applied to this scene (used only for collisions)
  40052. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40053. */
  40054. gravity: Vector3;
  40055. /**
  40056. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40057. */
  40058. postProcessesEnabled: boolean;
  40059. /**
  40060. * Gets the current postprocess manager
  40061. */
  40062. postProcessManager: PostProcessManager;
  40063. /**
  40064. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40065. */
  40066. renderTargetsEnabled: boolean;
  40067. /**
  40068. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40069. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40070. */
  40071. dumpNextRenderTargets: boolean;
  40072. /**
  40073. * The list of user defined render targets added to the scene
  40074. */
  40075. customRenderTargets: RenderTargetTexture[];
  40076. /**
  40077. * Defines if texture loading must be delayed
  40078. * If true, textures will only be loaded when they need to be rendered
  40079. */
  40080. useDelayedTextureLoading: boolean;
  40081. /**
  40082. * Gets the list of meshes imported to the scene through SceneLoader
  40083. */
  40084. importedMeshesFiles: String[];
  40085. /**
  40086. * Gets or sets a boolean indicating if probes are enabled on this scene
  40087. */
  40088. probesEnabled: boolean;
  40089. /**
  40090. * Gets or sets the current offline provider to use to store scene data
  40091. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40092. */
  40093. offlineProvider: IOfflineProvider;
  40094. /**
  40095. * Gets or sets the action manager associated with the scene
  40096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40097. */
  40098. actionManager: AbstractActionManager;
  40099. private _meshesForIntersections;
  40100. /**
  40101. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40102. */
  40103. proceduralTexturesEnabled: boolean;
  40104. private _engine;
  40105. private _totalVertices;
  40106. /** @hidden */
  40107. _activeIndices: PerfCounter;
  40108. /** @hidden */
  40109. _activeParticles: PerfCounter;
  40110. /** @hidden */
  40111. _activeBones: PerfCounter;
  40112. private _animationRatio;
  40113. /** @hidden */
  40114. _animationTimeLast: number;
  40115. /** @hidden */
  40116. _animationTime: number;
  40117. /**
  40118. * Gets or sets a general scale for animation speed
  40119. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40120. */
  40121. animationTimeScale: number;
  40122. /** @hidden */
  40123. _cachedMaterial: Nullable<Material>;
  40124. /** @hidden */
  40125. _cachedEffect: Nullable<Effect>;
  40126. /** @hidden */
  40127. _cachedVisibility: Nullable<number>;
  40128. private _renderId;
  40129. private _frameId;
  40130. private _executeWhenReadyTimeoutId;
  40131. private _intermediateRendering;
  40132. private _viewUpdateFlag;
  40133. private _projectionUpdateFlag;
  40134. /** @hidden */
  40135. _toBeDisposed: Nullable<IDisposable>[];
  40136. private _activeRequests;
  40137. /** @hidden */
  40138. _pendingData: any[];
  40139. private _isDisposed;
  40140. /**
  40141. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40142. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40143. */
  40144. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40145. private _activeMeshes;
  40146. private _processedMaterials;
  40147. private _renderTargets;
  40148. /** @hidden */
  40149. _activeParticleSystems: SmartArray<IParticleSystem>;
  40150. private _activeSkeletons;
  40151. private _softwareSkinnedMeshes;
  40152. private _renderingManager;
  40153. /** @hidden */
  40154. _activeAnimatables: Animatable[];
  40155. private _transformMatrix;
  40156. private _sceneUbo;
  40157. /** @hidden */
  40158. _viewMatrix: Matrix;
  40159. private _projectionMatrix;
  40160. /** @hidden */
  40161. _forcedViewPosition: Nullable<Vector3>;
  40162. /** @hidden */
  40163. _frustumPlanes: Plane[];
  40164. /**
  40165. * Gets the list of frustum planes (built from the active camera)
  40166. */
  40167. get frustumPlanes(): Plane[];
  40168. /**
  40169. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40170. * This is useful if there are more lights that the maximum simulteanous authorized
  40171. */
  40172. requireLightSorting: boolean;
  40173. /** @hidden */
  40174. readonly useMaterialMeshMap: boolean;
  40175. /** @hidden */
  40176. readonly useClonedMeshMap: boolean;
  40177. private _externalData;
  40178. private _uid;
  40179. /**
  40180. * @hidden
  40181. * Backing store of defined scene components.
  40182. */
  40183. _components: ISceneComponent[];
  40184. /**
  40185. * @hidden
  40186. * Backing store of defined scene components.
  40187. */
  40188. _serializableComponents: ISceneSerializableComponent[];
  40189. /**
  40190. * List of components to register on the next registration step.
  40191. */
  40192. private _transientComponents;
  40193. /**
  40194. * Registers the transient components if needed.
  40195. */
  40196. private _registerTransientComponents;
  40197. /**
  40198. * @hidden
  40199. * Add a component to the scene.
  40200. * Note that the ccomponent could be registered on th next frame if this is called after
  40201. * the register component stage.
  40202. * @param component Defines the component to add to the scene
  40203. */
  40204. _addComponent(component: ISceneComponent): void;
  40205. /**
  40206. * @hidden
  40207. * Gets a component from the scene.
  40208. * @param name defines the name of the component to retrieve
  40209. * @returns the component or null if not present
  40210. */
  40211. _getComponent(name: string): Nullable<ISceneComponent>;
  40212. /**
  40213. * @hidden
  40214. * Defines the actions happening before camera updates.
  40215. */
  40216. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40217. /**
  40218. * @hidden
  40219. * Defines the actions happening before clear the canvas.
  40220. */
  40221. _beforeClearStage: Stage<SimpleStageAction>;
  40222. /**
  40223. * @hidden
  40224. * Defines the actions when collecting render targets for the frame.
  40225. */
  40226. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40227. /**
  40228. * @hidden
  40229. * Defines the actions happening for one camera in the frame.
  40230. */
  40231. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40232. /**
  40233. * @hidden
  40234. * Defines the actions happening during the per mesh ready checks.
  40235. */
  40236. _isReadyForMeshStage: Stage<MeshStageAction>;
  40237. /**
  40238. * @hidden
  40239. * Defines the actions happening before evaluate active mesh checks.
  40240. */
  40241. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40242. /**
  40243. * @hidden
  40244. * Defines the actions happening during the evaluate sub mesh checks.
  40245. */
  40246. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40247. /**
  40248. * @hidden
  40249. * Defines the actions happening during the active mesh stage.
  40250. */
  40251. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40252. /**
  40253. * @hidden
  40254. * Defines the actions happening during the per camera render target step.
  40255. */
  40256. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40257. /**
  40258. * @hidden
  40259. * Defines the actions happening just before the active camera is drawing.
  40260. */
  40261. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40262. /**
  40263. * @hidden
  40264. * Defines the actions happening just before a render target is drawing.
  40265. */
  40266. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40267. /**
  40268. * @hidden
  40269. * Defines the actions happening just before a rendering group is drawing.
  40270. */
  40271. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40272. /**
  40273. * @hidden
  40274. * Defines the actions happening just before a mesh is drawing.
  40275. */
  40276. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40277. /**
  40278. * @hidden
  40279. * Defines the actions happening just after a mesh has been drawn.
  40280. */
  40281. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40282. /**
  40283. * @hidden
  40284. * Defines the actions happening just after a rendering group has been drawn.
  40285. */
  40286. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40287. /**
  40288. * @hidden
  40289. * Defines the actions happening just after the active camera has been drawn.
  40290. */
  40291. _afterCameraDrawStage: Stage<CameraStageAction>;
  40292. /**
  40293. * @hidden
  40294. * Defines the actions happening just after a render target has been drawn.
  40295. */
  40296. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40297. /**
  40298. * @hidden
  40299. * Defines the actions happening just after rendering all cameras and computing intersections.
  40300. */
  40301. _afterRenderStage: Stage<SimpleStageAction>;
  40302. /**
  40303. * @hidden
  40304. * Defines the actions happening when a pointer move event happens.
  40305. */
  40306. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40307. /**
  40308. * @hidden
  40309. * Defines the actions happening when a pointer down event happens.
  40310. */
  40311. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40312. /**
  40313. * @hidden
  40314. * Defines the actions happening when a pointer up event happens.
  40315. */
  40316. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40317. /**
  40318. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40319. */
  40320. private geometriesByUniqueId;
  40321. /**
  40322. * Creates a new Scene
  40323. * @param engine defines the engine to use to render this scene
  40324. * @param options defines the scene options
  40325. */
  40326. constructor(engine: Engine, options?: SceneOptions);
  40327. /**
  40328. * Gets a string identifying the name of the class
  40329. * @returns "Scene" string
  40330. */
  40331. getClassName(): string;
  40332. private _defaultMeshCandidates;
  40333. /**
  40334. * @hidden
  40335. */
  40336. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40337. private _defaultSubMeshCandidates;
  40338. /**
  40339. * @hidden
  40340. */
  40341. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40342. /**
  40343. * Sets the default candidate providers for the scene.
  40344. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40345. * and getCollidingSubMeshCandidates to their default function
  40346. */
  40347. setDefaultCandidateProviders(): void;
  40348. /**
  40349. * Gets the mesh that is currently under the pointer
  40350. */
  40351. get meshUnderPointer(): Nullable<AbstractMesh>;
  40352. /**
  40353. * Gets or sets the current on-screen X position of the pointer
  40354. */
  40355. get pointerX(): number;
  40356. set pointerX(value: number);
  40357. /**
  40358. * Gets or sets the current on-screen Y position of the pointer
  40359. */
  40360. get pointerY(): number;
  40361. set pointerY(value: number);
  40362. /**
  40363. * Gets the cached material (ie. the latest rendered one)
  40364. * @returns the cached material
  40365. */
  40366. getCachedMaterial(): Nullable<Material>;
  40367. /**
  40368. * Gets the cached effect (ie. the latest rendered one)
  40369. * @returns the cached effect
  40370. */
  40371. getCachedEffect(): Nullable<Effect>;
  40372. /**
  40373. * Gets the cached visibility state (ie. the latest rendered one)
  40374. * @returns the cached visibility state
  40375. */
  40376. getCachedVisibility(): Nullable<number>;
  40377. /**
  40378. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40379. * @param material defines the current material
  40380. * @param effect defines the current effect
  40381. * @param visibility defines the current visibility state
  40382. * @returns true if one parameter is not cached
  40383. */
  40384. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40385. /**
  40386. * Gets the engine associated with the scene
  40387. * @returns an Engine
  40388. */
  40389. getEngine(): Engine;
  40390. /**
  40391. * Gets the total number of vertices rendered per frame
  40392. * @returns the total number of vertices rendered per frame
  40393. */
  40394. getTotalVertices(): number;
  40395. /**
  40396. * Gets the performance counter for total vertices
  40397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40398. */
  40399. get totalVerticesPerfCounter(): PerfCounter;
  40400. /**
  40401. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40402. * @returns the total number of active indices rendered per frame
  40403. */
  40404. getActiveIndices(): number;
  40405. /**
  40406. * Gets the performance counter for active indices
  40407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40408. */
  40409. get totalActiveIndicesPerfCounter(): PerfCounter;
  40410. /**
  40411. * Gets the total number of active particles rendered per frame
  40412. * @returns the total number of active particles rendered per frame
  40413. */
  40414. getActiveParticles(): number;
  40415. /**
  40416. * Gets the performance counter for active particles
  40417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40418. */
  40419. get activeParticlesPerfCounter(): PerfCounter;
  40420. /**
  40421. * Gets the total number of active bones rendered per frame
  40422. * @returns the total number of active bones rendered per frame
  40423. */
  40424. getActiveBones(): number;
  40425. /**
  40426. * Gets the performance counter for active bones
  40427. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40428. */
  40429. get activeBonesPerfCounter(): PerfCounter;
  40430. /**
  40431. * Gets the array of active meshes
  40432. * @returns an array of AbstractMesh
  40433. */
  40434. getActiveMeshes(): SmartArray<AbstractMesh>;
  40435. /**
  40436. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40437. * @returns a number
  40438. */
  40439. getAnimationRatio(): number;
  40440. /**
  40441. * Gets an unique Id for the current render phase
  40442. * @returns a number
  40443. */
  40444. getRenderId(): number;
  40445. /**
  40446. * Gets an unique Id for the current frame
  40447. * @returns a number
  40448. */
  40449. getFrameId(): number;
  40450. /** Call this function if you want to manually increment the render Id*/
  40451. incrementRenderId(): void;
  40452. private _createUbo;
  40453. /**
  40454. * Use this method to simulate a pointer move on a mesh
  40455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40458. * @returns the current scene
  40459. */
  40460. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40461. /**
  40462. * Use this method to simulate a pointer down on a mesh
  40463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40466. * @returns the current scene
  40467. */
  40468. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40469. /**
  40470. * Use this method to simulate a pointer up on a mesh
  40471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40474. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40475. * @returns the current scene
  40476. */
  40477. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40478. /**
  40479. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40480. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40481. * @returns true if the pointer was captured
  40482. */
  40483. isPointerCaptured(pointerId?: number): boolean;
  40484. /**
  40485. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40486. * @param attachUp defines if you want to attach events to pointerup
  40487. * @param attachDown defines if you want to attach events to pointerdown
  40488. * @param attachMove defines if you want to attach events to pointermove
  40489. */
  40490. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40491. /** Detaches all event handlers*/
  40492. detachControl(): void;
  40493. /**
  40494. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40495. * Delay loaded resources are not taking in account
  40496. * @return true if all required resources are ready
  40497. */
  40498. isReady(): boolean;
  40499. /** Resets all cached information relative to material (including effect and visibility) */
  40500. resetCachedMaterial(): void;
  40501. /**
  40502. * Registers a function to be called before every frame render
  40503. * @param func defines the function to register
  40504. */
  40505. registerBeforeRender(func: () => void): void;
  40506. /**
  40507. * Unregisters a function called before every frame render
  40508. * @param func defines the function to unregister
  40509. */
  40510. unregisterBeforeRender(func: () => void): void;
  40511. /**
  40512. * Registers a function to be called after every frame render
  40513. * @param func defines the function to register
  40514. */
  40515. registerAfterRender(func: () => void): void;
  40516. /**
  40517. * Unregisters a function called after every frame render
  40518. * @param func defines the function to unregister
  40519. */
  40520. unregisterAfterRender(func: () => void): void;
  40521. private _executeOnceBeforeRender;
  40522. /**
  40523. * The provided function will run before render once and will be disposed afterwards.
  40524. * A timeout delay can be provided so that the function will be executed in N ms.
  40525. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40526. * @param func The function to be executed.
  40527. * @param timeout optional delay in ms
  40528. */
  40529. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40530. /** @hidden */
  40531. _addPendingData(data: any): void;
  40532. /** @hidden */
  40533. _removePendingData(data: any): void;
  40534. /**
  40535. * Returns the number of items waiting to be loaded
  40536. * @returns the number of items waiting to be loaded
  40537. */
  40538. getWaitingItemsCount(): number;
  40539. /**
  40540. * Returns a boolean indicating if the scene is still loading data
  40541. */
  40542. get isLoading(): boolean;
  40543. /**
  40544. * Registers a function to be executed when the scene is ready
  40545. * @param {Function} func - the function to be executed
  40546. */
  40547. executeWhenReady(func: () => void): void;
  40548. /**
  40549. * Returns a promise that resolves when the scene is ready
  40550. * @returns A promise that resolves when the scene is ready
  40551. */
  40552. whenReadyAsync(): Promise<void>;
  40553. /** @hidden */
  40554. _checkIsReady(): void;
  40555. /**
  40556. * Gets all animatable attached to the scene
  40557. */
  40558. get animatables(): Animatable[];
  40559. /**
  40560. * Resets the last animation time frame.
  40561. * Useful to override when animations start running when loading a scene for the first time.
  40562. */
  40563. resetLastAnimationTimeFrame(): void;
  40564. /**
  40565. * Gets the current view matrix
  40566. * @returns a Matrix
  40567. */
  40568. getViewMatrix(): Matrix;
  40569. /**
  40570. * Gets the current projection matrix
  40571. * @returns a Matrix
  40572. */
  40573. getProjectionMatrix(): Matrix;
  40574. /**
  40575. * Gets the current transform matrix
  40576. * @returns a Matrix made of View * Projection
  40577. */
  40578. getTransformMatrix(): Matrix;
  40579. /**
  40580. * Sets the current transform matrix
  40581. * @param viewL defines the View matrix to use
  40582. * @param projectionL defines the Projection matrix to use
  40583. * @param viewR defines the right View matrix to use (if provided)
  40584. * @param projectionR defines the right Projection matrix to use (if provided)
  40585. */
  40586. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40587. /**
  40588. * Gets the uniform buffer used to store scene data
  40589. * @returns a UniformBuffer
  40590. */
  40591. getSceneUniformBuffer(): UniformBuffer;
  40592. /**
  40593. * Gets an unique (relatively to the current scene) Id
  40594. * @returns an unique number for the scene
  40595. */
  40596. getUniqueId(): number;
  40597. /**
  40598. * Add a mesh to the list of scene's meshes
  40599. * @param newMesh defines the mesh to add
  40600. * @param recursive if all child meshes should also be added to the scene
  40601. */
  40602. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40603. /**
  40604. * Remove a mesh for the list of scene's meshes
  40605. * @param toRemove defines the mesh to remove
  40606. * @param recursive if all child meshes should also be removed from the scene
  40607. * @returns the index where the mesh was in the mesh list
  40608. */
  40609. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40610. /**
  40611. * Add a transform node to the list of scene's transform nodes
  40612. * @param newTransformNode defines the transform node to add
  40613. */
  40614. addTransformNode(newTransformNode: TransformNode): void;
  40615. /**
  40616. * Remove a transform node for the list of scene's transform nodes
  40617. * @param toRemove defines the transform node to remove
  40618. * @returns the index where the transform node was in the transform node list
  40619. */
  40620. removeTransformNode(toRemove: TransformNode): number;
  40621. /**
  40622. * Remove a skeleton for the list of scene's skeletons
  40623. * @param toRemove defines the skeleton to remove
  40624. * @returns the index where the skeleton was in the skeleton list
  40625. */
  40626. removeSkeleton(toRemove: Skeleton): number;
  40627. /**
  40628. * Remove a morph target for the list of scene's morph targets
  40629. * @param toRemove defines the morph target to remove
  40630. * @returns the index where the morph target was in the morph target list
  40631. */
  40632. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40633. /**
  40634. * Remove a light for the list of scene's lights
  40635. * @param toRemove defines the light to remove
  40636. * @returns the index where the light was in the light list
  40637. */
  40638. removeLight(toRemove: Light): number;
  40639. /**
  40640. * Remove a camera for the list of scene's cameras
  40641. * @param toRemove defines the camera to remove
  40642. * @returns the index where the camera was in the camera list
  40643. */
  40644. removeCamera(toRemove: Camera): number;
  40645. /**
  40646. * Remove a particle system for the list of scene's particle systems
  40647. * @param toRemove defines the particle system to remove
  40648. * @returns the index where the particle system was in the particle system list
  40649. */
  40650. removeParticleSystem(toRemove: IParticleSystem): number;
  40651. /**
  40652. * Remove a animation for the list of scene's animations
  40653. * @param toRemove defines the animation to remove
  40654. * @returns the index where the animation was in the animation list
  40655. */
  40656. removeAnimation(toRemove: Animation): number;
  40657. /**
  40658. * Will stop the animation of the given target
  40659. * @param target - the target
  40660. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40661. * @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)
  40662. */
  40663. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40664. /**
  40665. * Removes the given animation group from this scene.
  40666. * @param toRemove The animation group to remove
  40667. * @returns The index of the removed animation group
  40668. */
  40669. removeAnimationGroup(toRemove: AnimationGroup): number;
  40670. /**
  40671. * Removes the given multi-material from this scene.
  40672. * @param toRemove The multi-material to remove
  40673. * @returns The index of the removed multi-material
  40674. */
  40675. removeMultiMaterial(toRemove: MultiMaterial): number;
  40676. /**
  40677. * Removes the given material from this scene.
  40678. * @param toRemove The material to remove
  40679. * @returns The index of the removed material
  40680. */
  40681. removeMaterial(toRemove: Material): number;
  40682. /**
  40683. * Removes the given action manager from this scene.
  40684. * @param toRemove The action manager to remove
  40685. * @returns The index of the removed action manager
  40686. */
  40687. removeActionManager(toRemove: AbstractActionManager): number;
  40688. /**
  40689. * Removes the given texture from this scene.
  40690. * @param toRemove The texture to remove
  40691. * @returns The index of the removed texture
  40692. */
  40693. removeTexture(toRemove: BaseTexture): number;
  40694. /**
  40695. * Adds the given light to this scene
  40696. * @param newLight The light to add
  40697. */
  40698. addLight(newLight: Light): void;
  40699. /**
  40700. * Sorts the list list based on light priorities
  40701. */
  40702. sortLightsByPriority(): void;
  40703. /**
  40704. * Adds the given camera to this scene
  40705. * @param newCamera The camera to add
  40706. */
  40707. addCamera(newCamera: Camera): void;
  40708. /**
  40709. * Adds the given skeleton to this scene
  40710. * @param newSkeleton The skeleton to add
  40711. */
  40712. addSkeleton(newSkeleton: Skeleton): void;
  40713. /**
  40714. * Adds the given particle system to this scene
  40715. * @param newParticleSystem The particle system to add
  40716. */
  40717. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40718. /**
  40719. * Adds the given animation to this scene
  40720. * @param newAnimation The animation to add
  40721. */
  40722. addAnimation(newAnimation: Animation): void;
  40723. /**
  40724. * Adds the given animation group to this scene.
  40725. * @param newAnimationGroup The animation group to add
  40726. */
  40727. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40728. /**
  40729. * Adds the given multi-material to this scene
  40730. * @param newMultiMaterial The multi-material to add
  40731. */
  40732. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40733. /**
  40734. * Adds the given material to this scene
  40735. * @param newMaterial The material to add
  40736. */
  40737. addMaterial(newMaterial: Material): void;
  40738. /**
  40739. * Adds the given morph target to this scene
  40740. * @param newMorphTargetManager The morph target to add
  40741. */
  40742. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40743. /**
  40744. * Adds the given geometry to this scene
  40745. * @param newGeometry The geometry to add
  40746. */
  40747. addGeometry(newGeometry: Geometry): void;
  40748. /**
  40749. * Adds the given action manager to this scene
  40750. * @param newActionManager The action manager to add
  40751. */
  40752. addActionManager(newActionManager: AbstractActionManager): void;
  40753. /**
  40754. * Adds the given texture to this scene.
  40755. * @param newTexture The texture to add
  40756. */
  40757. addTexture(newTexture: BaseTexture): void;
  40758. /**
  40759. * Switch active camera
  40760. * @param newCamera defines the new active camera
  40761. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40762. */
  40763. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40764. /**
  40765. * sets the active camera of the scene using its ID
  40766. * @param id defines the camera's ID
  40767. * @return the new active camera or null if none found.
  40768. */
  40769. setActiveCameraByID(id: string): Nullable<Camera>;
  40770. /**
  40771. * sets the active camera of the scene using its name
  40772. * @param name defines the camera's name
  40773. * @returns the new active camera or null if none found.
  40774. */
  40775. setActiveCameraByName(name: string): Nullable<Camera>;
  40776. /**
  40777. * get an animation group using its name
  40778. * @param name defines the material's name
  40779. * @return the animation group or null if none found.
  40780. */
  40781. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40782. /**
  40783. * Get a material using its unique id
  40784. * @param uniqueId defines the material's unique id
  40785. * @return the material or null if none found.
  40786. */
  40787. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40788. /**
  40789. * get a material using its id
  40790. * @param id defines the material's ID
  40791. * @return the material or null if none found.
  40792. */
  40793. getMaterialByID(id: string): Nullable<Material>;
  40794. /**
  40795. * Gets a the last added material using a given id
  40796. * @param id defines the material's ID
  40797. * @return the last material with the given id or null if none found.
  40798. */
  40799. getLastMaterialByID(id: string): Nullable<Material>;
  40800. /**
  40801. * Gets a material using its name
  40802. * @param name defines the material's name
  40803. * @return the material or null if none found.
  40804. */
  40805. getMaterialByName(name: string): Nullable<Material>;
  40806. /**
  40807. * Get a texture using its unique id
  40808. * @param uniqueId defines the texture's unique id
  40809. * @return the texture or null if none found.
  40810. */
  40811. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40812. /**
  40813. * Gets a camera using its id
  40814. * @param id defines the id to look for
  40815. * @returns the camera or null if not found
  40816. */
  40817. getCameraByID(id: string): Nullable<Camera>;
  40818. /**
  40819. * Gets a camera using its unique id
  40820. * @param uniqueId defines the unique id to look for
  40821. * @returns the camera or null if not found
  40822. */
  40823. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40824. /**
  40825. * Gets a camera using its name
  40826. * @param name defines the camera's name
  40827. * @return the camera or null if none found.
  40828. */
  40829. getCameraByName(name: string): Nullable<Camera>;
  40830. /**
  40831. * Gets a bone using its id
  40832. * @param id defines the bone's id
  40833. * @return the bone or null if not found
  40834. */
  40835. getBoneByID(id: string): Nullable<Bone>;
  40836. /**
  40837. * Gets a bone using its id
  40838. * @param name defines the bone's name
  40839. * @return the bone or null if not found
  40840. */
  40841. getBoneByName(name: string): Nullable<Bone>;
  40842. /**
  40843. * Gets a light node using its name
  40844. * @param name defines the the light's name
  40845. * @return the light or null if none found.
  40846. */
  40847. getLightByName(name: string): Nullable<Light>;
  40848. /**
  40849. * Gets a light node using its id
  40850. * @param id defines the light's id
  40851. * @return the light or null if none found.
  40852. */
  40853. getLightByID(id: string): Nullable<Light>;
  40854. /**
  40855. * Gets a light node using its scene-generated unique ID
  40856. * @param uniqueId defines the light's unique id
  40857. * @return the light or null if none found.
  40858. */
  40859. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40860. /**
  40861. * Gets a particle system by id
  40862. * @param id defines the particle system id
  40863. * @return the corresponding system or null if none found
  40864. */
  40865. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40866. /**
  40867. * Gets a geometry using its ID
  40868. * @param id defines the geometry's id
  40869. * @return the geometry or null if none found.
  40870. */
  40871. getGeometryByID(id: string): Nullable<Geometry>;
  40872. private _getGeometryByUniqueID;
  40873. /**
  40874. * Add a new geometry to this scene
  40875. * @param geometry defines the geometry to be added to the scene.
  40876. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40877. * @return a boolean defining if the geometry was added or not
  40878. */
  40879. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40880. /**
  40881. * Removes an existing geometry
  40882. * @param geometry defines the geometry to be removed from the scene
  40883. * @return a boolean defining if the geometry was removed or not
  40884. */
  40885. removeGeometry(geometry: Geometry): boolean;
  40886. /**
  40887. * Gets the list of geometries attached to the scene
  40888. * @returns an array of Geometry
  40889. */
  40890. getGeometries(): Geometry[];
  40891. /**
  40892. * Gets the first added mesh found of a given ID
  40893. * @param id defines the id to search for
  40894. * @return the mesh found or null if not found at all
  40895. */
  40896. getMeshByID(id: string): Nullable<AbstractMesh>;
  40897. /**
  40898. * Gets a list of meshes using their id
  40899. * @param id defines the id to search for
  40900. * @returns a list of meshes
  40901. */
  40902. getMeshesByID(id: string): Array<AbstractMesh>;
  40903. /**
  40904. * Gets the first added transform node found of a given ID
  40905. * @param id defines the id to search for
  40906. * @return the found transform node or null if not found at all.
  40907. */
  40908. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40909. /**
  40910. * Gets a transform node with its auto-generated unique id
  40911. * @param uniqueId efines the unique id to search for
  40912. * @return the found transform node or null if not found at all.
  40913. */
  40914. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40915. /**
  40916. * Gets a list of transform nodes using their id
  40917. * @param id defines the id to search for
  40918. * @returns a list of transform nodes
  40919. */
  40920. getTransformNodesByID(id: string): Array<TransformNode>;
  40921. /**
  40922. * Gets a mesh with its auto-generated unique id
  40923. * @param uniqueId defines the unique id to search for
  40924. * @return the found mesh or null if not found at all.
  40925. */
  40926. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40927. /**
  40928. * Gets a the last added mesh using a given id
  40929. * @param id defines the id to search for
  40930. * @return the found mesh or null if not found at all.
  40931. */
  40932. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40933. /**
  40934. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40935. * @param id defines the id to search for
  40936. * @return the found node or null if not found at all
  40937. */
  40938. getLastEntryByID(id: string): Nullable<Node>;
  40939. /**
  40940. * Gets a node (Mesh, Camera, Light) using a given id
  40941. * @param id defines the id to search for
  40942. * @return the found node or null if not found at all
  40943. */
  40944. getNodeByID(id: string): Nullable<Node>;
  40945. /**
  40946. * Gets a node (Mesh, Camera, Light) using a given name
  40947. * @param name defines the name to search for
  40948. * @return the found node or null if not found at all.
  40949. */
  40950. getNodeByName(name: string): Nullable<Node>;
  40951. /**
  40952. * Gets a mesh using a given name
  40953. * @param name defines the name to search for
  40954. * @return the found mesh or null if not found at all.
  40955. */
  40956. getMeshByName(name: string): Nullable<AbstractMesh>;
  40957. /**
  40958. * Gets a transform node using a given name
  40959. * @param name defines the name to search for
  40960. * @return the found transform node or null if not found at all.
  40961. */
  40962. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40963. /**
  40964. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40965. * @param id defines the id to search for
  40966. * @return the found skeleton or null if not found at all.
  40967. */
  40968. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40969. /**
  40970. * Gets a skeleton using a given auto generated unique id
  40971. * @param uniqueId defines the unique id to search for
  40972. * @return the found skeleton or null if not found at all.
  40973. */
  40974. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40975. /**
  40976. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40977. * @param id defines the id to search for
  40978. * @return the found skeleton or null if not found at all.
  40979. */
  40980. getSkeletonById(id: string): Nullable<Skeleton>;
  40981. /**
  40982. * Gets a skeleton using a given name
  40983. * @param name defines the name to search for
  40984. * @return the found skeleton or null if not found at all.
  40985. */
  40986. getSkeletonByName(name: string): Nullable<Skeleton>;
  40987. /**
  40988. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40989. * @param id defines the id to search for
  40990. * @return the found morph target manager or null if not found at all.
  40991. */
  40992. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40993. /**
  40994. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40995. * @param id defines the id to search for
  40996. * @return the found morph target or null if not found at all.
  40997. */
  40998. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40999. /**
  41000. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41001. * @param name defines the name to search for
  41002. * @return the found morph target or null if not found at all.
  41003. */
  41004. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41005. /**
  41006. * Gets a post process using a given name (if many are found, this function will pick the first one)
  41007. * @param name defines the name to search for
  41008. * @return the found post process or null if not found at all.
  41009. */
  41010. getPostProcessByName(name: string): Nullable<PostProcess>;
  41011. /**
  41012. * Gets a boolean indicating if the given mesh is active
  41013. * @param mesh defines the mesh to look for
  41014. * @returns true if the mesh is in the active list
  41015. */
  41016. isActiveMesh(mesh: AbstractMesh): boolean;
  41017. /**
  41018. * Return a unique id as a string which can serve as an identifier for the scene
  41019. */
  41020. get uid(): string;
  41021. /**
  41022. * Add an externaly attached data from its key.
  41023. * This method call will fail and return false, if such key already exists.
  41024. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41025. * @param key the unique key that identifies the data
  41026. * @param data the data object to associate to the key for this Engine instance
  41027. * @return true if no such key were already present and the data was added successfully, false otherwise
  41028. */
  41029. addExternalData<T>(key: string, data: T): boolean;
  41030. /**
  41031. * Get an externaly attached data from its key
  41032. * @param key the unique key that identifies the data
  41033. * @return the associated data, if present (can be null), or undefined if not present
  41034. */
  41035. getExternalData<T>(key: string): Nullable<T>;
  41036. /**
  41037. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41038. * @param key the unique key that identifies the data
  41039. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41040. * @return the associated data, can be null if the factory returned null.
  41041. */
  41042. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41043. /**
  41044. * Remove an externaly attached data from the Engine instance
  41045. * @param key the unique key that identifies the data
  41046. * @return true if the data was successfully removed, false if it doesn't exist
  41047. */
  41048. removeExternalData(key: string): boolean;
  41049. private _evaluateSubMesh;
  41050. /**
  41051. * Clear the processed materials smart array preventing retention point in material dispose.
  41052. */
  41053. freeProcessedMaterials(): void;
  41054. private _preventFreeActiveMeshesAndRenderingGroups;
  41055. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41056. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41057. * when disposing several meshes in a row or a hierarchy of meshes.
  41058. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41059. */
  41060. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41061. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41062. /**
  41063. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41064. */
  41065. freeActiveMeshes(): void;
  41066. /**
  41067. * Clear the info related to rendering groups preventing retention points during dispose.
  41068. */
  41069. freeRenderingGroups(): void;
  41070. /** @hidden */
  41071. _isInIntermediateRendering(): boolean;
  41072. /**
  41073. * Lambda returning the list of potentially active meshes.
  41074. */
  41075. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41076. /**
  41077. * Lambda returning the list of potentially active sub meshes.
  41078. */
  41079. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41080. /**
  41081. * Lambda returning the list of potentially intersecting sub meshes.
  41082. */
  41083. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41084. /**
  41085. * Lambda returning the list of potentially colliding sub meshes.
  41086. */
  41087. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41088. private _activeMeshesFrozen;
  41089. private _skipEvaluateActiveMeshesCompletely;
  41090. /**
  41091. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41092. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41093. * @returns the current scene
  41094. */
  41095. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41096. /**
  41097. * Use this function to restart evaluating active meshes on every frame
  41098. * @returns the current scene
  41099. */
  41100. unfreezeActiveMeshes(): Scene;
  41101. private _evaluateActiveMeshes;
  41102. private _activeMesh;
  41103. /**
  41104. * Update the transform matrix to update from the current active camera
  41105. * @param force defines a boolean used to force the update even if cache is up to date
  41106. */
  41107. updateTransformMatrix(force?: boolean): void;
  41108. private _bindFrameBuffer;
  41109. /** @hidden */
  41110. _allowPostProcessClearColor: boolean;
  41111. /** @hidden */
  41112. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41113. private _processSubCameras;
  41114. private _checkIntersections;
  41115. /** @hidden */
  41116. _advancePhysicsEngineStep(step: number): void;
  41117. /**
  41118. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41119. */
  41120. getDeterministicFrameTime: () => number;
  41121. /** @hidden */
  41122. _animate(): void;
  41123. /** Execute all animations (for a frame) */
  41124. animate(): void;
  41125. /**
  41126. * Render the scene
  41127. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41128. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41129. */
  41130. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41131. /**
  41132. * Freeze all materials
  41133. * A frozen material will not be updatable but should be faster to render
  41134. */
  41135. freezeMaterials(): void;
  41136. /**
  41137. * Unfreeze all materials
  41138. * A frozen material will not be updatable but should be faster to render
  41139. */
  41140. unfreezeMaterials(): void;
  41141. /**
  41142. * Releases all held ressources
  41143. */
  41144. dispose(): void;
  41145. /**
  41146. * Gets if the scene is already disposed
  41147. */
  41148. get isDisposed(): boolean;
  41149. /**
  41150. * Call this function to reduce memory footprint of the scene.
  41151. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41152. */
  41153. clearCachedVertexData(): void;
  41154. /**
  41155. * This function will remove the local cached buffer data from texture.
  41156. * It will save memory but will prevent the texture from being rebuilt
  41157. */
  41158. cleanCachedTextureBuffer(): void;
  41159. /**
  41160. * Get the world extend vectors with an optional filter
  41161. *
  41162. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41163. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41164. */
  41165. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41166. min: Vector3;
  41167. max: Vector3;
  41168. };
  41169. /**
  41170. * Creates a ray that can be used to pick in the scene
  41171. * @param x defines the x coordinate of the origin (on-screen)
  41172. * @param y defines the y coordinate of the origin (on-screen)
  41173. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41174. * @param camera defines the camera to use for the picking
  41175. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41176. * @returns a Ray
  41177. */
  41178. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41179. /**
  41180. * Creates a ray that can be used to pick in the scene
  41181. * @param x defines the x coordinate of the origin (on-screen)
  41182. * @param y defines the y coordinate of the origin (on-screen)
  41183. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41184. * @param result defines the ray where to store the picking ray
  41185. * @param camera defines the camera to use for the picking
  41186. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41187. * @returns the current scene
  41188. */
  41189. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41190. /**
  41191. * Creates a ray that can be used to pick in the scene
  41192. * @param x defines the x coordinate of the origin (on-screen)
  41193. * @param y defines the y coordinate of the origin (on-screen)
  41194. * @param camera defines the camera to use for the picking
  41195. * @returns a Ray
  41196. */
  41197. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41198. /**
  41199. * Creates a ray that can be used to pick in the scene
  41200. * @param x defines the x coordinate of the origin (on-screen)
  41201. * @param y defines the y coordinate of the origin (on-screen)
  41202. * @param result defines the ray where to store the picking ray
  41203. * @param camera defines the camera to use for the picking
  41204. * @returns the current scene
  41205. */
  41206. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41207. /** Launch a ray to try to pick a mesh in the scene
  41208. * @param x position on screen
  41209. * @param y position on screen
  41210. * @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
  41211. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41212. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41214. * @returns a PickingInfo
  41215. */
  41216. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41217. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41218. * @param x position on screen
  41219. * @param y position on screen
  41220. * @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
  41221. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41222. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41223. * @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)
  41224. */
  41225. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41226. /** Use the given ray to pick a mesh in the scene
  41227. * @param ray The ray to use to pick meshes
  41228. * @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
  41229. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41230. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41231. * @returns a PickingInfo
  41232. */
  41233. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41234. /**
  41235. * Launch a ray to try to pick a mesh in the scene
  41236. * @param x X position on screen
  41237. * @param y Y position on screen
  41238. * @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
  41239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41241. * @returns an array of PickingInfo
  41242. */
  41243. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41244. /**
  41245. * Launch a ray to try to pick a mesh in the scene
  41246. * @param ray Ray to use
  41247. * @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
  41248. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41249. * @returns an array of PickingInfo
  41250. */
  41251. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41252. /**
  41253. * Force the value of meshUnderPointer
  41254. * @param mesh defines the mesh to use
  41255. * @param pointerId optional pointer id when using more than one pointer
  41256. */
  41257. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41258. /**
  41259. * Gets the mesh under the pointer
  41260. * @returns a Mesh or null if no mesh is under the pointer
  41261. */
  41262. getPointerOverMesh(): Nullable<AbstractMesh>;
  41263. /** @hidden */
  41264. _rebuildGeometries(): void;
  41265. /** @hidden */
  41266. _rebuildTextures(): void;
  41267. private _getByTags;
  41268. /**
  41269. * Get a list of meshes by tags
  41270. * @param tagsQuery defines the tags query to use
  41271. * @param forEach defines a predicate used to filter results
  41272. * @returns an array of Mesh
  41273. */
  41274. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41275. /**
  41276. * Get a list of cameras by tags
  41277. * @param tagsQuery defines the tags query to use
  41278. * @param forEach defines a predicate used to filter results
  41279. * @returns an array of Camera
  41280. */
  41281. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41282. /**
  41283. * Get a list of lights by tags
  41284. * @param tagsQuery defines the tags query to use
  41285. * @param forEach defines a predicate used to filter results
  41286. * @returns an array of Light
  41287. */
  41288. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41289. /**
  41290. * Get a list of materials by tags
  41291. * @param tagsQuery defines the tags query to use
  41292. * @param forEach defines a predicate used to filter results
  41293. * @returns an array of Material
  41294. */
  41295. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41296. /**
  41297. * Get a list of transform nodes by tags
  41298. * @param tagsQuery defines the tags query to use
  41299. * @param forEach defines a predicate used to filter results
  41300. * @returns an array of TransformNode
  41301. */
  41302. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41303. /**
  41304. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41305. * This allowed control for front to back rendering or reversly depending of the special needs.
  41306. *
  41307. * @param renderingGroupId The rendering group id corresponding to its index
  41308. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41309. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41310. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41311. */
  41312. 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;
  41313. /**
  41314. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41315. *
  41316. * @param renderingGroupId The rendering group id corresponding to its index
  41317. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41318. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41319. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41320. */
  41321. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41322. /**
  41323. * Gets the current auto clear configuration for one rendering group of the rendering
  41324. * manager.
  41325. * @param index the rendering group index to get the information for
  41326. * @returns The auto clear setup for the requested rendering group
  41327. */
  41328. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41329. private _blockMaterialDirtyMechanism;
  41330. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41331. get blockMaterialDirtyMechanism(): boolean;
  41332. set blockMaterialDirtyMechanism(value: boolean);
  41333. /**
  41334. * Will flag all materials as dirty to trigger new shader compilation
  41335. * @param flag defines the flag used to specify which material part must be marked as dirty
  41336. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41337. */
  41338. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41339. /** @hidden */
  41340. _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;
  41341. /** @hidden */
  41342. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41343. /** @hidden */
  41344. _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;
  41345. /** @hidden */
  41346. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41347. /** @hidden */
  41348. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41349. /** @hidden */
  41350. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Set of assets to keep when moving a scene into an asset container.
  41356. */
  41357. export class KeepAssets extends AbstractScene {
  41358. }
  41359. /**
  41360. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41361. */
  41362. export class InstantiatedEntries {
  41363. /**
  41364. * List of new root nodes (eg. nodes with no parent)
  41365. */
  41366. rootNodes: TransformNode[];
  41367. /**
  41368. * List of new skeletons
  41369. */
  41370. skeletons: Skeleton[];
  41371. /**
  41372. * List of new animation groups
  41373. */
  41374. animationGroups: AnimationGroup[];
  41375. }
  41376. /**
  41377. * Container with a set of assets that can be added or removed from a scene.
  41378. */
  41379. export class AssetContainer extends AbstractScene {
  41380. private _wasAddedToScene;
  41381. /**
  41382. * The scene the AssetContainer belongs to.
  41383. */
  41384. scene: Scene;
  41385. /**
  41386. * Instantiates an AssetContainer.
  41387. * @param scene The scene the AssetContainer belongs to.
  41388. */
  41389. constructor(scene: Scene);
  41390. /**
  41391. * Instantiate or clone all meshes and add the new ones to the scene.
  41392. * Skeletons and animation groups will all be cloned
  41393. * @param nameFunction defines an optional function used to get new names for clones
  41394. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41395. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41396. */
  41397. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41398. /**
  41399. * Adds all the assets from the container to the scene.
  41400. */
  41401. addAllToScene(): void;
  41402. /**
  41403. * Removes all the assets in the container from the scene
  41404. */
  41405. removeAllFromScene(): void;
  41406. /**
  41407. * Disposes all the assets in the container
  41408. */
  41409. dispose(): void;
  41410. private _moveAssets;
  41411. /**
  41412. * Removes all the assets contained in the scene and adds them to the container.
  41413. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41414. */
  41415. moveAllFromScene(keepAssets?: KeepAssets): void;
  41416. /**
  41417. * 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.
  41418. * @returns the root mesh
  41419. */
  41420. createRootMesh(): Mesh;
  41421. /**
  41422. * Merge animations (direct and animation groups) from this asset container into a scene
  41423. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41424. * @param animatables set of animatables to retarget to a node from the scene
  41425. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41426. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41427. */
  41428. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41429. }
  41430. }
  41431. declare module BABYLON {
  41432. /**
  41433. * Defines how the parser contract is defined.
  41434. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41435. */
  41436. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41437. /**
  41438. * Defines how the individual parser contract is defined.
  41439. * These parser can parse an individual asset
  41440. */
  41441. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41442. /**
  41443. * Base class of the scene acting as a container for the different elements composing a scene.
  41444. * This class is dynamically extended by the different components of the scene increasing
  41445. * flexibility and reducing coupling
  41446. */
  41447. export abstract class AbstractScene {
  41448. /**
  41449. * Stores the list of available parsers in the application.
  41450. */
  41451. private static _BabylonFileParsers;
  41452. /**
  41453. * Stores the list of available individual parsers in the application.
  41454. */
  41455. private static _IndividualBabylonFileParsers;
  41456. /**
  41457. * Adds a parser in the list of available ones
  41458. * @param name Defines the name of the parser
  41459. * @param parser Defines the parser to add
  41460. */
  41461. static AddParser(name: string, parser: BabylonFileParser): void;
  41462. /**
  41463. * Gets a general parser from the list of avaialble ones
  41464. * @param name Defines the name of the parser
  41465. * @returns the requested parser or null
  41466. */
  41467. static GetParser(name: string): Nullable<BabylonFileParser>;
  41468. /**
  41469. * Adds n individual parser in the list of available ones
  41470. * @param name Defines the name of the parser
  41471. * @param parser Defines the parser to add
  41472. */
  41473. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41474. /**
  41475. * Gets an individual parser from the list of avaialble ones
  41476. * @param name Defines the name of the parser
  41477. * @returns the requested parser or null
  41478. */
  41479. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41480. /**
  41481. * Parser json data and populate both a scene and its associated container object
  41482. * @param jsonData Defines the data to parse
  41483. * @param scene Defines the scene to parse the data for
  41484. * @param container Defines the container attached to the parsing sequence
  41485. * @param rootUrl Defines the root url of the data
  41486. */
  41487. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41488. /**
  41489. * Gets the list of root nodes (ie. nodes with no parent)
  41490. */
  41491. rootNodes: Node[];
  41492. /** All of the cameras added to this scene
  41493. * @see https://doc.babylonjs.com/babylon101/cameras
  41494. */
  41495. cameras: Camera[];
  41496. /**
  41497. * All of the lights added to this scene
  41498. * @see https://doc.babylonjs.com/babylon101/lights
  41499. */
  41500. lights: Light[];
  41501. /**
  41502. * All of the (abstract) meshes added to this scene
  41503. */
  41504. meshes: AbstractMesh[];
  41505. /**
  41506. * The list of skeletons added to the scene
  41507. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41508. */
  41509. skeletons: Skeleton[];
  41510. /**
  41511. * All of the particle systems added to this scene
  41512. * @see https://doc.babylonjs.com/babylon101/particles
  41513. */
  41514. particleSystems: IParticleSystem[];
  41515. /**
  41516. * Gets a list of Animations associated with the scene
  41517. */
  41518. animations: Animation[];
  41519. /**
  41520. * All of the animation groups added to this scene
  41521. * @see https://doc.babylonjs.com/how_to/group
  41522. */
  41523. animationGroups: AnimationGroup[];
  41524. /**
  41525. * All of the multi-materials added to this scene
  41526. * @see https://doc.babylonjs.com/how_to/multi_materials
  41527. */
  41528. multiMaterials: MultiMaterial[];
  41529. /**
  41530. * All of the materials added to this scene
  41531. * In the context of a Scene, it is not supposed to be modified manually.
  41532. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41533. * Note also that the order of the Material within the array is not significant and might change.
  41534. * @see https://doc.babylonjs.com/babylon101/materials
  41535. */
  41536. materials: Material[];
  41537. /**
  41538. * The list of morph target managers added to the scene
  41539. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41540. */
  41541. morphTargetManagers: MorphTargetManager[];
  41542. /**
  41543. * The list of geometries used in the scene.
  41544. */
  41545. geometries: Geometry[];
  41546. /**
  41547. * All of the tranform nodes added to this scene
  41548. * In the context of a Scene, it is not supposed to be modified manually.
  41549. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41550. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41551. * @see https://doc.babylonjs.com/how_to/transformnode
  41552. */
  41553. transformNodes: TransformNode[];
  41554. /**
  41555. * ActionManagers available on the scene.
  41556. */
  41557. actionManagers: AbstractActionManager[];
  41558. /**
  41559. * Textures to keep.
  41560. */
  41561. textures: BaseTexture[];
  41562. /** @hidden */
  41563. protected _environmentTexture: Nullable<BaseTexture>;
  41564. /**
  41565. * Texture used in all pbr material as the reflection texture.
  41566. * As in the majority of the scene they are the same (exception for multi room and so on),
  41567. * this is easier to reference from here than from all the materials.
  41568. */
  41569. get environmentTexture(): Nullable<BaseTexture>;
  41570. set environmentTexture(value: Nullable<BaseTexture>);
  41571. /**
  41572. * The list of postprocesses added to the scene
  41573. */
  41574. postProcesses: PostProcess[];
  41575. /**
  41576. * @returns all meshes, lights, cameras, transformNodes and bones
  41577. */
  41578. getNodes(): Array<Node>;
  41579. }
  41580. }
  41581. declare module BABYLON {
  41582. /**
  41583. * Interface used to define options for Sound class
  41584. */
  41585. export interface ISoundOptions {
  41586. /**
  41587. * Does the sound autoplay once loaded.
  41588. */
  41589. autoplay?: boolean;
  41590. /**
  41591. * Does the sound loop after it finishes playing once.
  41592. */
  41593. loop?: boolean;
  41594. /**
  41595. * Sound's volume
  41596. */
  41597. volume?: number;
  41598. /**
  41599. * Is it a spatial sound?
  41600. */
  41601. spatialSound?: boolean;
  41602. /**
  41603. * Maximum distance to hear that sound
  41604. */
  41605. maxDistance?: number;
  41606. /**
  41607. * Uses user defined attenuation function
  41608. */
  41609. useCustomAttenuation?: boolean;
  41610. /**
  41611. * Define the roll off factor of spatial sounds.
  41612. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41613. */
  41614. rolloffFactor?: number;
  41615. /**
  41616. * Define the reference distance the sound should be heard perfectly.
  41617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41618. */
  41619. refDistance?: number;
  41620. /**
  41621. * Define the distance attenuation model the sound will follow.
  41622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41623. */
  41624. distanceModel?: string;
  41625. /**
  41626. * Defines the playback speed (1 by default)
  41627. */
  41628. playbackRate?: number;
  41629. /**
  41630. * Defines if the sound is from a streaming source
  41631. */
  41632. streaming?: boolean;
  41633. /**
  41634. * Defines an optional length (in seconds) inside the sound file
  41635. */
  41636. length?: number;
  41637. /**
  41638. * Defines an optional offset (in seconds) inside the sound file
  41639. */
  41640. offset?: number;
  41641. /**
  41642. * If true, URLs will not be required to state the audio file codec to use.
  41643. */
  41644. skipCodecCheck?: boolean;
  41645. }
  41646. /**
  41647. * Defines a sound that can be played in the application.
  41648. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41650. */
  41651. export class Sound {
  41652. /**
  41653. * The name of the sound in the scene.
  41654. */
  41655. name: string;
  41656. /**
  41657. * Does the sound autoplay once loaded.
  41658. */
  41659. autoplay: boolean;
  41660. /**
  41661. * Does the sound loop after it finishes playing once.
  41662. */
  41663. loop: boolean;
  41664. /**
  41665. * Does the sound use a custom attenuation curve to simulate the falloff
  41666. * happening when the source gets further away from the camera.
  41667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41668. */
  41669. useCustomAttenuation: boolean;
  41670. /**
  41671. * The sound track id this sound belongs to.
  41672. */
  41673. soundTrackId: number;
  41674. /**
  41675. * Is this sound currently played.
  41676. */
  41677. isPlaying: boolean;
  41678. /**
  41679. * Is this sound currently paused.
  41680. */
  41681. isPaused: boolean;
  41682. /**
  41683. * Does this sound enables spatial sound.
  41684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41685. */
  41686. spatialSound: boolean;
  41687. /**
  41688. * Define the reference distance the sound should be heard perfectly.
  41689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41690. */
  41691. refDistance: number;
  41692. /**
  41693. * Define the roll off factor of spatial sounds.
  41694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41695. */
  41696. rolloffFactor: number;
  41697. /**
  41698. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41699. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41700. */
  41701. maxDistance: number;
  41702. /**
  41703. * Define the distance attenuation model the sound will follow.
  41704. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41705. */
  41706. distanceModel: string;
  41707. /**
  41708. * @hidden
  41709. * Back Compat
  41710. **/
  41711. onended: () => any;
  41712. /**
  41713. * Gets or sets an object used to store user defined information for the sound.
  41714. */
  41715. metadata: any;
  41716. /**
  41717. * Observable event when the current playing sound finishes.
  41718. */
  41719. onEndedObservable: Observable<Sound>;
  41720. private _panningModel;
  41721. private _playbackRate;
  41722. private _streaming;
  41723. private _startTime;
  41724. private _startOffset;
  41725. private _position;
  41726. /** @hidden */
  41727. _positionInEmitterSpace: boolean;
  41728. private _localDirection;
  41729. private _volume;
  41730. private _isReadyToPlay;
  41731. private _isDirectional;
  41732. private _readyToPlayCallback;
  41733. private _audioBuffer;
  41734. private _soundSource;
  41735. private _streamingSource;
  41736. private _soundPanner;
  41737. private _soundGain;
  41738. private _inputAudioNode;
  41739. private _outputAudioNode;
  41740. private _coneInnerAngle;
  41741. private _coneOuterAngle;
  41742. private _coneOuterGain;
  41743. private _scene;
  41744. private _connectedTransformNode;
  41745. private _customAttenuationFunction;
  41746. private _registerFunc;
  41747. private _isOutputConnected;
  41748. private _htmlAudioElement;
  41749. private _urlType;
  41750. private _length?;
  41751. private _offset?;
  41752. /** @hidden */
  41753. static _SceneComponentInitialization: (scene: Scene) => void;
  41754. /**
  41755. * Create a sound and attach it to a scene
  41756. * @param name Name of your sound
  41757. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41758. * @param scene defines the scene the sound belongs to
  41759. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41760. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41761. */
  41762. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41763. /**
  41764. * Release the sound and its associated resources
  41765. */
  41766. dispose(): void;
  41767. /**
  41768. * Gets if the sounds is ready to be played or not.
  41769. * @returns true if ready, otherwise false
  41770. */
  41771. isReady(): boolean;
  41772. private _soundLoaded;
  41773. /**
  41774. * Sets the data of the sound from an audiobuffer
  41775. * @param audioBuffer The audioBuffer containing the data
  41776. */
  41777. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41778. /**
  41779. * Updates the current sounds options such as maxdistance, loop...
  41780. * @param options A JSON object containing values named as the object properties
  41781. */
  41782. updateOptions(options: ISoundOptions): void;
  41783. private _createSpatialParameters;
  41784. private _updateSpatialParameters;
  41785. /**
  41786. * Switch the panning model to HRTF:
  41787. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41788. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41789. */
  41790. switchPanningModelToHRTF(): void;
  41791. /**
  41792. * Switch the panning model to Equal Power:
  41793. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41795. */
  41796. switchPanningModelToEqualPower(): void;
  41797. private _switchPanningModel;
  41798. /**
  41799. * Connect this sound to a sound track audio node like gain...
  41800. * @param soundTrackAudioNode the sound track audio node to connect to
  41801. */
  41802. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41803. /**
  41804. * Transform this sound into a directional source
  41805. * @param coneInnerAngle Size of the inner cone in degree
  41806. * @param coneOuterAngle Size of the outer cone in degree
  41807. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41808. */
  41809. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41810. /**
  41811. * Gets or sets the inner angle for the directional cone.
  41812. */
  41813. get directionalConeInnerAngle(): number;
  41814. /**
  41815. * Gets or sets the inner angle for the directional cone.
  41816. */
  41817. set directionalConeInnerAngle(value: number);
  41818. /**
  41819. * Gets or sets the outer angle for the directional cone.
  41820. */
  41821. get directionalConeOuterAngle(): number;
  41822. /**
  41823. * Gets or sets the outer angle for the directional cone.
  41824. */
  41825. set directionalConeOuterAngle(value: number);
  41826. /**
  41827. * Sets the position of the emitter if spatial sound is enabled
  41828. * @param newPosition Defines the new posisiton
  41829. */
  41830. setPosition(newPosition: Vector3): void;
  41831. /**
  41832. * Sets the local direction of the emitter if spatial sound is enabled
  41833. * @param newLocalDirection Defines the new local direction
  41834. */
  41835. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41836. private _updateDirection;
  41837. /** @hidden */
  41838. updateDistanceFromListener(): void;
  41839. /**
  41840. * Sets a new custom attenuation function for the sound.
  41841. * @param callback Defines the function used for the attenuation
  41842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41843. */
  41844. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41845. /**
  41846. * Play the sound
  41847. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41848. * @param offset (optional) Start the sound at a specific time in seconds
  41849. * @param length (optional) Sound duration (in seconds)
  41850. */
  41851. play(time?: number, offset?: number, length?: number): void;
  41852. private _onended;
  41853. /**
  41854. * Stop the sound
  41855. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41856. */
  41857. stop(time?: number): void;
  41858. /**
  41859. * Put the sound in pause
  41860. */
  41861. pause(): void;
  41862. /**
  41863. * Sets a dedicated volume for this sounds
  41864. * @param newVolume Define the new volume of the sound
  41865. * @param time Define time for gradual change to new volume
  41866. */
  41867. setVolume(newVolume: number, time?: number): void;
  41868. /**
  41869. * Set the sound play back rate
  41870. * @param newPlaybackRate Define the playback rate the sound should be played at
  41871. */
  41872. setPlaybackRate(newPlaybackRate: number): void;
  41873. /**
  41874. * Gets the volume of the sound.
  41875. * @returns the volume of the sound
  41876. */
  41877. getVolume(): number;
  41878. /**
  41879. * Attach the sound to a dedicated mesh
  41880. * @param transformNode The transform node to connect the sound with
  41881. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41882. */
  41883. attachToMesh(transformNode: TransformNode): void;
  41884. /**
  41885. * Detach the sound from the previously attached mesh
  41886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41887. */
  41888. detachFromMesh(): void;
  41889. private _onRegisterAfterWorldMatrixUpdate;
  41890. /**
  41891. * Clone the current sound in the scene.
  41892. * @returns the new sound clone
  41893. */
  41894. clone(): Nullable<Sound>;
  41895. /**
  41896. * Gets the current underlying audio buffer containing the data
  41897. * @returns the audio buffer
  41898. */
  41899. getAudioBuffer(): Nullable<AudioBuffer>;
  41900. /**
  41901. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41902. * @returns the source node
  41903. */
  41904. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41905. /**
  41906. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41907. * @returns the gain node
  41908. */
  41909. getSoundGain(): Nullable<GainNode>;
  41910. /**
  41911. * Serializes the Sound in a JSON representation
  41912. * @returns the JSON representation of the sound
  41913. */
  41914. serialize(): any;
  41915. /**
  41916. * Parse a JSON representation of a sound to innstantiate in a given scene
  41917. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41918. * @param scene Define the scene the new parsed sound should be created in
  41919. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41920. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41921. * @returns the newly parsed sound
  41922. */
  41923. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * This defines an action helpful to play a defined sound on a triggered action.
  41929. */
  41930. export class PlaySoundAction extends Action {
  41931. private _sound;
  41932. /**
  41933. * Instantiate the action
  41934. * @param triggerOptions defines the trigger options
  41935. * @param sound defines the sound to play
  41936. * @param condition defines the trigger related conditions
  41937. */
  41938. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41939. /** @hidden */
  41940. _prepare(): void;
  41941. /**
  41942. * Execute the action and play the sound.
  41943. */
  41944. execute(): void;
  41945. /**
  41946. * Serializes the actions and its related information.
  41947. * @param parent defines the object to serialize in
  41948. * @returns the serialized object
  41949. */
  41950. serialize(parent: any): any;
  41951. }
  41952. /**
  41953. * This defines an action helpful to stop a defined sound on a triggered action.
  41954. */
  41955. export class StopSoundAction extends Action {
  41956. private _sound;
  41957. /**
  41958. * Instantiate the action
  41959. * @param triggerOptions defines the trigger options
  41960. * @param sound defines the sound to stop
  41961. * @param condition defines the trigger related conditions
  41962. */
  41963. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41964. /** @hidden */
  41965. _prepare(): void;
  41966. /**
  41967. * Execute the action and stop the sound.
  41968. */
  41969. execute(): void;
  41970. /**
  41971. * Serializes the actions and its related information.
  41972. * @param parent defines the object to serialize in
  41973. * @returns the serialized object
  41974. */
  41975. serialize(parent: any): any;
  41976. }
  41977. }
  41978. declare module BABYLON {
  41979. /**
  41980. * This defines an action responsible to change the value of a property
  41981. * by interpolating between its current value and the newly set one once triggered.
  41982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41983. */
  41984. export class InterpolateValueAction extends Action {
  41985. /**
  41986. * Defines the path of the property where the value should be interpolated
  41987. */
  41988. propertyPath: string;
  41989. /**
  41990. * Defines the target value at the end of the interpolation.
  41991. */
  41992. value: any;
  41993. /**
  41994. * Defines the time it will take for the property to interpolate to the value.
  41995. */
  41996. duration: number;
  41997. /**
  41998. * Defines if the other scene animations should be stopped when the action has been triggered
  41999. */
  42000. stopOtherAnimations?: boolean;
  42001. /**
  42002. * Defines a callback raised once the interpolation animation has been done.
  42003. */
  42004. onInterpolationDone?: () => void;
  42005. /**
  42006. * Observable triggered once the interpolation animation has been done.
  42007. */
  42008. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42009. private _target;
  42010. private _effectiveTarget;
  42011. private _property;
  42012. /**
  42013. * Instantiate the action
  42014. * @param triggerOptions defines the trigger options
  42015. * @param target defines the object containing the value to interpolate
  42016. * @param propertyPath defines the path to the property in the target object
  42017. * @param value defines the target value at the end of the interpolation
  42018. * @param duration deines the time it will take for the property to interpolate to the value.
  42019. * @param condition defines the trigger related conditions
  42020. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42021. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42022. */
  42023. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42024. /** @hidden */
  42025. _prepare(): void;
  42026. /**
  42027. * Execute the action starts the value interpolation.
  42028. */
  42029. execute(): void;
  42030. /**
  42031. * Serializes the actions and its related information.
  42032. * @param parent defines the object to serialize in
  42033. * @returns the serialized object
  42034. */
  42035. serialize(parent: any): any;
  42036. }
  42037. }
  42038. declare module BABYLON {
  42039. /**
  42040. * Options allowed during the creation of a sound track.
  42041. */
  42042. export interface ISoundTrackOptions {
  42043. /**
  42044. * The volume the sound track should take during creation
  42045. */
  42046. volume?: number;
  42047. /**
  42048. * Define if the sound track is the main sound track of the scene
  42049. */
  42050. mainTrack?: boolean;
  42051. }
  42052. /**
  42053. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42054. * It will be also used in a future release to apply effects on a specific track.
  42055. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42056. */
  42057. export class SoundTrack {
  42058. /**
  42059. * The unique identifier of the sound track in the scene.
  42060. */
  42061. id: number;
  42062. /**
  42063. * The list of sounds included in the sound track.
  42064. */
  42065. soundCollection: Array<Sound>;
  42066. private _outputAudioNode;
  42067. private _scene;
  42068. private _connectedAnalyser;
  42069. private _options;
  42070. private _isInitialized;
  42071. /**
  42072. * Creates a new sound track.
  42073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42074. * @param scene Define the scene the sound track belongs to
  42075. * @param options
  42076. */
  42077. constructor(scene: Scene, options?: ISoundTrackOptions);
  42078. private _initializeSoundTrackAudioGraph;
  42079. /**
  42080. * Release the sound track and its associated resources
  42081. */
  42082. dispose(): void;
  42083. /**
  42084. * Adds a sound to this sound track
  42085. * @param sound define the cound to add
  42086. * @ignoreNaming
  42087. */
  42088. AddSound(sound: Sound): void;
  42089. /**
  42090. * Removes a sound to this sound track
  42091. * @param sound define the cound to remove
  42092. * @ignoreNaming
  42093. */
  42094. RemoveSound(sound: Sound): void;
  42095. /**
  42096. * Set a global volume for the full sound track.
  42097. * @param newVolume Define the new volume of the sound track
  42098. */
  42099. setVolume(newVolume: number): void;
  42100. /**
  42101. * Switch the panning model to HRTF:
  42102. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42104. */
  42105. switchPanningModelToHRTF(): void;
  42106. /**
  42107. * Switch the panning model to Equal Power:
  42108. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42110. */
  42111. switchPanningModelToEqualPower(): void;
  42112. /**
  42113. * Connect the sound track to an audio analyser allowing some amazing
  42114. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42116. * @param analyser The analyser to connect to the engine
  42117. */
  42118. connectToAnalyser(analyser: Analyser): void;
  42119. }
  42120. }
  42121. declare module BABYLON {
  42122. interface AbstractScene {
  42123. /**
  42124. * The list of sounds used in the scene.
  42125. */
  42126. sounds: Nullable<Array<Sound>>;
  42127. }
  42128. interface Scene {
  42129. /**
  42130. * @hidden
  42131. * Backing field
  42132. */
  42133. _mainSoundTrack: SoundTrack;
  42134. /**
  42135. * The main sound track played by the scene.
  42136. * It cotains your primary collection of sounds.
  42137. */
  42138. mainSoundTrack: SoundTrack;
  42139. /**
  42140. * The list of sound tracks added to the scene
  42141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42142. */
  42143. soundTracks: Nullable<Array<SoundTrack>>;
  42144. /**
  42145. * Gets a sound using a given name
  42146. * @param name defines the name to search for
  42147. * @return the found sound or null if not found at all.
  42148. */
  42149. getSoundByName(name: string): Nullable<Sound>;
  42150. /**
  42151. * Gets or sets if audio support is enabled
  42152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42153. */
  42154. audioEnabled: boolean;
  42155. /**
  42156. * Gets or sets if audio will be output to headphones
  42157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42158. */
  42159. headphone: boolean;
  42160. /**
  42161. * Gets or sets custom audio listener position provider
  42162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42163. */
  42164. audioListenerPositionProvider: Nullable<() => Vector3>;
  42165. /**
  42166. * Gets or sets a refresh rate when using 3D audio positioning
  42167. */
  42168. audioPositioningRefreshRate: number;
  42169. }
  42170. /**
  42171. * Defines the sound scene component responsible to manage any sounds
  42172. * in a given scene.
  42173. */
  42174. export class AudioSceneComponent implements ISceneSerializableComponent {
  42175. private static _CameraDirectionLH;
  42176. private static _CameraDirectionRH;
  42177. /**
  42178. * The component name helpfull to identify the component in the list of scene components.
  42179. */
  42180. readonly name: string;
  42181. /**
  42182. * The scene the component belongs to.
  42183. */
  42184. scene: Scene;
  42185. private _audioEnabled;
  42186. /**
  42187. * Gets whether audio is enabled or not.
  42188. * Please use related enable/disable method to switch state.
  42189. */
  42190. get audioEnabled(): boolean;
  42191. private _headphone;
  42192. /**
  42193. * Gets whether audio is outputing to headphone or not.
  42194. * Please use the according Switch methods to change output.
  42195. */
  42196. get headphone(): boolean;
  42197. /**
  42198. * Gets or sets a refresh rate when using 3D audio positioning
  42199. */
  42200. audioPositioningRefreshRate: number;
  42201. private _audioListenerPositionProvider;
  42202. /**
  42203. * Gets the current audio listener position provider
  42204. */
  42205. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42206. /**
  42207. * Sets a custom listener position for all sounds in the scene
  42208. * By default, this is the position of the first active camera
  42209. */
  42210. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42211. /**
  42212. * Creates a new instance of the component for the given scene
  42213. * @param scene Defines the scene to register the component in
  42214. */
  42215. constructor(scene: Scene);
  42216. /**
  42217. * Registers the component in a given scene
  42218. */
  42219. register(): void;
  42220. /**
  42221. * Rebuilds the elements related to this component in case of
  42222. * context lost for instance.
  42223. */
  42224. rebuild(): void;
  42225. /**
  42226. * Serializes the component data to the specified json object
  42227. * @param serializationObject The object to serialize to
  42228. */
  42229. serialize(serializationObject: any): void;
  42230. /**
  42231. * Adds all the elements from the container to the scene
  42232. * @param container the container holding the elements
  42233. */
  42234. addFromContainer(container: AbstractScene): void;
  42235. /**
  42236. * Removes all the elements in the container from the scene
  42237. * @param container contains the elements to remove
  42238. * @param dispose if the removed element should be disposed (default: false)
  42239. */
  42240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42241. /**
  42242. * Disposes the component and the associated ressources.
  42243. */
  42244. dispose(): void;
  42245. /**
  42246. * Disables audio in the associated scene.
  42247. */
  42248. disableAudio(): void;
  42249. /**
  42250. * Enables audio in the associated scene.
  42251. */
  42252. enableAudio(): void;
  42253. /**
  42254. * Switch audio to headphone output.
  42255. */
  42256. switchAudioModeForHeadphones(): void;
  42257. /**
  42258. * Switch audio to normal speakers.
  42259. */
  42260. switchAudioModeForNormalSpeakers(): void;
  42261. private _cachedCameraDirection;
  42262. private _cachedCameraPosition;
  42263. private _lastCheck;
  42264. private _afterRender;
  42265. }
  42266. }
  42267. declare module BABYLON {
  42268. /**
  42269. * Wraps one or more Sound objects and selects one with random weight for playback.
  42270. */
  42271. export class WeightedSound {
  42272. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42273. loop: boolean;
  42274. private _coneInnerAngle;
  42275. private _coneOuterAngle;
  42276. private _volume;
  42277. /** A Sound is currently playing. */
  42278. isPlaying: boolean;
  42279. /** A Sound is currently paused. */
  42280. isPaused: boolean;
  42281. private _sounds;
  42282. private _weights;
  42283. private _currentIndex?;
  42284. /**
  42285. * Creates a new WeightedSound from the list of sounds given.
  42286. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42287. * @param sounds Array of Sounds that will be selected from.
  42288. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42289. */
  42290. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42291. /**
  42292. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42293. */
  42294. get directionalConeInnerAngle(): number;
  42295. /**
  42296. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42297. */
  42298. set directionalConeInnerAngle(value: number);
  42299. /**
  42300. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42301. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42302. */
  42303. get directionalConeOuterAngle(): number;
  42304. /**
  42305. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42306. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42307. */
  42308. set directionalConeOuterAngle(value: number);
  42309. /**
  42310. * Playback volume.
  42311. */
  42312. get volume(): number;
  42313. /**
  42314. * Playback volume.
  42315. */
  42316. set volume(value: number);
  42317. private _onended;
  42318. /**
  42319. * Suspend playback
  42320. */
  42321. pause(): void;
  42322. /**
  42323. * Stop playback
  42324. */
  42325. stop(): void;
  42326. /**
  42327. * Start playback.
  42328. * @param startOffset Position the clip head at a specific time in seconds.
  42329. */
  42330. play(startOffset?: number): void;
  42331. }
  42332. }
  42333. declare module BABYLON {
  42334. /**
  42335. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42336. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42337. */
  42338. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42339. /**
  42340. * Gets the name of the behavior.
  42341. */
  42342. get name(): string;
  42343. /**
  42344. * The easing function used by animations
  42345. */
  42346. static EasingFunction: BackEase;
  42347. /**
  42348. * The easing mode used by animations
  42349. */
  42350. static EasingMode: number;
  42351. /**
  42352. * The duration of the animation, in milliseconds
  42353. */
  42354. transitionDuration: number;
  42355. /**
  42356. * Length of the distance animated by the transition when lower radius is reached
  42357. */
  42358. lowerRadiusTransitionRange: number;
  42359. /**
  42360. * Length of the distance animated by the transition when upper radius is reached
  42361. */
  42362. upperRadiusTransitionRange: number;
  42363. private _autoTransitionRange;
  42364. /**
  42365. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42366. */
  42367. get autoTransitionRange(): boolean;
  42368. /**
  42369. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42370. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42371. */
  42372. set autoTransitionRange(value: boolean);
  42373. private _attachedCamera;
  42374. private _onAfterCheckInputsObserver;
  42375. private _onMeshTargetChangedObserver;
  42376. /**
  42377. * Initializes the behavior.
  42378. */
  42379. init(): void;
  42380. /**
  42381. * Attaches the behavior to its arc rotate camera.
  42382. * @param camera Defines the camera to attach the behavior to
  42383. */
  42384. attach(camera: ArcRotateCamera): void;
  42385. /**
  42386. * Detaches the behavior from its current arc rotate camera.
  42387. */
  42388. detach(): void;
  42389. private _radiusIsAnimating;
  42390. private _radiusBounceTransition;
  42391. private _animatables;
  42392. private _cachedWheelPrecision;
  42393. /**
  42394. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42395. * @param radiusLimit The limit to check against.
  42396. * @return Bool to indicate if at limit.
  42397. */
  42398. private _isRadiusAtLimit;
  42399. /**
  42400. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42401. * @param radiusDelta The delta by which to animate to. Can be negative.
  42402. */
  42403. private _applyBoundRadiusAnimation;
  42404. /**
  42405. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42406. */
  42407. protected _clearAnimationLocks(): void;
  42408. /**
  42409. * Stops and removes all animations that have been applied to the camera
  42410. */
  42411. stopAllAnimations(): void;
  42412. }
  42413. }
  42414. declare module BABYLON {
  42415. /**
  42416. * 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.
  42417. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42418. */
  42419. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42420. /**
  42421. * Gets the name of the behavior.
  42422. */
  42423. get name(): string;
  42424. private _mode;
  42425. private _radiusScale;
  42426. private _positionScale;
  42427. private _defaultElevation;
  42428. private _elevationReturnTime;
  42429. private _elevationReturnWaitTime;
  42430. private _zoomStopsAnimation;
  42431. private _framingTime;
  42432. /**
  42433. * The easing function used by animations
  42434. */
  42435. static EasingFunction: ExponentialEase;
  42436. /**
  42437. * The easing mode used by animations
  42438. */
  42439. static EasingMode: number;
  42440. /**
  42441. * Sets the current mode used by the behavior
  42442. */
  42443. set mode(mode: number);
  42444. /**
  42445. * Gets current mode used by the behavior.
  42446. */
  42447. get mode(): number;
  42448. /**
  42449. * Sets the scale applied to the radius (1 by default)
  42450. */
  42451. set radiusScale(radius: number);
  42452. /**
  42453. * Gets the scale applied to the radius
  42454. */
  42455. get radiusScale(): number;
  42456. /**
  42457. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42458. */
  42459. set positionScale(scale: number);
  42460. /**
  42461. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42462. */
  42463. get positionScale(): number;
  42464. /**
  42465. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42466. * behaviour is triggered, in radians.
  42467. */
  42468. set defaultElevation(elevation: number);
  42469. /**
  42470. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42471. * behaviour is triggered, in radians.
  42472. */
  42473. get defaultElevation(): number;
  42474. /**
  42475. * Sets the time (in milliseconds) taken to return to the default beta position.
  42476. * Negative value indicates camera should not return to default.
  42477. */
  42478. set elevationReturnTime(speed: number);
  42479. /**
  42480. * Gets the time (in milliseconds) taken to return to the default beta position.
  42481. * Negative value indicates camera should not return to default.
  42482. */
  42483. get elevationReturnTime(): number;
  42484. /**
  42485. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42486. */
  42487. set elevationReturnWaitTime(time: number);
  42488. /**
  42489. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42490. */
  42491. get elevationReturnWaitTime(): number;
  42492. /**
  42493. * Sets the flag that indicates if user zooming should stop animation.
  42494. */
  42495. set zoomStopsAnimation(flag: boolean);
  42496. /**
  42497. * Gets the flag that indicates if user zooming should stop animation.
  42498. */
  42499. get zoomStopsAnimation(): boolean;
  42500. /**
  42501. * Sets the transition time when framing the mesh, in milliseconds
  42502. */
  42503. set framingTime(time: number);
  42504. /**
  42505. * Gets the transition time when framing the mesh, in milliseconds
  42506. */
  42507. get framingTime(): number;
  42508. /**
  42509. * Define if the behavior should automatically change the configured
  42510. * camera limits and sensibilities.
  42511. */
  42512. autoCorrectCameraLimitsAndSensibility: boolean;
  42513. private _onPrePointerObservableObserver;
  42514. private _onAfterCheckInputsObserver;
  42515. private _onMeshTargetChangedObserver;
  42516. private _attachedCamera;
  42517. private _isPointerDown;
  42518. private _lastInteractionTime;
  42519. /**
  42520. * Initializes the behavior.
  42521. */
  42522. init(): void;
  42523. /**
  42524. * Attaches the behavior to its arc rotate camera.
  42525. * @param camera Defines the camera to attach the behavior to
  42526. */
  42527. attach(camera: ArcRotateCamera): void;
  42528. /**
  42529. * Detaches the behavior from its current arc rotate camera.
  42530. */
  42531. detach(): void;
  42532. private _animatables;
  42533. private _betaIsAnimating;
  42534. private _betaTransition;
  42535. private _radiusTransition;
  42536. private _vectorTransition;
  42537. /**
  42538. * Targets the given mesh and updates zoom level accordingly.
  42539. * @param mesh The mesh to target.
  42540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42542. */
  42543. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42544. /**
  42545. * Targets the given mesh with its children and updates zoom level accordingly.
  42546. * @param mesh The mesh to target.
  42547. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42548. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42549. */
  42550. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42551. /**
  42552. * Targets the given meshes with their children and updates zoom level accordingly.
  42553. * @param meshes The mesh to target.
  42554. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42555. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42556. */
  42557. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42558. /**
  42559. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42560. * @param minimumWorld Determines the smaller position of the bounding box extend
  42561. * @param maximumWorld Determines the bigger position of the bounding box extend
  42562. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42563. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42564. */
  42565. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42566. /**
  42567. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42568. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42569. * frustum width.
  42570. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42571. * to fully enclose the mesh in the viewing frustum.
  42572. */
  42573. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42574. /**
  42575. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42576. * is automatically returned to its default position (expected to be above ground plane).
  42577. */
  42578. private _maintainCameraAboveGround;
  42579. /**
  42580. * Returns the frustum slope based on the canvas ratio and camera FOV
  42581. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42582. */
  42583. private _getFrustumSlope;
  42584. /**
  42585. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42586. */
  42587. private _clearAnimationLocks;
  42588. /**
  42589. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42590. */
  42591. private _applyUserInteraction;
  42592. /**
  42593. * Stops and removes all animations that have been applied to the camera
  42594. */
  42595. stopAllAnimations(): void;
  42596. /**
  42597. * Gets a value indicating if the user is moving the camera
  42598. */
  42599. get isUserIsMoving(): boolean;
  42600. /**
  42601. * The camera can move all the way towards the mesh.
  42602. */
  42603. static IgnoreBoundsSizeMode: number;
  42604. /**
  42605. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42606. */
  42607. static FitFrustumSidesMode: number;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /**
  42612. * Base class for Camera Pointer Inputs.
  42613. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42614. * for example usage.
  42615. */
  42616. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42617. /**
  42618. * Defines the camera the input is attached to.
  42619. */
  42620. abstract camera: Camera;
  42621. /**
  42622. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42623. */
  42624. protected _altKey: boolean;
  42625. protected _ctrlKey: boolean;
  42626. protected _metaKey: boolean;
  42627. protected _shiftKey: boolean;
  42628. /**
  42629. * Which mouse buttons were pressed at time of last mouse event.
  42630. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42631. */
  42632. protected _buttonsPressed: number;
  42633. /**
  42634. * Defines the buttons associated with the input to handle camera move.
  42635. */
  42636. buttons: number[];
  42637. /**
  42638. * Attach the input controls to a specific dom element to get the input from.
  42639. * @param element Defines the element the controls should be listened from
  42640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42641. */
  42642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42643. /**
  42644. * Detach the current controls from the specified dom element.
  42645. * @param element Defines the element to stop listening the inputs from
  42646. */
  42647. detachControl(element: Nullable<HTMLElement>): void;
  42648. /**
  42649. * Gets the class name of the current input.
  42650. * @returns the class name
  42651. */
  42652. getClassName(): string;
  42653. /**
  42654. * Get the friendly name associated with the input class.
  42655. * @returns the input friendly name
  42656. */
  42657. getSimpleName(): string;
  42658. /**
  42659. * Called on pointer POINTERDOUBLETAP event.
  42660. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42661. */
  42662. protected onDoubleTap(type: string): void;
  42663. /**
  42664. * Called on pointer POINTERMOVE event if only a single touch is active.
  42665. * Override this method to provide functionality.
  42666. */
  42667. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42668. /**
  42669. * Called on pointer POINTERMOVE event if multiple touches are active.
  42670. * Override this method to provide functionality.
  42671. */
  42672. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42673. /**
  42674. * Called on JS contextmenu event.
  42675. * Override this method to provide functionality.
  42676. */
  42677. protected onContextMenu(evt: PointerEvent): void;
  42678. /**
  42679. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42680. * press.
  42681. * Override this method to provide functionality.
  42682. */
  42683. protected onButtonDown(evt: PointerEvent): void;
  42684. /**
  42685. * Called each time a new POINTERUP event occurs. Ie, for each button
  42686. * release.
  42687. * Override this method to provide functionality.
  42688. */
  42689. protected onButtonUp(evt: PointerEvent): void;
  42690. /**
  42691. * Called when window becomes inactive.
  42692. * Override this method to provide functionality.
  42693. */
  42694. protected onLostFocus(): void;
  42695. private _pointerInput;
  42696. private _observer;
  42697. private _onLostFocus;
  42698. private pointA;
  42699. private pointB;
  42700. }
  42701. }
  42702. declare module BABYLON {
  42703. /**
  42704. * Manage the pointers inputs to control an arc rotate camera.
  42705. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42706. */
  42707. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42708. /**
  42709. * Defines the camera the input is attached to.
  42710. */
  42711. camera: ArcRotateCamera;
  42712. /**
  42713. * Gets the class name of the current input.
  42714. * @returns the class name
  42715. */
  42716. getClassName(): string;
  42717. /**
  42718. * Defines the buttons associated with the input to handle camera move.
  42719. */
  42720. buttons: number[];
  42721. /**
  42722. * Defines the pointer angular sensibility along the X axis or how fast is
  42723. * the camera rotating.
  42724. */
  42725. angularSensibilityX: number;
  42726. /**
  42727. * Defines the pointer angular sensibility along the Y axis or how fast is
  42728. * the camera rotating.
  42729. */
  42730. angularSensibilityY: number;
  42731. /**
  42732. * Defines the pointer pinch precision or how fast is the camera zooming.
  42733. */
  42734. pinchPrecision: number;
  42735. /**
  42736. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42737. * from 0.
  42738. * It defines the percentage of current camera.radius to use as delta when
  42739. * pinch zoom is used.
  42740. */
  42741. pinchDeltaPercentage: number;
  42742. /**
  42743. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42744. * that any object in the plane at the camera's target point will scale
  42745. * perfectly with finger motion.
  42746. * Overrides pinchDeltaPercentage and pinchPrecision.
  42747. */
  42748. useNaturalPinchZoom: boolean;
  42749. /**
  42750. * Defines the pointer panning sensibility or how fast is the camera moving.
  42751. */
  42752. panningSensibility: number;
  42753. /**
  42754. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42755. */
  42756. multiTouchPanning: boolean;
  42757. /**
  42758. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42759. * zoom (pinch) through multitouch.
  42760. */
  42761. multiTouchPanAndZoom: boolean;
  42762. /**
  42763. * Revers pinch action direction.
  42764. */
  42765. pinchInwards: boolean;
  42766. private _isPanClick;
  42767. private _twoFingerActivityCount;
  42768. private _isPinching;
  42769. /**
  42770. * Called on pointer POINTERMOVE event if only a single touch is active.
  42771. */
  42772. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42773. /**
  42774. * Called on pointer POINTERDOUBLETAP event.
  42775. */
  42776. protected onDoubleTap(type: string): void;
  42777. /**
  42778. * Called on pointer POINTERMOVE event if multiple touches are active.
  42779. */
  42780. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42781. /**
  42782. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42783. * press.
  42784. */
  42785. protected onButtonDown(evt: PointerEvent): void;
  42786. /**
  42787. * Called each time a new POINTERUP event occurs. Ie, for each button
  42788. * release.
  42789. */
  42790. protected onButtonUp(evt: PointerEvent): void;
  42791. /**
  42792. * Called when window becomes inactive.
  42793. */
  42794. protected onLostFocus(): void;
  42795. }
  42796. }
  42797. declare module BABYLON {
  42798. /**
  42799. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42800. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42801. */
  42802. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42803. /**
  42804. * Defines the camera the input is attached to.
  42805. */
  42806. camera: ArcRotateCamera;
  42807. /**
  42808. * Defines the list of key codes associated with the up action (increase alpha)
  42809. */
  42810. keysUp: number[];
  42811. /**
  42812. * Defines the list of key codes associated with the down action (decrease alpha)
  42813. */
  42814. keysDown: number[];
  42815. /**
  42816. * Defines the list of key codes associated with the left action (increase beta)
  42817. */
  42818. keysLeft: number[];
  42819. /**
  42820. * Defines the list of key codes associated with the right action (decrease beta)
  42821. */
  42822. keysRight: number[];
  42823. /**
  42824. * Defines the list of key codes associated with the reset action.
  42825. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42826. */
  42827. keysReset: number[];
  42828. /**
  42829. * Defines the panning sensibility of the inputs.
  42830. * (How fast is the camera panning)
  42831. */
  42832. panningSensibility: number;
  42833. /**
  42834. * Defines the zooming sensibility of the inputs.
  42835. * (How fast is the camera zooming)
  42836. */
  42837. zoomingSensibility: number;
  42838. /**
  42839. * Defines whether maintaining the alt key down switch the movement mode from
  42840. * orientation to zoom.
  42841. */
  42842. useAltToZoom: boolean;
  42843. /**
  42844. * Rotation speed of the camera
  42845. */
  42846. angularSpeed: number;
  42847. private _keys;
  42848. private _ctrlPressed;
  42849. private _altPressed;
  42850. private _onCanvasBlurObserver;
  42851. private _onKeyboardObserver;
  42852. private _engine;
  42853. private _scene;
  42854. /**
  42855. * Attach the input controls to a specific dom element to get the input from.
  42856. * @param element Defines the element the controls should be listened from
  42857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42858. */
  42859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42860. /**
  42861. * Detach the current controls from the specified dom element.
  42862. * @param element Defines the element to stop listening the inputs from
  42863. */
  42864. detachControl(element: Nullable<HTMLElement>): void;
  42865. /**
  42866. * Update the current camera state depending on the inputs that have been used this frame.
  42867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42868. */
  42869. checkInputs(): void;
  42870. /**
  42871. * Gets the class name of the current intput.
  42872. * @returns the class name
  42873. */
  42874. getClassName(): string;
  42875. /**
  42876. * Get the friendly name associated with the input class.
  42877. * @returns the input friendly name
  42878. */
  42879. getSimpleName(): string;
  42880. }
  42881. }
  42882. declare module BABYLON {
  42883. /**
  42884. * Manage the mouse wheel inputs to control an arc rotate camera.
  42885. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42886. */
  42887. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42888. /**
  42889. * Defines the camera the input is attached to.
  42890. */
  42891. camera: ArcRotateCamera;
  42892. /**
  42893. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42894. */
  42895. wheelPrecision: number;
  42896. /**
  42897. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42898. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42899. */
  42900. wheelDeltaPercentage: number;
  42901. private _wheel;
  42902. private _observer;
  42903. private computeDeltaFromMouseWheelLegacyEvent;
  42904. /**
  42905. * Attach the input controls to a specific dom element to get the input from.
  42906. * @param element Defines the element the controls should be listened from
  42907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42908. */
  42909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42910. /**
  42911. * Detach the current controls from the specified dom element.
  42912. * @param element Defines the element to stop listening the inputs from
  42913. */
  42914. detachControl(element: Nullable<HTMLElement>): void;
  42915. /**
  42916. * Gets the class name of the current intput.
  42917. * @returns the class name
  42918. */
  42919. getClassName(): string;
  42920. /**
  42921. * Get the friendly name associated with the input class.
  42922. * @returns the input friendly name
  42923. */
  42924. getSimpleName(): string;
  42925. }
  42926. }
  42927. declare module BABYLON {
  42928. /**
  42929. * Default Inputs manager for the ArcRotateCamera.
  42930. * It groups all the default supported inputs for ease of use.
  42931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42932. */
  42933. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42934. /**
  42935. * Instantiates a new ArcRotateCameraInputsManager.
  42936. * @param camera Defines the camera the inputs belong to
  42937. */
  42938. constructor(camera: ArcRotateCamera);
  42939. /**
  42940. * Add mouse wheel input support to the input manager.
  42941. * @returns the current input manager
  42942. */
  42943. addMouseWheel(): ArcRotateCameraInputsManager;
  42944. /**
  42945. * Add pointers input support to the input manager.
  42946. * @returns the current input manager
  42947. */
  42948. addPointers(): ArcRotateCameraInputsManager;
  42949. /**
  42950. * Add keyboard input support to the input manager.
  42951. * @returns the current input manager
  42952. */
  42953. addKeyboard(): ArcRotateCameraInputsManager;
  42954. }
  42955. }
  42956. declare module BABYLON {
  42957. /**
  42958. * This represents an orbital type of camera.
  42959. *
  42960. * 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.
  42961. * 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.
  42962. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42963. */
  42964. export class ArcRotateCamera extends TargetCamera {
  42965. /**
  42966. * Defines the rotation angle of the camera along the longitudinal axis.
  42967. */
  42968. alpha: number;
  42969. /**
  42970. * Defines the rotation angle of the camera along the latitudinal axis.
  42971. */
  42972. beta: number;
  42973. /**
  42974. * Defines the radius of the camera from it s target point.
  42975. */
  42976. radius: number;
  42977. protected _target: Vector3;
  42978. protected _targetHost: Nullable<AbstractMesh>;
  42979. /**
  42980. * Defines the target point of the camera.
  42981. * The camera looks towards it form the radius distance.
  42982. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42983. */
  42984. get target(): Vector3;
  42985. set target(value: Vector3);
  42986. /**
  42987. * Define the current local position of the camera in the scene
  42988. */
  42989. get position(): Vector3;
  42990. set position(newPosition: Vector3);
  42991. protected _upToYMatrix: Matrix;
  42992. protected _YToUpMatrix: Matrix;
  42993. /**
  42994. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42995. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42996. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42997. */
  42998. set upVector(vec: Vector3);
  42999. get upVector(): Vector3;
  43000. /**
  43001. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43002. */
  43003. setMatUp(): void;
  43004. /**
  43005. * Current inertia value on the longitudinal axis.
  43006. * The bigger this number the longer it will take for the camera to stop.
  43007. */
  43008. inertialAlphaOffset: number;
  43009. /**
  43010. * Current inertia value on the latitudinal axis.
  43011. * The bigger this number the longer it will take for the camera to stop.
  43012. */
  43013. inertialBetaOffset: number;
  43014. /**
  43015. * Current inertia value on the radius axis.
  43016. * The bigger this number the longer it will take for the camera to stop.
  43017. */
  43018. inertialRadiusOffset: number;
  43019. /**
  43020. * Minimum allowed angle on the longitudinal axis.
  43021. * This can help limiting how the Camera is able to move in the scene.
  43022. */
  43023. lowerAlphaLimit: Nullable<number>;
  43024. /**
  43025. * Maximum allowed angle on the longitudinal axis.
  43026. * This can help limiting how the Camera is able to move in the scene.
  43027. */
  43028. upperAlphaLimit: Nullable<number>;
  43029. /**
  43030. * Minimum allowed angle on the latitudinal axis.
  43031. * This can help limiting how the Camera is able to move in the scene.
  43032. */
  43033. lowerBetaLimit: number;
  43034. /**
  43035. * Maximum allowed angle on the latitudinal axis.
  43036. * This can help limiting how the Camera is able to move in the scene.
  43037. */
  43038. upperBetaLimit: number;
  43039. /**
  43040. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43041. * This can help limiting how the Camera is able to move in the scene.
  43042. */
  43043. lowerRadiusLimit: Nullable<number>;
  43044. /**
  43045. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43046. * This can help limiting how the Camera is able to move in the scene.
  43047. */
  43048. upperRadiusLimit: Nullable<number>;
  43049. /**
  43050. * Defines the current inertia value used during panning of the camera along the X axis.
  43051. */
  43052. inertialPanningX: number;
  43053. /**
  43054. * Defines the current inertia value used during panning of the camera along the Y axis.
  43055. */
  43056. inertialPanningY: number;
  43057. /**
  43058. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43059. * Basically if your fingers moves away from more than this distance you will be considered
  43060. * in pinch mode.
  43061. */
  43062. pinchToPanMaxDistance: number;
  43063. /**
  43064. * Defines the maximum distance the camera can pan.
  43065. * This could help keeping the cammera always in your scene.
  43066. */
  43067. panningDistanceLimit: Nullable<number>;
  43068. /**
  43069. * Defines the target of the camera before paning.
  43070. */
  43071. panningOriginTarget: Vector3;
  43072. /**
  43073. * Defines the value of the inertia used during panning.
  43074. * 0 would mean stop inertia and one would mean no decelleration at all.
  43075. */
  43076. panningInertia: number;
  43077. /**
  43078. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43079. */
  43080. get angularSensibilityX(): number;
  43081. set angularSensibilityX(value: number);
  43082. /**
  43083. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43084. */
  43085. get angularSensibilityY(): number;
  43086. set angularSensibilityY(value: number);
  43087. /**
  43088. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43089. */
  43090. get pinchPrecision(): number;
  43091. set pinchPrecision(value: number);
  43092. /**
  43093. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43094. * It will be used instead of pinchDeltaPrecision if different from 0.
  43095. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43096. */
  43097. get pinchDeltaPercentage(): number;
  43098. set pinchDeltaPercentage(value: number);
  43099. /**
  43100. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43101. * and pinch delta percentage.
  43102. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43103. * that any object in the plane at the camera's target point will scale
  43104. * perfectly with finger motion.
  43105. */
  43106. get useNaturalPinchZoom(): boolean;
  43107. set useNaturalPinchZoom(value: boolean);
  43108. /**
  43109. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43110. */
  43111. get panningSensibility(): number;
  43112. set panningSensibility(value: number);
  43113. /**
  43114. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43115. */
  43116. get keysUp(): number[];
  43117. set keysUp(value: number[]);
  43118. /**
  43119. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43120. */
  43121. get keysDown(): number[];
  43122. set keysDown(value: number[]);
  43123. /**
  43124. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43125. */
  43126. get keysLeft(): number[];
  43127. set keysLeft(value: number[]);
  43128. /**
  43129. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43130. */
  43131. get keysRight(): number[];
  43132. set keysRight(value: number[]);
  43133. /**
  43134. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43135. */
  43136. get wheelPrecision(): number;
  43137. set wheelPrecision(value: number);
  43138. /**
  43139. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43140. * It will be used instead of pinchDeltaPrecision if different from 0.
  43141. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43142. */
  43143. get wheelDeltaPercentage(): number;
  43144. set wheelDeltaPercentage(value: number);
  43145. /**
  43146. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43147. */
  43148. zoomOnFactor: number;
  43149. /**
  43150. * Defines a screen offset for the camera position.
  43151. */
  43152. targetScreenOffset: Vector2;
  43153. /**
  43154. * Allows the camera to be completely reversed.
  43155. * If false the camera can not arrive upside down.
  43156. */
  43157. allowUpsideDown: boolean;
  43158. /**
  43159. * Define if double tap/click is used to restore the previously saved state of the camera.
  43160. */
  43161. useInputToRestoreState: boolean;
  43162. /** @hidden */
  43163. _viewMatrix: Matrix;
  43164. /** @hidden */
  43165. _useCtrlForPanning: boolean;
  43166. /** @hidden */
  43167. _panningMouseButton: number;
  43168. /**
  43169. * Defines the input associated to the camera.
  43170. */
  43171. inputs: ArcRotateCameraInputsManager;
  43172. /** @hidden */
  43173. _reset: () => void;
  43174. /**
  43175. * Defines the allowed panning axis.
  43176. */
  43177. panningAxis: Vector3;
  43178. protected _localDirection: Vector3;
  43179. protected _transformedDirection: Vector3;
  43180. private _bouncingBehavior;
  43181. /**
  43182. * Gets the bouncing behavior of the camera if it has been enabled.
  43183. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43184. */
  43185. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43186. /**
  43187. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43188. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43189. */
  43190. get useBouncingBehavior(): boolean;
  43191. set useBouncingBehavior(value: boolean);
  43192. private _framingBehavior;
  43193. /**
  43194. * Gets the framing behavior of the camera if it has been enabled.
  43195. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43196. */
  43197. get framingBehavior(): Nullable<FramingBehavior>;
  43198. /**
  43199. * Defines if the framing behavior of the camera is enabled on the camera.
  43200. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43201. */
  43202. get useFramingBehavior(): boolean;
  43203. set useFramingBehavior(value: boolean);
  43204. private _autoRotationBehavior;
  43205. /**
  43206. * Gets the auto rotation behavior of the camera if it has been enabled.
  43207. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43208. */
  43209. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43210. /**
  43211. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43212. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43213. */
  43214. get useAutoRotationBehavior(): boolean;
  43215. set useAutoRotationBehavior(value: boolean);
  43216. /**
  43217. * Observable triggered when the mesh target has been changed on the camera.
  43218. */
  43219. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43220. /**
  43221. * Event raised when the camera is colliding with a mesh.
  43222. */
  43223. onCollide: (collidedMesh: AbstractMesh) => void;
  43224. /**
  43225. * Defines whether the camera should check collision with the objects oh the scene.
  43226. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43227. */
  43228. checkCollisions: boolean;
  43229. /**
  43230. * Defines the collision radius of the camera.
  43231. * This simulates a sphere around the camera.
  43232. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43233. */
  43234. collisionRadius: Vector3;
  43235. protected _collider: Collider;
  43236. protected _previousPosition: Vector3;
  43237. protected _collisionVelocity: Vector3;
  43238. protected _newPosition: Vector3;
  43239. protected _previousAlpha: number;
  43240. protected _previousBeta: number;
  43241. protected _previousRadius: number;
  43242. protected _collisionTriggered: boolean;
  43243. protected _targetBoundingCenter: Nullable<Vector3>;
  43244. private _computationVector;
  43245. /**
  43246. * Instantiates a new ArcRotateCamera in a given scene
  43247. * @param name Defines the name of the camera
  43248. * @param alpha Defines the camera rotation along the logitudinal axis
  43249. * @param beta Defines the camera rotation along the latitudinal axis
  43250. * @param radius Defines the camera distance from its target
  43251. * @param target Defines the camera target
  43252. * @param scene Defines the scene the camera belongs to
  43253. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43254. */
  43255. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43256. /** @hidden */
  43257. _initCache(): void;
  43258. /** @hidden */
  43259. _updateCache(ignoreParentClass?: boolean): void;
  43260. protected _getTargetPosition(): Vector3;
  43261. private _storedAlpha;
  43262. private _storedBeta;
  43263. private _storedRadius;
  43264. private _storedTarget;
  43265. private _storedTargetScreenOffset;
  43266. /**
  43267. * Stores the current state of the camera (alpha, beta, radius and target)
  43268. * @returns the camera itself
  43269. */
  43270. storeState(): Camera;
  43271. /**
  43272. * @hidden
  43273. * Restored camera state. You must call storeState() first
  43274. */
  43275. _restoreStateValues(): boolean;
  43276. /** @hidden */
  43277. _isSynchronizedViewMatrix(): boolean;
  43278. /**
  43279. * Attached controls to the current camera.
  43280. * @param element Defines the element the controls should be listened from
  43281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43282. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43283. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43284. */
  43285. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43286. /**
  43287. * Detach the current controls from the camera.
  43288. * The camera will stop reacting to inputs.
  43289. * @param element Defines the element to stop listening the inputs from
  43290. */
  43291. detachControl(element: HTMLElement): void;
  43292. /** @hidden */
  43293. _checkInputs(): void;
  43294. protected _checkLimits(): void;
  43295. /**
  43296. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43297. */
  43298. rebuildAnglesAndRadius(): void;
  43299. /**
  43300. * Use a position to define the current camera related information like alpha, beta and radius
  43301. * @param position Defines the position to set the camera at
  43302. */
  43303. setPosition(position: Vector3): void;
  43304. /**
  43305. * Defines the target the camera should look at.
  43306. * This will automatically adapt alpha beta and radius to fit within the new target.
  43307. * @param target Defines the new target as a Vector or a mesh
  43308. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43309. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43310. */
  43311. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43312. /** @hidden */
  43313. _getViewMatrix(): Matrix;
  43314. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43315. /**
  43316. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43317. * @param meshes Defines the mesh to zoom on
  43318. * @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)
  43319. */
  43320. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43321. /**
  43322. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43323. * The target will be changed but the radius
  43324. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43325. * @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)
  43326. */
  43327. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43328. min: Vector3;
  43329. max: Vector3;
  43330. distance: number;
  43331. }, doNotUpdateMaxZ?: boolean): void;
  43332. /**
  43333. * @override
  43334. * Override Camera.createRigCamera
  43335. */
  43336. createRigCamera(name: string, cameraIndex: number): Camera;
  43337. /**
  43338. * @hidden
  43339. * @override
  43340. * Override Camera._updateRigCameras
  43341. */
  43342. _updateRigCameras(): void;
  43343. /**
  43344. * Destroy the camera and release the current resources hold by it.
  43345. */
  43346. dispose(): void;
  43347. /**
  43348. * Gets the current object class name.
  43349. * @return the class name
  43350. */
  43351. getClassName(): string;
  43352. }
  43353. }
  43354. declare module BABYLON {
  43355. /**
  43356. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43357. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43358. */
  43359. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43360. /**
  43361. * Gets the name of the behavior.
  43362. */
  43363. get name(): string;
  43364. private _zoomStopsAnimation;
  43365. private _idleRotationSpeed;
  43366. private _idleRotationWaitTime;
  43367. private _idleRotationSpinupTime;
  43368. /**
  43369. * Sets the flag that indicates if user zooming should stop animation.
  43370. */
  43371. set zoomStopsAnimation(flag: boolean);
  43372. /**
  43373. * Gets the flag that indicates if user zooming should stop animation.
  43374. */
  43375. get zoomStopsAnimation(): boolean;
  43376. /**
  43377. * Sets the default speed at which the camera rotates around the model.
  43378. */
  43379. set idleRotationSpeed(speed: number);
  43380. /**
  43381. * Gets the default speed at which the camera rotates around the model.
  43382. */
  43383. get idleRotationSpeed(): number;
  43384. /**
  43385. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43386. */
  43387. set idleRotationWaitTime(time: number);
  43388. /**
  43389. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43390. */
  43391. get idleRotationWaitTime(): number;
  43392. /**
  43393. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43394. */
  43395. set idleRotationSpinupTime(time: number);
  43396. /**
  43397. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43398. */
  43399. get idleRotationSpinupTime(): number;
  43400. /**
  43401. * Gets a value indicating if the camera is currently rotating because of this behavior
  43402. */
  43403. get rotationInProgress(): boolean;
  43404. private _onPrePointerObservableObserver;
  43405. private _onAfterCheckInputsObserver;
  43406. private _attachedCamera;
  43407. private _isPointerDown;
  43408. private _lastFrameTime;
  43409. private _lastInteractionTime;
  43410. private _cameraRotationSpeed;
  43411. /**
  43412. * Initializes the behavior.
  43413. */
  43414. init(): void;
  43415. /**
  43416. * Attaches the behavior to its arc rotate camera.
  43417. * @param camera Defines the camera to attach the behavior to
  43418. */
  43419. attach(camera: ArcRotateCamera): void;
  43420. /**
  43421. * Detaches the behavior from its current arc rotate camera.
  43422. */
  43423. detach(): void;
  43424. /**
  43425. * Returns true if user is scrolling.
  43426. * @return true if user is scrolling.
  43427. */
  43428. private _userIsZooming;
  43429. private _lastFrameRadius;
  43430. private _shouldAnimationStopForInteraction;
  43431. /**
  43432. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43433. */
  43434. private _applyUserInteraction;
  43435. private _userIsMoving;
  43436. }
  43437. }
  43438. declare module BABYLON {
  43439. /**
  43440. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43441. */
  43442. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43443. private ui;
  43444. /**
  43445. * The name of the behavior
  43446. */
  43447. name: string;
  43448. /**
  43449. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43450. */
  43451. distanceAwayFromFace: number;
  43452. /**
  43453. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43454. */
  43455. distanceAwayFromBottomOfFace: number;
  43456. private _faceVectors;
  43457. private _target;
  43458. private _scene;
  43459. private _onRenderObserver;
  43460. private _tmpMatrix;
  43461. private _tmpVector;
  43462. /**
  43463. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43464. * @param ui The transform node that should be attched to the mesh
  43465. */
  43466. constructor(ui: TransformNode);
  43467. /**
  43468. * Initializes the behavior
  43469. */
  43470. init(): void;
  43471. private _closestFace;
  43472. private _zeroVector;
  43473. private _lookAtTmpMatrix;
  43474. private _lookAtToRef;
  43475. /**
  43476. * Attaches the AttachToBoxBehavior to the passed in mesh
  43477. * @param target The mesh that the specified node will be attached to
  43478. */
  43479. attach(target: Mesh): void;
  43480. /**
  43481. * Detaches the behavior from the mesh
  43482. */
  43483. detach(): void;
  43484. }
  43485. }
  43486. declare module BABYLON {
  43487. /**
  43488. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43489. */
  43490. export class FadeInOutBehavior implements Behavior<Mesh> {
  43491. /**
  43492. * Time in milliseconds to delay before fading in (Default: 0)
  43493. */
  43494. delay: number;
  43495. /**
  43496. * Time in milliseconds for the mesh to fade in (Default: 300)
  43497. */
  43498. fadeInTime: number;
  43499. private _millisecondsPerFrame;
  43500. private _hovered;
  43501. private _hoverValue;
  43502. private _ownerNode;
  43503. /**
  43504. * Instatiates the FadeInOutBehavior
  43505. */
  43506. constructor();
  43507. /**
  43508. * The name of the behavior
  43509. */
  43510. get name(): string;
  43511. /**
  43512. * Initializes the behavior
  43513. */
  43514. init(): void;
  43515. /**
  43516. * Attaches the fade behavior on the passed in mesh
  43517. * @param ownerNode The mesh that will be faded in/out once attached
  43518. */
  43519. attach(ownerNode: Mesh): void;
  43520. /**
  43521. * Detaches the behavior from the mesh
  43522. */
  43523. detach(): void;
  43524. /**
  43525. * Triggers the mesh to begin fading in or out
  43526. * @param value if the object should fade in or out (true to fade in)
  43527. */
  43528. fadeIn(value: boolean): void;
  43529. private _update;
  43530. private _setAllVisibility;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Class containing a set of static utilities functions for managing Pivots
  43536. * @hidden
  43537. */
  43538. export class PivotTools {
  43539. private static _PivotCached;
  43540. private static _OldPivotPoint;
  43541. private static _PivotTranslation;
  43542. private static _PivotTmpVector;
  43543. private static _PivotPostMultiplyPivotMatrix;
  43544. /** @hidden */
  43545. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43546. /** @hidden */
  43547. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43548. }
  43549. }
  43550. declare module BABYLON {
  43551. /**
  43552. * Class containing static functions to help procedurally build meshes
  43553. */
  43554. export class PlaneBuilder {
  43555. /**
  43556. * Creates a plane mesh
  43557. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43558. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43559. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43561. * * 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
  43562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43563. * @param name defines the name of the mesh
  43564. * @param options defines the options used to create the mesh
  43565. * @param scene defines the hosting scene
  43566. * @returns the plane mesh
  43567. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43568. */
  43569. static CreatePlane(name: string, options: {
  43570. size?: number;
  43571. width?: number;
  43572. height?: number;
  43573. sideOrientation?: number;
  43574. frontUVs?: Vector4;
  43575. backUVs?: Vector4;
  43576. updatable?: boolean;
  43577. sourcePlane?: Plane;
  43578. }, scene?: Nullable<Scene>): Mesh;
  43579. }
  43580. }
  43581. declare module BABYLON {
  43582. /**
  43583. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43584. */
  43585. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43586. private static _AnyMouseID;
  43587. /**
  43588. * Abstract mesh the behavior is set on
  43589. */
  43590. attachedNode: AbstractMesh;
  43591. private _dragPlane;
  43592. private _scene;
  43593. private _pointerObserver;
  43594. private _beforeRenderObserver;
  43595. private static _planeScene;
  43596. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43597. /**
  43598. * 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)
  43599. */
  43600. maxDragAngle: number;
  43601. /**
  43602. * @hidden
  43603. */
  43604. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43605. /**
  43606. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43607. */
  43608. currentDraggingPointerID: number;
  43609. /**
  43610. * The last position where the pointer hit the drag plane in world space
  43611. */
  43612. lastDragPosition: Vector3;
  43613. /**
  43614. * If the behavior is currently in a dragging state
  43615. */
  43616. dragging: boolean;
  43617. /**
  43618. * 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)
  43619. */
  43620. dragDeltaRatio: number;
  43621. /**
  43622. * If the drag plane orientation should be updated during the dragging (Default: true)
  43623. */
  43624. updateDragPlane: boolean;
  43625. private _debugMode;
  43626. private _moving;
  43627. /**
  43628. * Fires each time the attached mesh is dragged with the pointer
  43629. * * delta between last drag position and current drag position in world space
  43630. * * dragDistance along the drag axis
  43631. * * dragPlaneNormal normal of the current drag plane used during the drag
  43632. * * dragPlanePoint in world space where the drag intersects the drag plane
  43633. */
  43634. onDragObservable: Observable<{
  43635. delta: Vector3;
  43636. dragPlanePoint: Vector3;
  43637. dragPlaneNormal: Vector3;
  43638. dragDistance: number;
  43639. pointerId: number;
  43640. }>;
  43641. /**
  43642. * Fires each time a drag begins (eg. mouse down on mesh)
  43643. */
  43644. onDragStartObservable: Observable<{
  43645. dragPlanePoint: Vector3;
  43646. pointerId: number;
  43647. }>;
  43648. /**
  43649. * Fires each time a drag ends (eg. mouse release after drag)
  43650. */
  43651. onDragEndObservable: Observable<{
  43652. dragPlanePoint: Vector3;
  43653. pointerId: number;
  43654. }>;
  43655. /**
  43656. * If the attached mesh should be moved when dragged
  43657. */
  43658. moveAttached: boolean;
  43659. /**
  43660. * If the drag behavior will react to drag events (Default: true)
  43661. */
  43662. enabled: boolean;
  43663. /**
  43664. * If pointer events should start and release the drag (Default: true)
  43665. */
  43666. startAndReleaseDragOnPointerEvents: boolean;
  43667. /**
  43668. * If camera controls should be detached during the drag
  43669. */
  43670. detachCameraControls: boolean;
  43671. /**
  43672. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43673. */
  43674. useObjectOrientationForDragging: boolean;
  43675. private _options;
  43676. /**
  43677. * Gets the options used by the behavior
  43678. */
  43679. get options(): {
  43680. dragAxis?: Vector3;
  43681. dragPlaneNormal?: Vector3;
  43682. };
  43683. /**
  43684. * Sets the options used by the behavior
  43685. */
  43686. set options(options: {
  43687. dragAxis?: Vector3;
  43688. dragPlaneNormal?: Vector3;
  43689. });
  43690. /**
  43691. * Creates a pointer drag behavior that can be attached to a mesh
  43692. * @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)
  43693. */
  43694. constructor(options?: {
  43695. dragAxis?: Vector3;
  43696. dragPlaneNormal?: Vector3;
  43697. });
  43698. /**
  43699. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43700. */
  43701. validateDrag: (targetPosition: Vector3) => boolean;
  43702. /**
  43703. * The name of the behavior
  43704. */
  43705. get name(): string;
  43706. /**
  43707. * Initializes the behavior
  43708. */
  43709. init(): void;
  43710. private _tmpVector;
  43711. private _alternatePickedPoint;
  43712. private _worldDragAxis;
  43713. private _targetPosition;
  43714. private _attachedElement;
  43715. /**
  43716. * Attaches the drag behavior the passed in mesh
  43717. * @param ownerNode The mesh that will be dragged around once attached
  43718. * @param predicate Predicate to use for pick filtering
  43719. */
  43720. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43721. /**
  43722. * Force relase the drag action by code.
  43723. */
  43724. releaseDrag(): void;
  43725. private _startDragRay;
  43726. private _lastPointerRay;
  43727. /**
  43728. * Simulates the start of a pointer drag event on the behavior
  43729. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43730. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43731. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43732. */
  43733. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43734. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43735. private _dragDelta;
  43736. protected _moveDrag(ray: Ray): void;
  43737. private _pickWithRayOnDragPlane;
  43738. private _pointA;
  43739. private _pointC;
  43740. private _localAxis;
  43741. private _lookAt;
  43742. private _updateDragPlanePosition;
  43743. /**
  43744. * Detaches the behavior from the mesh
  43745. */
  43746. detach(): void;
  43747. }
  43748. }
  43749. declare module BABYLON {
  43750. /**
  43751. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43752. */
  43753. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43754. private _dragBehaviorA;
  43755. private _dragBehaviorB;
  43756. private _startDistance;
  43757. private _initialScale;
  43758. private _targetScale;
  43759. private _ownerNode;
  43760. private _sceneRenderObserver;
  43761. /**
  43762. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43763. */
  43764. constructor();
  43765. /**
  43766. * The name of the behavior
  43767. */
  43768. get name(): string;
  43769. /**
  43770. * Initializes the behavior
  43771. */
  43772. init(): void;
  43773. private _getCurrentDistance;
  43774. /**
  43775. * Attaches the scale behavior the passed in mesh
  43776. * @param ownerNode The mesh that will be scaled around once attached
  43777. */
  43778. attach(ownerNode: Mesh): void;
  43779. /**
  43780. * Detaches the behavior from the mesh
  43781. */
  43782. detach(): void;
  43783. }
  43784. }
  43785. declare module BABYLON {
  43786. /**
  43787. * 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
  43788. */
  43789. export class SixDofDragBehavior implements Behavior<Mesh> {
  43790. private static _virtualScene;
  43791. private _ownerNode;
  43792. private _sceneRenderObserver;
  43793. private _scene;
  43794. private _targetPosition;
  43795. private _virtualOriginMesh;
  43796. private _virtualDragMesh;
  43797. private _pointerObserver;
  43798. private _moving;
  43799. private _startingOrientation;
  43800. private _attachedElement;
  43801. /**
  43802. * 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)
  43803. */
  43804. private zDragFactor;
  43805. /**
  43806. * If the object should rotate to face the drag origin
  43807. */
  43808. rotateDraggedObject: boolean;
  43809. /**
  43810. * If the behavior is currently in a dragging state
  43811. */
  43812. dragging: boolean;
  43813. /**
  43814. * 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)
  43815. */
  43816. dragDeltaRatio: number;
  43817. /**
  43818. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43819. */
  43820. currentDraggingPointerID: number;
  43821. /**
  43822. * If camera controls should be detached during the drag
  43823. */
  43824. detachCameraControls: boolean;
  43825. /**
  43826. * Fires each time a drag starts
  43827. */
  43828. onDragStartObservable: Observable<{}>;
  43829. /**
  43830. * Fires each time a drag ends (eg. mouse release after drag)
  43831. */
  43832. onDragEndObservable: Observable<{}>;
  43833. /**
  43834. * 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
  43835. */
  43836. constructor();
  43837. /**
  43838. * The name of the behavior
  43839. */
  43840. get name(): string;
  43841. /**
  43842. * Initializes the behavior
  43843. */
  43844. init(): void;
  43845. /**
  43846. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43847. */
  43848. private get _pointerCamera();
  43849. /**
  43850. * Attaches the scale behavior the passed in mesh
  43851. * @param ownerNode The mesh that will be scaled around once attached
  43852. */
  43853. attach(ownerNode: Mesh): void;
  43854. /**
  43855. * Detaches the behavior from the mesh
  43856. */
  43857. detach(): void;
  43858. }
  43859. }
  43860. declare module BABYLON {
  43861. /**
  43862. * Class used to apply inverse kinematics to bones
  43863. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43864. */
  43865. export class BoneIKController {
  43866. private static _tmpVecs;
  43867. private static _tmpQuat;
  43868. private static _tmpMats;
  43869. /**
  43870. * Gets or sets the target mesh
  43871. */
  43872. targetMesh: AbstractMesh;
  43873. /** Gets or sets the mesh used as pole */
  43874. poleTargetMesh: AbstractMesh;
  43875. /**
  43876. * Gets or sets the bone used as pole
  43877. */
  43878. poleTargetBone: Nullable<Bone>;
  43879. /**
  43880. * Gets or sets the target position
  43881. */
  43882. targetPosition: Vector3;
  43883. /**
  43884. * Gets or sets the pole target position
  43885. */
  43886. poleTargetPosition: Vector3;
  43887. /**
  43888. * Gets or sets the pole target local offset
  43889. */
  43890. poleTargetLocalOffset: Vector3;
  43891. /**
  43892. * Gets or sets the pole angle
  43893. */
  43894. poleAngle: number;
  43895. /**
  43896. * Gets or sets the mesh associated with the controller
  43897. */
  43898. mesh: AbstractMesh;
  43899. /**
  43900. * 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)
  43901. */
  43902. slerpAmount: number;
  43903. private _bone1Quat;
  43904. private _bone1Mat;
  43905. private _bone2Ang;
  43906. private _bone1;
  43907. private _bone2;
  43908. private _bone1Length;
  43909. private _bone2Length;
  43910. private _maxAngle;
  43911. private _maxReach;
  43912. private _rightHandedSystem;
  43913. private _bendAxis;
  43914. private _slerping;
  43915. private _adjustRoll;
  43916. /**
  43917. * Gets or sets maximum allowed angle
  43918. */
  43919. get maxAngle(): number;
  43920. set maxAngle(value: number);
  43921. /**
  43922. * Creates a new BoneIKController
  43923. * @param mesh defines the mesh to control
  43924. * @param bone defines the bone to control
  43925. * @param options defines options to set up the controller
  43926. */
  43927. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43928. targetMesh?: AbstractMesh;
  43929. poleTargetMesh?: AbstractMesh;
  43930. poleTargetBone?: Bone;
  43931. poleTargetLocalOffset?: Vector3;
  43932. poleAngle?: number;
  43933. bendAxis?: Vector3;
  43934. maxAngle?: number;
  43935. slerpAmount?: number;
  43936. });
  43937. private _setMaxAngle;
  43938. /**
  43939. * Force the controller to update the bones
  43940. */
  43941. update(): void;
  43942. }
  43943. }
  43944. declare module BABYLON {
  43945. /**
  43946. * Class used to make a bone look toward a point in space
  43947. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43948. */
  43949. export class BoneLookController {
  43950. private static _tmpVecs;
  43951. private static _tmpQuat;
  43952. private static _tmpMats;
  43953. /**
  43954. * The target Vector3 that the bone will look at
  43955. */
  43956. target: Vector3;
  43957. /**
  43958. * The mesh that the bone is attached to
  43959. */
  43960. mesh: AbstractMesh;
  43961. /**
  43962. * The bone that will be looking to the target
  43963. */
  43964. bone: Bone;
  43965. /**
  43966. * The up axis of the coordinate system that is used when the bone is rotated
  43967. */
  43968. upAxis: Vector3;
  43969. /**
  43970. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43971. */
  43972. upAxisSpace: Space;
  43973. /**
  43974. * Used to make an adjustment to the yaw of the bone
  43975. */
  43976. adjustYaw: number;
  43977. /**
  43978. * Used to make an adjustment to the pitch of the bone
  43979. */
  43980. adjustPitch: number;
  43981. /**
  43982. * Used to make an adjustment to the roll of the bone
  43983. */
  43984. adjustRoll: number;
  43985. /**
  43986. * 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)
  43987. */
  43988. slerpAmount: number;
  43989. private _minYaw;
  43990. private _maxYaw;
  43991. private _minPitch;
  43992. private _maxPitch;
  43993. private _minYawSin;
  43994. private _minYawCos;
  43995. private _maxYawSin;
  43996. private _maxYawCos;
  43997. private _midYawConstraint;
  43998. private _minPitchTan;
  43999. private _maxPitchTan;
  44000. private _boneQuat;
  44001. private _slerping;
  44002. private _transformYawPitch;
  44003. private _transformYawPitchInv;
  44004. private _firstFrameSkipped;
  44005. private _yawRange;
  44006. private _fowardAxis;
  44007. /**
  44008. * Gets or sets the minimum yaw angle that the bone can look to
  44009. */
  44010. get minYaw(): number;
  44011. set minYaw(value: number);
  44012. /**
  44013. * Gets or sets the maximum yaw angle that the bone can look to
  44014. */
  44015. get maxYaw(): number;
  44016. set maxYaw(value: number);
  44017. /**
  44018. * Gets or sets the minimum pitch angle that the bone can look to
  44019. */
  44020. get minPitch(): number;
  44021. set minPitch(value: number);
  44022. /**
  44023. * Gets or sets the maximum pitch angle that the bone can look to
  44024. */
  44025. get maxPitch(): number;
  44026. set maxPitch(value: number);
  44027. /**
  44028. * Create a BoneLookController
  44029. * @param mesh the mesh that the bone belongs to
  44030. * @param bone the bone that will be looking to the target
  44031. * @param target the target Vector3 to look at
  44032. * @param options optional settings:
  44033. * * maxYaw: the maximum angle the bone will yaw to
  44034. * * minYaw: the minimum angle the bone will yaw to
  44035. * * maxPitch: the maximum angle the bone will pitch to
  44036. * * minPitch: the minimum angle the bone will yaw to
  44037. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44038. * * upAxis: the up axis of the coordinate system
  44039. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44040. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44041. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44042. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44043. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44044. * * adjustRoll: used to make an adjustment to the roll of the bone
  44045. **/
  44046. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44047. maxYaw?: number;
  44048. minYaw?: number;
  44049. maxPitch?: number;
  44050. minPitch?: number;
  44051. slerpAmount?: number;
  44052. upAxis?: Vector3;
  44053. upAxisSpace?: Space;
  44054. yawAxis?: Vector3;
  44055. pitchAxis?: Vector3;
  44056. adjustYaw?: number;
  44057. adjustPitch?: number;
  44058. adjustRoll?: number;
  44059. });
  44060. /**
  44061. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44062. */
  44063. update(): void;
  44064. private _getAngleDiff;
  44065. private _getAngleBetween;
  44066. private _isAngleBetween;
  44067. }
  44068. }
  44069. declare module BABYLON {
  44070. /**
  44071. * Manage the gamepad inputs to control an arc rotate camera.
  44072. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44073. */
  44074. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44075. /**
  44076. * Defines the camera the input is attached to.
  44077. */
  44078. camera: ArcRotateCamera;
  44079. /**
  44080. * Defines the gamepad the input is gathering event from.
  44081. */
  44082. gamepad: Nullable<Gamepad>;
  44083. /**
  44084. * Defines the gamepad rotation sensiblity.
  44085. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44086. */
  44087. gamepadRotationSensibility: number;
  44088. /**
  44089. * Defines the gamepad move sensiblity.
  44090. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44091. */
  44092. gamepadMoveSensibility: number;
  44093. private _yAxisScale;
  44094. /**
  44095. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44096. */
  44097. get invertYAxis(): boolean;
  44098. set invertYAxis(value: boolean);
  44099. private _onGamepadConnectedObserver;
  44100. private _onGamepadDisconnectedObserver;
  44101. /**
  44102. * Attach the input controls to a specific dom element to get the input from.
  44103. * @param element Defines the element the controls should be listened from
  44104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44105. */
  44106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44107. /**
  44108. * Detach the current controls from the specified dom element.
  44109. * @param element Defines the element to stop listening the inputs from
  44110. */
  44111. detachControl(element: Nullable<HTMLElement>): void;
  44112. /**
  44113. * Update the current camera state depending on the inputs that have been used this frame.
  44114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44115. */
  44116. checkInputs(): void;
  44117. /**
  44118. * Gets the class name of the current intput.
  44119. * @returns the class name
  44120. */
  44121. getClassName(): string;
  44122. /**
  44123. * Get the friendly name associated with the input class.
  44124. * @returns the input friendly name
  44125. */
  44126. getSimpleName(): string;
  44127. }
  44128. }
  44129. declare module BABYLON {
  44130. interface ArcRotateCameraInputsManager {
  44131. /**
  44132. * Add orientation input support to the input manager.
  44133. * @returns the current input manager
  44134. */
  44135. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44136. }
  44137. /**
  44138. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44139. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44140. */
  44141. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44142. /**
  44143. * Defines the camera the input is attached to.
  44144. */
  44145. camera: ArcRotateCamera;
  44146. /**
  44147. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44148. */
  44149. alphaCorrection: number;
  44150. /**
  44151. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44152. */
  44153. gammaCorrection: number;
  44154. private _alpha;
  44155. private _gamma;
  44156. private _dirty;
  44157. private _deviceOrientationHandler;
  44158. /**
  44159. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44160. */
  44161. constructor();
  44162. /**
  44163. * Attach the input controls to a specific dom element to get the input from.
  44164. * @param element Defines the element the controls should be listened from
  44165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44166. */
  44167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44168. /** @hidden */
  44169. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44170. /**
  44171. * Update the current camera state depending on the inputs that have been used this frame.
  44172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44173. */
  44174. checkInputs(): void;
  44175. /**
  44176. * Detach the current controls from the specified dom element.
  44177. * @param element Defines the element to stop listening the inputs from
  44178. */
  44179. detachControl(element: Nullable<HTMLElement>): void;
  44180. /**
  44181. * Gets the class name of the current intput.
  44182. * @returns the class name
  44183. */
  44184. getClassName(): string;
  44185. /**
  44186. * Get the friendly name associated with the input class.
  44187. * @returns the input friendly name
  44188. */
  44189. getSimpleName(): string;
  44190. }
  44191. }
  44192. declare module BABYLON {
  44193. /**
  44194. * Listen to mouse events to control the camera.
  44195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44196. */
  44197. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44198. /**
  44199. * Defines the camera the input is attached to.
  44200. */
  44201. camera: FlyCamera;
  44202. /**
  44203. * Defines if touch is enabled. (Default is true.)
  44204. */
  44205. touchEnabled: boolean;
  44206. /**
  44207. * Defines the buttons associated with the input to handle camera rotation.
  44208. */
  44209. buttons: number[];
  44210. /**
  44211. * Assign buttons for Yaw control.
  44212. */
  44213. buttonsYaw: number[];
  44214. /**
  44215. * Assign buttons for Pitch control.
  44216. */
  44217. buttonsPitch: number[];
  44218. /**
  44219. * Assign buttons for Roll control.
  44220. */
  44221. buttonsRoll: number[];
  44222. /**
  44223. * Detect if any button is being pressed while mouse is moved.
  44224. * -1 = Mouse locked.
  44225. * 0 = Left button.
  44226. * 1 = Middle Button.
  44227. * 2 = Right Button.
  44228. */
  44229. activeButton: number;
  44230. /**
  44231. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44232. * Higher values reduce its sensitivity.
  44233. */
  44234. angularSensibility: number;
  44235. private _mousemoveCallback;
  44236. private _observer;
  44237. private _rollObserver;
  44238. private previousPosition;
  44239. private noPreventDefault;
  44240. private element;
  44241. /**
  44242. * Listen to mouse events to control the camera.
  44243. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44245. */
  44246. constructor(touchEnabled?: boolean);
  44247. /**
  44248. * Attach the mouse control to the HTML DOM element.
  44249. * @param element Defines the element that listens to the input events.
  44250. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44251. */
  44252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44253. /**
  44254. * Detach the current controls from the specified dom element.
  44255. * @param element Defines the element to stop listening the inputs from
  44256. */
  44257. detachControl(element: Nullable<HTMLElement>): void;
  44258. /**
  44259. * Gets the class name of the current input.
  44260. * @returns the class name.
  44261. */
  44262. getClassName(): string;
  44263. /**
  44264. * Get the friendly name associated with the input class.
  44265. * @returns the input's friendly name.
  44266. */
  44267. getSimpleName(): string;
  44268. private _pointerInput;
  44269. private _onMouseMove;
  44270. /**
  44271. * Rotate camera by mouse offset.
  44272. */
  44273. private rotateCamera;
  44274. }
  44275. }
  44276. declare module BABYLON {
  44277. /**
  44278. * Default Inputs manager for the FlyCamera.
  44279. * It groups all the default supported inputs for ease of use.
  44280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44281. */
  44282. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44283. /**
  44284. * Instantiates a new FlyCameraInputsManager.
  44285. * @param camera Defines the camera the inputs belong to.
  44286. */
  44287. constructor(camera: FlyCamera);
  44288. /**
  44289. * Add keyboard input support to the input manager.
  44290. * @returns the new FlyCameraKeyboardMoveInput().
  44291. */
  44292. addKeyboard(): FlyCameraInputsManager;
  44293. /**
  44294. * Add mouse input support to the input manager.
  44295. * @param touchEnabled Enable touch screen support.
  44296. * @returns the new FlyCameraMouseInput().
  44297. */
  44298. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44299. }
  44300. }
  44301. declare module BABYLON {
  44302. /**
  44303. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44304. * such as in a 3D Space Shooter or a Flight Simulator.
  44305. */
  44306. export class FlyCamera extends TargetCamera {
  44307. /**
  44308. * Define the collision ellipsoid of the camera.
  44309. * This is helpful for simulating a camera body, like a player's body.
  44310. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44311. */
  44312. ellipsoid: Vector3;
  44313. /**
  44314. * Define an offset for the position of the ellipsoid around the camera.
  44315. * This can be helpful if the camera is attached away from the player's body center,
  44316. * such as at its head.
  44317. */
  44318. ellipsoidOffset: Vector3;
  44319. /**
  44320. * Enable or disable collisions of the camera with the rest of the scene objects.
  44321. */
  44322. checkCollisions: boolean;
  44323. /**
  44324. * Enable or disable gravity on the camera.
  44325. */
  44326. applyGravity: boolean;
  44327. /**
  44328. * Define the current direction the camera is moving to.
  44329. */
  44330. cameraDirection: Vector3;
  44331. /**
  44332. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44333. * This overrides and empties cameraRotation.
  44334. */
  44335. rotationQuaternion: Quaternion;
  44336. /**
  44337. * Track Roll to maintain the wanted Rolling when looking around.
  44338. */
  44339. _trackRoll: number;
  44340. /**
  44341. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44342. */
  44343. rollCorrect: number;
  44344. /**
  44345. * Mimic a banked turn, Rolling the camera when Yawing.
  44346. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44347. */
  44348. bankedTurn: boolean;
  44349. /**
  44350. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44351. */
  44352. bankedTurnLimit: number;
  44353. /**
  44354. * Value of 0 disables the banked Roll.
  44355. * Value of 1 is equal to the Yaw angle in radians.
  44356. */
  44357. bankedTurnMultiplier: number;
  44358. /**
  44359. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44360. */
  44361. inputs: FlyCameraInputsManager;
  44362. /**
  44363. * Gets the input sensibility for mouse input.
  44364. * Higher values reduce sensitivity.
  44365. */
  44366. get angularSensibility(): number;
  44367. /**
  44368. * Sets the input sensibility for a mouse input.
  44369. * Higher values reduce sensitivity.
  44370. */
  44371. set angularSensibility(value: number);
  44372. /**
  44373. * Get the keys for camera movement forward.
  44374. */
  44375. get keysForward(): number[];
  44376. /**
  44377. * Set the keys for camera movement forward.
  44378. */
  44379. set keysForward(value: number[]);
  44380. /**
  44381. * Get the keys for camera movement backward.
  44382. */
  44383. get keysBackward(): number[];
  44384. set keysBackward(value: number[]);
  44385. /**
  44386. * Get the keys for camera movement up.
  44387. */
  44388. get keysUp(): number[];
  44389. /**
  44390. * Set the keys for camera movement up.
  44391. */
  44392. set keysUp(value: number[]);
  44393. /**
  44394. * Get the keys for camera movement down.
  44395. */
  44396. get keysDown(): number[];
  44397. /**
  44398. * Set the keys for camera movement down.
  44399. */
  44400. set keysDown(value: number[]);
  44401. /**
  44402. * Get the keys for camera movement left.
  44403. */
  44404. get keysLeft(): number[];
  44405. /**
  44406. * Set the keys for camera movement left.
  44407. */
  44408. set keysLeft(value: number[]);
  44409. /**
  44410. * Set the keys for camera movement right.
  44411. */
  44412. get keysRight(): number[];
  44413. /**
  44414. * Set the keys for camera movement right.
  44415. */
  44416. set keysRight(value: number[]);
  44417. /**
  44418. * Event raised when the camera collides with a mesh in the scene.
  44419. */
  44420. onCollide: (collidedMesh: AbstractMesh) => void;
  44421. private _collider;
  44422. private _needMoveForGravity;
  44423. private _oldPosition;
  44424. private _diffPosition;
  44425. private _newPosition;
  44426. /** @hidden */
  44427. _localDirection: Vector3;
  44428. /** @hidden */
  44429. _transformedDirection: Vector3;
  44430. /**
  44431. * Instantiates a FlyCamera.
  44432. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44433. * such as in a 3D Space Shooter or a Flight Simulator.
  44434. * @param name Define the name of the camera in the scene.
  44435. * @param position Define the starting position of the camera in the scene.
  44436. * @param scene Define the scene the camera belongs to.
  44437. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44438. */
  44439. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44440. /**
  44441. * Attach a control to the HTML DOM element.
  44442. * @param element Defines the element that listens to the input events.
  44443. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44444. */
  44445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44446. /**
  44447. * Detach a control from the HTML DOM element.
  44448. * The camera will stop reacting to that input.
  44449. * @param element Defines the element that listens to the input events.
  44450. */
  44451. detachControl(element: HTMLElement): void;
  44452. private _collisionMask;
  44453. /**
  44454. * Get the mask that the camera ignores in collision events.
  44455. */
  44456. get collisionMask(): number;
  44457. /**
  44458. * Set the mask that the camera ignores in collision events.
  44459. */
  44460. set collisionMask(mask: number);
  44461. /** @hidden */
  44462. _collideWithWorld(displacement: Vector3): void;
  44463. /** @hidden */
  44464. private _onCollisionPositionChange;
  44465. /** @hidden */
  44466. _checkInputs(): void;
  44467. /** @hidden */
  44468. _decideIfNeedsToMove(): boolean;
  44469. /** @hidden */
  44470. _updatePosition(): void;
  44471. /**
  44472. * Restore the Roll to its target value at the rate specified.
  44473. * @param rate - Higher means slower restoring.
  44474. * @hidden
  44475. */
  44476. restoreRoll(rate: number): void;
  44477. /**
  44478. * Destroy the camera and release the current resources held by it.
  44479. */
  44480. dispose(): void;
  44481. /**
  44482. * Get the current object class name.
  44483. * @returns the class name.
  44484. */
  44485. getClassName(): string;
  44486. }
  44487. }
  44488. declare module BABYLON {
  44489. /**
  44490. * Listen to keyboard events to control the camera.
  44491. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44492. */
  44493. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44494. /**
  44495. * Defines the camera the input is attached to.
  44496. */
  44497. camera: FlyCamera;
  44498. /**
  44499. * The list of keyboard keys used to control the forward move of the camera.
  44500. */
  44501. keysForward: number[];
  44502. /**
  44503. * The list of keyboard keys used to control the backward move of the camera.
  44504. */
  44505. keysBackward: number[];
  44506. /**
  44507. * The list of keyboard keys used to control the forward move of the camera.
  44508. */
  44509. keysUp: number[];
  44510. /**
  44511. * The list of keyboard keys used to control the backward move of the camera.
  44512. */
  44513. keysDown: number[];
  44514. /**
  44515. * The list of keyboard keys used to control the right strafe move of the camera.
  44516. */
  44517. keysRight: number[];
  44518. /**
  44519. * The list of keyboard keys used to control the left strafe move of the camera.
  44520. */
  44521. keysLeft: number[];
  44522. private _keys;
  44523. private _onCanvasBlurObserver;
  44524. private _onKeyboardObserver;
  44525. private _engine;
  44526. private _scene;
  44527. /**
  44528. * Attach the input controls to a specific dom element to get the input from.
  44529. * @param element Defines the element the controls should be listened from
  44530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44531. */
  44532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44533. /**
  44534. * Detach the current controls from the specified dom element.
  44535. * @param element Defines the element to stop listening the inputs from
  44536. */
  44537. detachControl(element: Nullable<HTMLElement>): void;
  44538. /**
  44539. * Gets the class name of the current intput.
  44540. * @returns the class name
  44541. */
  44542. getClassName(): string;
  44543. /** @hidden */
  44544. _onLostFocus(e: FocusEvent): void;
  44545. /**
  44546. * Get the friendly name associated with the input class.
  44547. * @returns the input friendly name
  44548. */
  44549. getSimpleName(): string;
  44550. /**
  44551. * Update the current camera state depending on the inputs that have been used this frame.
  44552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44553. */
  44554. checkInputs(): void;
  44555. }
  44556. }
  44557. declare module BABYLON {
  44558. /**
  44559. * Manage the mouse wheel inputs to control a follow camera.
  44560. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44561. */
  44562. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44563. /**
  44564. * Defines the camera the input is attached to.
  44565. */
  44566. camera: FollowCamera;
  44567. /**
  44568. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44569. */
  44570. axisControlRadius: boolean;
  44571. /**
  44572. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44573. */
  44574. axisControlHeight: boolean;
  44575. /**
  44576. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44577. */
  44578. axisControlRotation: boolean;
  44579. /**
  44580. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44581. * relation to mouseWheel events.
  44582. */
  44583. wheelPrecision: number;
  44584. /**
  44585. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44586. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44587. */
  44588. wheelDeltaPercentage: number;
  44589. private _wheel;
  44590. private _observer;
  44591. /**
  44592. * Attach the input controls to a specific dom element to get the input from.
  44593. * @param element Defines the element the controls should be listened from
  44594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44595. */
  44596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44597. /**
  44598. * Detach the current controls from the specified dom element.
  44599. * @param element Defines the element to stop listening the inputs from
  44600. */
  44601. detachControl(element: Nullable<HTMLElement>): void;
  44602. /**
  44603. * Gets the class name of the current intput.
  44604. * @returns the class name
  44605. */
  44606. getClassName(): string;
  44607. /**
  44608. * Get the friendly name associated with the input class.
  44609. * @returns the input friendly name
  44610. */
  44611. getSimpleName(): string;
  44612. }
  44613. }
  44614. declare module BABYLON {
  44615. /**
  44616. * Manage the pointers inputs to control an follow camera.
  44617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44618. */
  44619. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44620. /**
  44621. * Defines the camera the input is attached to.
  44622. */
  44623. camera: FollowCamera;
  44624. /**
  44625. * Gets the class name of the current input.
  44626. * @returns the class name
  44627. */
  44628. getClassName(): string;
  44629. /**
  44630. * Defines the pointer angular sensibility along the X axis or how fast is
  44631. * the camera rotating.
  44632. * A negative number will reverse the axis direction.
  44633. */
  44634. angularSensibilityX: number;
  44635. /**
  44636. * Defines the pointer angular sensibility along the Y axis or how fast is
  44637. * the camera rotating.
  44638. * A negative number will reverse the axis direction.
  44639. */
  44640. angularSensibilityY: number;
  44641. /**
  44642. * Defines the pointer pinch precision or how fast is the camera zooming.
  44643. * A negative number will reverse the axis direction.
  44644. */
  44645. pinchPrecision: number;
  44646. /**
  44647. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44648. * from 0.
  44649. * It defines the percentage of current camera.radius to use as delta when
  44650. * pinch zoom is used.
  44651. */
  44652. pinchDeltaPercentage: number;
  44653. /**
  44654. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44655. */
  44656. axisXControlRadius: boolean;
  44657. /**
  44658. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44659. */
  44660. axisXControlHeight: boolean;
  44661. /**
  44662. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44663. */
  44664. axisXControlRotation: boolean;
  44665. /**
  44666. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44667. */
  44668. axisYControlRadius: boolean;
  44669. /**
  44670. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44671. */
  44672. axisYControlHeight: boolean;
  44673. /**
  44674. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44675. */
  44676. axisYControlRotation: boolean;
  44677. /**
  44678. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44679. */
  44680. axisPinchControlRadius: boolean;
  44681. /**
  44682. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44683. */
  44684. axisPinchControlHeight: boolean;
  44685. /**
  44686. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44687. */
  44688. axisPinchControlRotation: boolean;
  44689. /**
  44690. * Log error messages if basic misconfiguration has occurred.
  44691. */
  44692. warningEnable: boolean;
  44693. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44694. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44695. private _warningCounter;
  44696. private _warning;
  44697. }
  44698. }
  44699. declare module BABYLON {
  44700. /**
  44701. * Default Inputs manager for the FollowCamera.
  44702. * It groups all the default supported inputs for ease of use.
  44703. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44704. */
  44705. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44706. /**
  44707. * Instantiates a new FollowCameraInputsManager.
  44708. * @param camera Defines the camera the inputs belong to
  44709. */
  44710. constructor(camera: FollowCamera);
  44711. /**
  44712. * Add keyboard input support to the input manager.
  44713. * @returns the current input manager
  44714. */
  44715. addKeyboard(): FollowCameraInputsManager;
  44716. /**
  44717. * Add mouse wheel input support to the input manager.
  44718. * @returns the current input manager
  44719. */
  44720. addMouseWheel(): FollowCameraInputsManager;
  44721. /**
  44722. * Add pointers input support to the input manager.
  44723. * @returns the current input manager
  44724. */
  44725. addPointers(): FollowCameraInputsManager;
  44726. /**
  44727. * Add orientation input support to the input manager.
  44728. * @returns the current input manager
  44729. */
  44730. addVRDeviceOrientation(): FollowCameraInputsManager;
  44731. }
  44732. }
  44733. declare module BABYLON {
  44734. /**
  44735. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44736. * an arc rotate version arcFollowCamera are available.
  44737. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44738. */
  44739. export class FollowCamera extends TargetCamera {
  44740. /**
  44741. * Distance the follow camera should follow an object at
  44742. */
  44743. radius: number;
  44744. /**
  44745. * Minimum allowed distance of the camera to the axis of rotation
  44746. * (The camera can not get closer).
  44747. * This can help limiting how the Camera is able to move in the scene.
  44748. */
  44749. lowerRadiusLimit: Nullable<number>;
  44750. /**
  44751. * Maximum allowed distance of the camera to the axis of rotation
  44752. * (The camera can not get further).
  44753. * This can help limiting how the Camera is able to move in the scene.
  44754. */
  44755. upperRadiusLimit: Nullable<number>;
  44756. /**
  44757. * Define a rotation offset between the camera and the object it follows
  44758. */
  44759. rotationOffset: number;
  44760. /**
  44761. * Minimum allowed angle to camera position relative to target object.
  44762. * This can help limiting how the Camera is able to move in the scene.
  44763. */
  44764. lowerRotationOffsetLimit: Nullable<number>;
  44765. /**
  44766. * Maximum allowed angle to camera position relative to target object.
  44767. * This can help limiting how the Camera is able to move in the scene.
  44768. */
  44769. upperRotationOffsetLimit: Nullable<number>;
  44770. /**
  44771. * Define a height offset between the camera and the object it follows.
  44772. * It can help following an object from the top (like a car chaing a plane)
  44773. */
  44774. heightOffset: number;
  44775. /**
  44776. * Minimum allowed height of camera position relative to target object.
  44777. * This can help limiting how the Camera is able to move in the scene.
  44778. */
  44779. lowerHeightOffsetLimit: Nullable<number>;
  44780. /**
  44781. * Maximum allowed height of camera position relative to target object.
  44782. * This can help limiting how the Camera is able to move in the scene.
  44783. */
  44784. upperHeightOffsetLimit: Nullable<number>;
  44785. /**
  44786. * Define how fast the camera can accelerate to follow it s target.
  44787. */
  44788. cameraAcceleration: number;
  44789. /**
  44790. * Define the speed limit of the camera following an object.
  44791. */
  44792. maxCameraSpeed: number;
  44793. /**
  44794. * Define the target of the camera.
  44795. */
  44796. lockedTarget: Nullable<AbstractMesh>;
  44797. /**
  44798. * Defines the input associated with the camera.
  44799. */
  44800. inputs: FollowCameraInputsManager;
  44801. /**
  44802. * Instantiates the follow camera.
  44803. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44804. * @param name Define the name of the camera in the scene
  44805. * @param position Define the position of the camera
  44806. * @param scene Define the scene the camera belong to
  44807. * @param lockedTarget Define the target of the camera
  44808. */
  44809. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44810. private _follow;
  44811. /**
  44812. * Attached controls to the current camera.
  44813. * @param element Defines the element the controls should be listened from
  44814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44815. */
  44816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44817. /**
  44818. * Detach the current controls from the camera.
  44819. * The camera will stop reacting to inputs.
  44820. * @param element Defines the element to stop listening the inputs from
  44821. */
  44822. detachControl(element: HTMLElement): void;
  44823. /** @hidden */
  44824. _checkInputs(): void;
  44825. private _checkLimits;
  44826. /**
  44827. * Gets the camera class name.
  44828. * @returns the class name
  44829. */
  44830. getClassName(): string;
  44831. }
  44832. /**
  44833. * Arc Rotate version of the follow camera.
  44834. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44835. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44836. */
  44837. export class ArcFollowCamera extends TargetCamera {
  44838. /** The longitudinal angle of the camera */
  44839. alpha: number;
  44840. /** The latitudinal angle of the camera */
  44841. beta: number;
  44842. /** The radius of the camera from its target */
  44843. radius: number;
  44844. private _cartesianCoordinates;
  44845. /** Define the camera target (the mesh it should follow) */
  44846. private _meshTarget;
  44847. /**
  44848. * Instantiates a new ArcFollowCamera
  44849. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44850. * @param name Define the name of the camera
  44851. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44852. * @param beta Define the rotation angle of the camera around the elevation axis
  44853. * @param radius Define the radius of the camera from its target point
  44854. * @param target Define the target of the camera
  44855. * @param scene Define the scene the camera belongs to
  44856. */
  44857. constructor(name: string,
  44858. /** The longitudinal angle of the camera */
  44859. alpha: number,
  44860. /** The latitudinal angle of the camera */
  44861. beta: number,
  44862. /** The radius of the camera from its target */
  44863. radius: number,
  44864. /** Define the camera target (the mesh it should follow) */
  44865. target: Nullable<AbstractMesh>, scene: Scene);
  44866. private _follow;
  44867. /** @hidden */
  44868. _checkInputs(): void;
  44869. /**
  44870. * Returns the class name of the object.
  44871. * It is mostly used internally for serialization purposes.
  44872. */
  44873. getClassName(): string;
  44874. }
  44875. }
  44876. declare module BABYLON {
  44877. /**
  44878. * Manage the keyboard inputs to control the movement of a follow camera.
  44879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44880. */
  44881. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44882. /**
  44883. * Defines the camera the input is attached to.
  44884. */
  44885. camera: FollowCamera;
  44886. /**
  44887. * Defines the list of key codes associated with the up action (increase heightOffset)
  44888. */
  44889. keysHeightOffsetIncr: number[];
  44890. /**
  44891. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44892. */
  44893. keysHeightOffsetDecr: number[];
  44894. /**
  44895. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44896. */
  44897. keysHeightOffsetModifierAlt: boolean;
  44898. /**
  44899. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44900. */
  44901. keysHeightOffsetModifierCtrl: boolean;
  44902. /**
  44903. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44904. */
  44905. keysHeightOffsetModifierShift: boolean;
  44906. /**
  44907. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44908. */
  44909. keysRotationOffsetIncr: number[];
  44910. /**
  44911. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44912. */
  44913. keysRotationOffsetDecr: number[];
  44914. /**
  44915. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44916. */
  44917. keysRotationOffsetModifierAlt: boolean;
  44918. /**
  44919. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44920. */
  44921. keysRotationOffsetModifierCtrl: boolean;
  44922. /**
  44923. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44924. */
  44925. keysRotationOffsetModifierShift: boolean;
  44926. /**
  44927. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44928. */
  44929. keysRadiusIncr: number[];
  44930. /**
  44931. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44932. */
  44933. keysRadiusDecr: number[];
  44934. /**
  44935. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44936. */
  44937. keysRadiusModifierAlt: boolean;
  44938. /**
  44939. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44940. */
  44941. keysRadiusModifierCtrl: boolean;
  44942. /**
  44943. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44944. */
  44945. keysRadiusModifierShift: boolean;
  44946. /**
  44947. * Defines the rate of change of heightOffset.
  44948. */
  44949. heightSensibility: number;
  44950. /**
  44951. * Defines the rate of change of rotationOffset.
  44952. */
  44953. rotationSensibility: number;
  44954. /**
  44955. * Defines the rate of change of radius.
  44956. */
  44957. radiusSensibility: number;
  44958. private _keys;
  44959. private _ctrlPressed;
  44960. private _altPressed;
  44961. private _shiftPressed;
  44962. private _onCanvasBlurObserver;
  44963. private _onKeyboardObserver;
  44964. private _engine;
  44965. private _scene;
  44966. /**
  44967. * Attach the input controls to a specific dom element to get the input from.
  44968. * @param element Defines the element the controls should be listened from
  44969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44970. */
  44971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44972. /**
  44973. * Detach the current controls from the specified dom element.
  44974. * @param element Defines the element to stop listening the inputs from
  44975. */
  44976. detachControl(element: Nullable<HTMLElement>): void;
  44977. /**
  44978. * Update the current camera state depending on the inputs that have been used this frame.
  44979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44980. */
  44981. checkInputs(): void;
  44982. /**
  44983. * Gets the class name of the current input.
  44984. * @returns the class name
  44985. */
  44986. getClassName(): string;
  44987. /**
  44988. * Get the friendly name associated with the input class.
  44989. * @returns the input friendly name
  44990. */
  44991. getSimpleName(): string;
  44992. /**
  44993. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44994. * allow modification of the heightOffset value.
  44995. */
  44996. private _modifierHeightOffset;
  44997. /**
  44998. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44999. * allow modification of the rotationOffset value.
  45000. */
  45001. private _modifierRotationOffset;
  45002. /**
  45003. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45004. * allow modification of the radius value.
  45005. */
  45006. private _modifierRadius;
  45007. }
  45008. }
  45009. declare module BABYLON {
  45010. interface FreeCameraInputsManager {
  45011. /**
  45012. * @hidden
  45013. */
  45014. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45015. /**
  45016. * Add orientation input support to the input manager.
  45017. * @returns the current input manager
  45018. */
  45019. addDeviceOrientation(): FreeCameraInputsManager;
  45020. }
  45021. /**
  45022. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45023. * Screen rotation is taken into account.
  45024. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45025. */
  45026. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45027. private _camera;
  45028. private _screenOrientationAngle;
  45029. private _constantTranform;
  45030. private _screenQuaternion;
  45031. private _alpha;
  45032. private _beta;
  45033. private _gamma;
  45034. /**
  45035. * Can be used to detect if a device orientation sensor is available on a device
  45036. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45037. * @returns a promise that will resolve on orientation change
  45038. */
  45039. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45040. /**
  45041. * @hidden
  45042. */
  45043. _onDeviceOrientationChangedObservable: Observable<void>;
  45044. /**
  45045. * Instantiates a new input
  45046. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45047. */
  45048. constructor();
  45049. /**
  45050. * Define the camera controlled by the input.
  45051. */
  45052. get camera(): FreeCamera;
  45053. set camera(camera: FreeCamera);
  45054. /**
  45055. * Attach the input controls to a specific dom element to get the input from.
  45056. * @param element Defines the element the controls should be listened from
  45057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45058. */
  45059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45060. private _orientationChanged;
  45061. private _deviceOrientation;
  45062. /**
  45063. * Detach the current controls from the specified dom element.
  45064. * @param element Defines the element to stop listening the inputs from
  45065. */
  45066. detachControl(element: Nullable<HTMLElement>): void;
  45067. /**
  45068. * Update the current camera state depending on the inputs that have been used this frame.
  45069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45070. */
  45071. checkInputs(): void;
  45072. /**
  45073. * Gets the class name of the current intput.
  45074. * @returns the class name
  45075. */
  45076. getClassName(): string;
  45077. /**
  45078. * Get the friendly name associated with the input class.
  45079. * @returns the input friendly name
  45080. */
  45081. getSimpleName(): string;
  45082. }
  45083. }
  45084. declare module BABYLON {
  45085. /**
  45086. * Manage the gamepad inputs to control a free camera.
  45087. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45088. */
  45089. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45090. /**
  45091. * Define the camera the input is attached to.
  45092. */
  45093. camera: FreeCamera;
  45094. /**
  45095. * Define the Gamepad controlling the input
  45096. */
  45097. gamepad: Nullable<Gamepad>;
  45098. /**
  45099. * Defines the gamepad rotation sensiblity.
  45100. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45101. */
  45102. gamepadAngularSensibility: number;
  45103. /**
  45104. * Defines the gamepad move sensiblity.
  45105. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45106. */
  45107. gamepadMoveSensibility: number;
  45108. private _yAxisScale;
  45109. /**
  45110. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45111. */
  45112. get invertYAxis(): boolean;
  45113. set invertYAxis(value: boolean);
  45114. private _onGamepadConnectedObserver;
  45115. private _onGamepadDisconnectedObserver;
  45116. private _cameraTransform;
  45117. private _deltaTransform;
  45118. private _vector3;
  45119. private _vector2;
  45120. /**
  45121. * Attach the input controls to a specific dom element to get the input from.
  45122. * @param element Defines the element the controls should be listened from
  45123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45124. */
  45125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45126. /**
  45127. * Detach the current controls from the specified dom element.
  45128. * @param element Defines the element to stop listening the inputs from
  45129. */
  45130. detachControl(element: Nullable<HTMLElement>): void;
  45131. /**
  45132. * Update the current camera state depending on the inputs that have been used this frame.
  45133. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45134. */
  45135. checkInputs(): void;
  45136. /**
  45137. * Gets the class name of the current intput.
  45138. * @returns the class name
  45139. */
  45140. getClassName(): string;
  45141. /**
  45142. * Get the friendly name associated with the input class.
  45143. * @returns the input friendly name
  45144. */
  45145. getSimpleName(): string;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. /**
  45150. * Defines the potential axis of a Joystick
  45151. */
  45152. export enum JoystickAxis {
  45153. /** X axis */
  45154. X = 0,
  45155. /** Y axis */
  45156. Y = 1,
  45157. /** Z axis */
  45158. Z = 2
  45159. }
  45160. /**
  45161. * Represents the different customization options available
  45162. * for VirtualJoystick
  45163. */
  45164. interface VirtualJoystickCustomizations {
  45165. /**
  45166. * Size of the joystick's puck
  45167. */
  45168. puckSize: number;
  45169. /**
  45170. * Size of the joystick's container
  45171. */
  45172. containerSize: number;
  45173. /**
  45174. * Color of the joystick && puck
  45175. */
  45176. color: string;
  45177. /**
  45178. * Image URL for the joystick's puck
  45179. */
  45180. puckImage?: string;
  45181. /**
  45182. * Image URL for the joystick's container
  45183. */
  45184. containerImage?: string;
  45185. /**
  45186. * Defines the unmoving position of the joystick container
  45187. */
  45188. position?: {
  45189. x: number;
  45190. y: number;
  45191. };
  45192. /**
  45193. * Defines whether or not the joystick container is always visible
  45194. */
  45195. alwaysVisible: boolean;
  45196. /**
  45197. * Defines whether or not to limit the movement of the puck to the joystick's container
  45198. */
  45199. limitToContainer: boolean;
  45200. }
  45201. /**
  45202. * Class used to define virtual joystick (used in touch mode)
  45203. */
  45204. export class VirtualJoystick {
  45205. /**
  45206. * Gets or sets a boolean indicating that left and right values must be inverted
  45207. */
  45208. reverseLeftRight: boolean;
  45209. /**
  45210. * Gets or sets a boolean indicating that up and down values must be inverted
  45211. */
  45212. reverseUpDown: boolean;
  45213. /**
  45214. * Gets the offset value for the position (ie. the change of the position value)
  45215. */
  45216. deltaPosition: Vector3;
  45217. /**
  45218. * Gets a boolean indicating if the virtual joystick was pressed
  45219. */
  45220. pressed: boolean;
  45221. /**
  45222. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45223. */
  45224. static Canvas: Nullable<HTMLCanvasElement>;
  45225. /**
  45226. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45227. */
  45228. limitToContainer: boolean;
  45229. private static _globalJoystickIndex;
  45230. private static _alwaysVisibleSticks;
  45231. private static vjCanvasContext;
  45232. private static vjCanvasWidth;
  45233. private static vjCanvasHeight;
  45234. private static halfWidth;
  45235. private static _GetDefaultOptions;
  45236. private _action;
  45237. private _axisTargetedByLeftAndRight;
  45238. private _axisTargetedByUpAndDown;
  45239. private _joystickSensibility;
  45240. private _inversedSensibility;
  45241. private _joystickPointerID;
  45242. private _joystickColor;
  45243. private _joystickPointerPos;
  45244. private _joystickPreviousPointerPos;
  45245. private _joystickPointerStartPos;
  45246. private _deltaJoystickVector;
  45247. private _leftJoystick;
  45248. private _touches;
  45249. private _joystickPosition;
  45250. private _alwaysVisible;
  45251. private _puckImage;
  45252. private _containerImage;
  45253. private _joystickPuckSize;
  45254. private _joystickContainerSize;
  45255. private _clearPuckSize;
  45256. private _clearContainerSize;
  45257. private _clearPuckSizeOffset;
  45258. private _clearContainerSizeOffset;
  45259. private _onPointerDownHandlerRef;
  45260. private _onPointerMoveHandlerRef;
  45261. private _onPointerUpHandlerRef;
  45262. private _onResize;
  45263. /**
  45264. * Creates a new virtual joystick
  45265. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45266. * @param customizations Defines the options we want to customize the VirtualJoystick
  45267. */
  45268. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45269. /**
  45270. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45271. * @param newJoystickSensibility defines the new sensibility
  45272. */
  45273. setJoystickSensibility(newJoystickSensibility: number): void;
  45274. private _onPointerDown;
  45275. private _onPointerMove;
  45276. private _onPointerUp;
  45277. /**
  45278. * Change the color of the virtual joystick
  45279. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45280. */
  45281. setJoystickColor(newColor: string): void;
  45282. /**
  45283. * Size of the joystick's container
  45284. */
  45285. set containerSize(newSize: number);
  45286. get containerSize(): number;
  45287. /**
  45288. * Size of the joystick's puck
  45289. */
  45290. set puckSize(newSize: number);
  45291. get puckSize(): number;
  45292. /**
  45293. * Clears the set position of the joystick
  45294. */
  45295. clearPosition(): void;
  45296. /**
  45297. * Defines whether or not the joystick container is always visible
  45298. */
  45299. set alwaysVisible(value: boolean);
  45300. get alwaysVisible(): boolean;
  45301. /**
  45302. * Sets the constant position of the Joystick container
  45303. * @param x X axis coordinate
  45304. * @param y Y axis coordinate
  45305. */
  45306. setPosition(x: number, y: number): void;
  45307. /**
  45308. * Defines a callback to call when the joystick is touched
  45309. * @param action defines the callback
  45310. */
  45311. setActionOnTouch(action: () => any): void;
  45312. /**
  45313. * Defines which axis you'd like to control for left & right
  45314. * @param axis defines the axis to use
  45315. */
  45316. setAxisForLeftRight(axis: JoystickAxis): void;
  45317. /**
  45318. * Defines which axis you'd like to control for up & down
  45319. * @param axis defines the axis to use
  45320. */
  45321. setAxisForUpDown(axis: JoystickAxis): void;
  45322. /**
  45323. * Clears the canvas from the previous puck / container draw
  45324. */
  45325. private _clearPreviousDraw;
  45326. /**
  45327. * Loads `urlPath` to be used for the container's image
  45328. * @param urlPath defines the urlPath of an image to use
  45329. */
  45330. setContainerImage(urlPath: string): void;
  45331. /**
  45332. * Loads `urlPath` to be used for the puck's image
  45333. * @param urlPath defines the urlPath of an image to use
  45334. */
  45335. setPuckImage(urlPath: string): void;
  45336. /**
  45337. * Draws the Virtual Joystick's container
  45338. */
  45339. private _drawContainer;
  45340. /**
  45341. * Draws the Virtual Joystick's puck
  45342. */
  45343. private _drawPuck;
  45344. private _drawVirtualJoystick;
  45345. /**
  45346. * Release internal HTML canvas
  45347. */
  45348. releaseCanvas(): void;
  45349. }
  45350. }
  45351. declare module BABYLON {
  45352. interface FreeCameraInputsManager {
  45353. /**
  45354. * Add virtual joystick input support to the input manager.
  45355. * @returns the current input manager
  45356. */
  45357. addVirtualJoystick(): FreeCameraInputsManager;
  45358. }
  45359. /**
  45360. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45361. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45362. */
  45363. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45364. /**
  45365. * Defines the camera the input is attached to.
  45366. */
  45367. camera: FreeCamera;
  45368. private _leftjoystick;
  45369. private _rightjoystick;
  45370. /**
  45371. * Gets the left stick of the virtual joystick.
  45372. * @returns The virtual Joystick
  45373. */
  45374. getLeftJoystick(): VirtualJoystick;
  45375. /**
  45376. * Gets the right stick of the virtual joystick.
  45377. * @returns The virtual Joystick
  45378. */
  45379. getRightJoystick(): VirtualJoystick;
  45380. /**
  45381. * Update the current camera state depending on the inputs that have been used this frame.
  45382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45383. */
  45384. checkInputs(): void;
  45385. /**
  45386. * Attach the input controls to a specific dom element to get the input from.
  45387. * @param element Defines the element the controls should be listened from
  45388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45389. */
  45390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45391. /**
  45392. * Detach the current controls from the specified dom element.
  45393. * @param element Defines the element to stop listening the inputs from
  45394. */
  45395. detachControl(element: Nullable<HTMLElement>): void;
  45396. /**
  45397. * Gets the class name of the current intput.
  45398. * @returns the class name
  45399. */
  45400. getClassName(): string;
  45401. /**
  45402. * Get the friendly name associated with the input class.
  45403. * @returns the input friendly name
  45404. */
  45405. getSimpleName(): string;
  45406. }
  45407. }
  45408. declare module BABYLON {
  45409. /**
  45410. * This represents a FPS type of camera controlled by touch.
  45411. * This is like a universal camera minus the Gamepad controls.
  45412. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45413. */
  45414. export class TouchCamera extends FreeCamera {
  45415. /**
  45416. * Defines the touch sensibility for rotation.
  45417. * The higher the faster.
  45418. */
  45419. get touchAngularSensibility(): number;
  45420. set touchAngularSensibility(value: number);
  45421. /**
  45422. * Defines the touch sensibility for move.
  45423. * The higher the faster.
  45424. */
  45425. get touchMoveSensibility(): number;
  45426. set touchMoveSensibility(value: number);
  45427. /**
  45428. * Instantiates a new touch camera.
  45429. * This represents a FPS type of camera controlled by touch.
  45430. * This is like a universal camera minus the Gamepad controls.
  45431. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45432. * @param name Define the name of the camera in the scene
  45433. * @param position Define the start position of the camera in the scene
  45434. * @param scene Define the scene the camera belongs to
  45435. */
  45436. constructor(name: string, position: Vector3, scene: Scene);
  45437. /**
  45438. * Gets the current object class name.
  45439. * @return the class name
  45440. */
  45441. getClassName(): string;
  45442. /** @hidden */
  45443. _setupInputs(): void;
  45444. }
  45445. }
  45446. declare module BABYLON {
  45447. /**
  45448. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45449. * being tilted forward or back and left or right.
  45450. */
  45451. export class DeviceOrientationCamera extends FreeCamera {
  45452. private _initialQuaternion;
  45453. private _quaternionCache;
  45454. private _tmpDragQuaternion;
  45455. private _disablePointerInputWhenUsingDeviceOrientation;
  45456. /**
  45457. * Creates a new device orientation camera
  45458. * @param name The name of the camera
  45459. * @param position The start position camera
  45460. * @param scene The scene the camera belongs to
  45461. */
  45462. constructor(name: string, position: Vector3, scene: Scene);
  45463. /**
  45464. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45465. */
  45466. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45467. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45468. private _dragFactor;
  45469. /**
  45470. * Enabled turning on the y axis when the orientation sensor is active
  45471. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45472. */
  45473. enableHorizontalDragging(dragFactor?: number): void;
  45474. /**
  45475. * Gets the current instance class name ("DeviceOrientationCamera").
  45476. * This helps avoiding instanceof at run time.
  45477. * @returns the class name
  45478. */
  45479. getClassName(): string;
  45480. /**
  45481. * @hidden
  45482. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45483. */
  45484. _checkInputs(): void;
  45485. /**
  45486. * Reset the camera to its default orientation on the specified axis only.
  45487. * @param axis The axis to reset
  45488. */
  45489. resetToCurrentRotation(axis?: Axis): void;
  45490. }
  45491. }
  45492. declare module BABYLON {
  45493. /**
  45494. * Defines supported buttons for XBox360 compatible gamepads
  45495. */
  45496. export enum Xbox360Button {
  45497. /** A */
  45498. A = 0,
  45499. /** B */
  45500. B = 1,
  45501. /** X */
  45502. X = 2,
  45503. /** Y */
  45504. Y = 3,
  45505. /** Left button */
  45506. LB = 4,
  45507. /** Right button */
  45508. RB = 5,
  45509. /** Back */
  45510. Back = 8,
  45511. /** Start */
  45512. Start = 9,
  45513. /** Left stick */
  45514. LeftStick = 10,
  45515. /** Right stick */
  45516. RightStick = 11
  45517. }
  45518. /** Defines values for XBox360 DPad */
  45519. export enum Xbox360Dpad {
  45520. /** Up */
  45521. Up = 12,
  45522. /** Down */
  45523. Down = 13,
  45524. /** Left */
  45525. Left = 14,
  45526. /** Right */
  45527. Right = 15
  45528. }
  45529. /**
  45530. * Defines a XBox360 gamepad
  45531. */
  45532. export class Xbox360Pad extends Gamepad {
  45533. private _leftTrigger;
  45534. private _rightTrigger;
  45535. private _onlefttriggerchanged;
  45536. private _onrighttriggerchanged;
  45537. private _onbuttondown;
  45538. private _onbuttonup;
  45539. private _ondpaddown;
  45540. private _ondpadup;
  45541. /** Observable raised when a button is pressed */
  45542. onButtonDownObservable: Observable<Xbox360Button>;
  45543. /** Observable raised when a button is released */
  45544. onButtonUpObservable: Observable<Xbox360Button>;
  45545. /** Observable raised when a pad is pressed */
  45546. onPadDownObservable: Observable<Xbox360Dpad>;
  45547. /** Observable raised when a pad is released */
  45548. onPadUpObservable: Observable<Xbox360Dpad>;
  45549. private _buttonA;
  45550. private _buttonB;
  45551. private _buttonX;
  45552. private _buttonY;
  45553. private _buttonBack;
  45554. private _buttonStart;
  45555. private _buttonLB;
  45556. private _buttonRB;
  45557. private _buttonLeftStick;
  45558. private _buttonRightStick;
  45559. private _dPadUp;
  45560. private _dPadDown;
  45561. private _dPadLeft;
  45562. private _dPadRight;
  45563. private _isXboxOnePad;
  45564. /**
  45565. * Creates a new XBox360 gamepad object
  45566. * @param id defines the id of this gamepad
  45567. * @param index defines its index
  45568. * @param gamepad defines the internal HTML gamepad object
  45569. * @param xboxOne defines if it is a XBox One gamepad
  45570. */
  45571. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45572. /**
  45573. * Defines the callback to call when left trigger is pressed
  45574. * @param callback defines the callback to use
  45575. */
  45576. onlefttriggerchanged(callback: (value: number) => void): void;
  45577. /**
  45578. * Defines the callback to call when right trigger is pressed
  45579. * @param callback defines the callback to use
  45580. */
  45581. onrighttriggerchanged(callback: (value: number) => void): void;
  45582. /**
  45583. * Gets the left trigger value
  45584. */
  45585. get leftTrigger(): number;
  45586. /**
  45587. * Sets the left trigger value
  45588. */
  45589. set leftTrigger(newValue: number);
  45590. /**
  45591. * Gets the right trigger value
  45592. */
  45593. get rightTrigger(): number;
  45594. /**
  45595. * Sets the right trigger value
  45596. */
  45597. set rightTrigger(newValue: number);
  45598. /**
  45599. * Defines the callback to call when a button is pressed
  45600. * @param callback defines the callback to use
  45601. */
  45602. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45603. /**
  45604. * Defines the callback to call when a button is released
  45605. * @param callback defines the callback to use
  45606. */
  45607. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45608. /**
  45609. * Defines the callback to call when a pad is pressed
  45610. * @param callback defines the callback to use
  45611. */
  45612. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45613. /**
  45614. * Defines the callback to call when a pad is released
  45615. * @param callback defines the callback to use
  45616. */
  45617. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45618. private _setButtonValue;
  45619. private _setDPadValue;
  45620. /**
  45621. * Gets the value of the `A` button
  45622. */
  45623. get buttonA(): number;
  45624. /**
  45625. * Sets the value of the `A` button
  45626. */
  45627. set buttonA(value: number);
  45628. /**
  45629. * Gets the value of the `B` button
  45630. */
  45631. get buttonB(): number;
  45632. /**
  45633. * Sets the value of the `B` button
  45634. */
  45635. set buttonB(value: number);
  45636. /**
  45637. * Gets the value of the `X` button
  45638. */
  45639. get buttonX(): number;
  45640. /**
  45641. * Sets the value of the `X` button
  45642. */
  45643. set buttonX(value: number);
  45644. /**
  45645. * Gets the value of the `Y` button
  45646. */
  45647. get buttonY(): number;
  45648. /**
  45649. * Sets the value of the `Y` button
  45650. */
  45651. set buttonY(value: number);
  45652. /**
  45653. * Gets the value of the `Start` button
  45654. */
  45655. get buttonStart(): number;
  45656. /**
  45657. * Sets the value of the `Start` button
  45658. */
  45659. set buttonStart(value: number);
  45660. /**
  45661. * Gets the value of the `Back` button
  45662. */
  45663. get buttonBack(): number;
  45664. /**
  45665. * Sets the value of the `Back` button
  45666. */
  45667. set buttonBack(value: number);
  45668. /**
  45669. * Gets the value of the `Left` button
  45670. */
  45671. get buttonLB(): number;
  45672. /**
  45673. * Sets the value of the `Left` button
  45674. */
  45675. set buttonLB(value: number);
  45676. /**
  45677. * Gets the value of the `Right` button
  45678. */
  45679. get buttonRB(): number;
  45680. /**
  45681. * Sets the value of the `Right` button
  45682. */
  45683. set buttonRB(value: number);
  45684. /**
  45685. * Gets the value of the Left joystick
  45686. */
  45687. get buttonLeftStick(): number;
  45688. /**
  45689. * Sets the value of the Left joystick
  45690. */
  45691. set buttonLeftStick(value: number);
  45692. /**
  45693. * Gets the value of the Right joystick
  45694. */
  45695. get buttonRightStick(): number;
  45696. /**
  45697. * Sets the value of the Right joystick
  45698. */
  45699. set buttonRightStick(value: number);
  45700. /**
  45701. * Gets the value of D-pad up
  45702. */
  45703. get dPadUp(): number;
  45704. /**
  45705. * Sets the value of D-pad up
  45706. */
  45707. set dPadUp(value: number);
  45708. /**
  45709. * Gets the value of D-pad down
  45710. */
  45711. get dPadDown(): number;
  45712. /**
  45713. * Sets the value of D-pad down
  45714. */
  45715. set dPadDown(value: number);
  45716. /**
  45717. * Gets the value of D-pad left
  45718. */
  45719. get dPadLeft(): number;
  45720. /**
  45721. * Sets the value of D-pad left
  45722. */
  45723. set dPadLeft(value: number);
  45724. /**
  45725. * Gets the value of D-pad right
  45726. */
  45727. get dPadRight(): number;
  45728. /**
  45729. * Sets the value of D-pad right
  45730. */
  45731. set dPadRight(value: number);
  45732. /**
  45733. * Force the gamepad to synchronize with device values
  45734. */
  45735. update(): void;
  45736. /**
  45737. * Disposes the gamepad
  45738. */
  45739. dispose(): void;
  45740. }
  45741. }
  45742. declare module BABYLON {
  45743. /**
  45744. * Defines supported buttons for DualShock compatible gamepads
  45745. */
  45746. export enum DualShockButton {
  45747. /** Cross */
  45748. Cross = 0,
  45749. /** Circle */
  45750. Circle = 1,
  45751. /** Square */
  45752. Square = 2,
  45753. /** Triangle */
  45754. Triangle = 3,
  45755. /** L1 */
  45756. L1 = 4,
  45757. /** R1 */
  45758. R1 = 5,
  45759. /** Share */
  45760. Share = 8,
  45761. /** Options */
  45762. Options = 9,
  45763. /** Left stick */
  45764. LeftStick = 10,
  45765. /** Right stick */
  45766. RightStick = 11
  45767. }
  45768. /** Defines values for DualShock DPad */
  45769. export enum DualShockDpad {
  45770. /** Up */
  45771. Up = 12,
  45772. /** Down */
  45773. Down = 13,
  45774. /** Left */
  45775. Left = 14,
  45776. /** Right */
  45777. Right = 15
  45778. }
  45779. /**
  45780. * Defines a DualShock gamepad
  45781. */
  45782. export class DualShockPad extends Gamepad {
  45783. private _leftTrigger;
  45784. private _rightTrigger;
  45785. private _onlefttriggerchanged;
  45786. private _onrighttriggerchanged;
  45787. private _onbuttondown;
  45788. private _onbuttonup;
  45789. private _ondpaddown;
  45790. private _ondpadup;
  45791. /** Observable raised when a button is pressed */
  45792. onButtonDownObservable: Observable<DualShockButton>;
  45793. /** Observable raised when a button is released */
  45794. onButtonUpObservable: Observable<DualShockButton>;
  45795. /** Observable raised when a pad is pressed */
  45796. onPadDownObservable: Observable<DualShockDpad>;
  45797. /** Observable raised when a pad is released */
  45798. onPadUpObservable: Observable<DualShockDpad>;
  45799. private _buttonCross;
  45800. private _buttonCircle;
  45801. private _buttonSquare;
  45802. private _buttonTriangle;
  45803. private _buttonShare;
  45804. private _buttonOptions;
  45805. private _buttonL1;
  45806. private _buttonR1;
  45807. private _buttonLeftStick;
  45808. private _buttonRightStick;
  45809. private _dPadUp;
  45810. private _dPadDown;
  45811. private _dPadLeft;
  45812. private _dPadRight;
  45813. /**
  45814. * Creates a new DualShock gamepad object
  45815. * @param id defines the id of this gamepad
  45816. * @param index defines its index
  45817. * @param gamepad defines the internal HTML gamepad object
  45818. */
  45819. constructor(id: string, index: number, gamepad: any);
  45820. /**
  45821. * Defines the callback to call when left trigger is pressed
  45822. * @param callback defines the callback to use
  45823. */
  45824. onlefttriggerchanged(callback: (value: number) => void): void;
  45825. /**
  45826. * Defines the callback to call when right trigger is pressed
  45827. * @param callback defines the callback to use
  45828. */
  45829. onrighttriggerchanged(callback: (value: number) => void): void;
  45830. /**
  45831. * Gets the left trigger value
  45832. */
  45833. get leftTrigger(): number;
  45834. /**
  45835. * Sets the left trigger value
  45836. */
  45837. set leftTrigger(newValue: number);
  45838. /**
  45839. * Gets the right trigger value
  45840. */
  45841. get rightTrigger(): number;
  45842. /**
  45843. * Sets the right trigger value
  45844. */
  45845. set rightTrigger(newValue: number);
  45846. /**
  45847. * Defines the callback to call when a button is pressed
  45848. * @param callback defines the callback to use
  45849. */
  45850. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45851. /**
  45852. * Defines the callback to call when a button is released
  45853. * @param callback defines the callback to use
  45854. */
  45855. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45856. /**
  45857. * Defines the callback to call when a pad is pressed
  45858. * @param callback defines the callback to use
  45859. */
  45860. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45861. /**
  45862. * Defines the callback to call when a pad is released
  45863. * @param callback defines the callback to use
  45864. */
  45865. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45866. private _setButtonValue;
  45867. private _setDPadValue;
  45868. /**
  45869. * Gets the value of the `Cross` button
  45870. */
  45871. get buttonCross(): number;
  45872. /**
  45873. * Sets the value of the `Cross` button
  45874. */
  45875. set buttonCross(value: number);
  45876. /**
  45877. * Gets the value of the `Circle` button
  45878. */
  45879. get buttonCircle(): number;
  45880. /**
  45881. * Sets the value of the `Circle` button
  45882. */
  45883. set buttonCircle(value: number);
  45884. /**
  45885. * Gets the value of the `Square` button
  45886. */
  45887. get buttonSquare(): number;
  45888. /**
  45889. * Sets the value of the `Square` button
  45890. */
  45891. set buttonSquare(value: number);
  45892. /**
  45893. * Gets the value of the `Triangle` button
  45894. */
  45895. get buttonTriangle(): number;
  45896. /**
  45897. * Sets the value of the `Triangle` button
  45898. */
  45899. set buttonTriangle(value: number);
  45900. /**
  45901. * Gets the value of the `Options` button
  45902. */
  45903. get buttonOptions(): number;
  45904. /**
  45905. * Sets the value of the `Options` button
  45906. */
  45907. set buttonOptions(value: number);
  45908. /**
  45909. * Gets the value of the `Share` button
  45910. */
  45911. get buttonShare(): number;
  45912. /**
  45913. * Sets the value of the `Share` button
  45914. */
  45915. set buttonShare(value: number);
  45916. /**
  45917. * Gets the value of the `L1` button
  45918. */
  45919. get buttonL1(): number;
  45920. /**
  45921. * Sets the value of the `L1` button
  45922. */
  45923. set buttonL1(value: number);
  45924. /**
  45925. * Gets the value of the `R1` button
  45926. */
  45927. get buttonR1(): number;
  45928. /**
  45929. * Sets the value of the `R1` button
  45930. */
  45931. set buttonR1(value: number);
  45932. /**
  45933. * Gets the value of the Left joystick
  45934. */
  45935. get buttonLeftStick(): number;
  45936. /**
  45937. * Sets the value of the Left joystick
  45938. */
  45939. set buttonLeftStick(value: number);
  45940. /**
  45941. * Gets the value of the Right joystick
  45942. */
  45943. get buttonRightStick(): number;
  45944. /**
  45945. * Sets the value of the Right joystick
  45946. */
  45947. set buttonRightStick(value: number);
  45948. /**
  45949. * Gets the value of D-pad up
  45950. */
  45951. get dPadUp(): number;
  45952. /**
  45953. * Sets the value of D-pad up
  45954. */
  45955. set dPadUp(value: number);
  45956. /**
  45957. * Gets the value of D-pad down
  45958. */
  45959. get dPadDown(): number;
  45960. /**
  45961. * Sets the value of D-pad down
  45962. */
  45963. set dPadDown(value: number);
  45964. /**
  45965. * Gets the value of D-pad left
  45966. */
  45967. get dPadLeft(): number;
  45968. /**
  45969. * Sets the value of D-pad left
  45970. */
  45971. set dPadLeft(value: number);
  45972. /**
  45973. * Gets the value of D-pad right
  45974. */
  45975. get dPadRight(): number;
  45976. /**
  45977. * Sets the value of D-pad right
  45978. */
  45979. set dPadRight(value: number);
  45980. /**
  45981. * Force the gamepad to synchronize with device values
  45982. */
  45983. update(): void;
  45984. /**
  45985. * Disposes the gamepad
  45986. */
  45987. dispose(): void;
  45988. }
  45989. }
  45990. declare module BABYLON {
  45991. /**
  45992. * Manager for handling gamepads
  45993. */
  45994. export class GamepadManager {
  45995. private _scene?;
  45996. private _babylonGamepads;
  45997. private _oneGamepadConnected;
  45998. /** @hidden */
  45999. _isMonitoring: boolean;
  46000. private _gamepadEventSupported;
  46001. private _gamepadSupport?;
  46002. /**
  46003. * observable to be triggered when the gamepad controller has been connected
  46004. */
  46005. onGamepadConnectedObservable: Observable<Gamepad>;
  46006. /**
  46007. * observable to be triggered when the gamepad controller has been disconnected
  46008. */
  46009. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46010. private _onGamepadConnectedEvent;
  46011. private _onGamepadDisconnectedEvent;
  46012. /**
  46013. * Initializes the gamepad manager
  46014. * @param _scene BabylonJS scene
  46015. */
  46016. constructor(_scene?: Scene | undefined);
  46017. /**
  46018. * The gamepads in the game pad manager
  46019. */
  46020. get gamepads(): Gamepad[];
  46021. /**
  46022. * Get the gamepad controllers based on type
  46023. * @param type The type of gamepad controller
  46024. * @returns Nullable gamepad
  46025. */
  46026. getGamepadByType(type?: number): Nullable<Gamepad>;
  46027. /**
  46028. * Disposes the gamepad manager
  46029. */
  46030. dispose(): void;
  46031. private _addNewGamepad;
  46032. private _startMonitoringGamepads;
  46033. private _stopMonitoringGamepads;
  46034. /** @hidden */
  46035. _checkGamepadsStatus(): void;
  46036. private _updateGamepadObjects;
  46037. }
  46038. }
  46039. declare module BABYLON {
  46040. interface Scene {
  46041. /** @hidden */
  46042. _gamepadManager: Nullable<GamepadManager>;
  46043. /**
  46044. * Gets the gamepad manager associated with the scene
  46045. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46046. */
  46047. gamepadManager: GamepadManager;
  46048. }
  46049. /**
  46050. * Interface representing a free camera inputs manager
  46051. */
  46052. interface FreeCameraInputsManager {
  46053. /**
  46054. * Adds gamepad input support to the FreeCameraInputsManager.
  46055. * @returns the FreeCameraInputsManager
  46056. */
  46057. addGamepad(): FreeCameraInputsManager;
  46058. }
  46059. /**
  46060. * Interface representing an arc rotate camera inputs manager
  46061. */
  46062. interface ArcRotateCameraInputsManager {
  46063. /**
  46064. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46065. * @returns the camera inputs manager
  46066. */
  46067. addGamepad(): ArcRotateCameraInputsManager;
  46068. }
  46069. /**
  46070. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46071. */
  46072. export class GamepadSystemSceneComponent implements ISceneComponent {
  46073. /**
  46074. * The component name helpfull to identify the component in the list of scene components.
  46075. */
  46076. readonly name: string;
  46077. /**
  46078. * The scene the component belongs to.
  46079. */
  46080. scene: Scene;
  46081. /**
  46082. * Creates a new instance of the component for the given scene
  46083. * @param scene Defines the scene to register the component in
  46084. */
  46085. constructor(scene: Scene);
  46086. /**
  46087. * Registers the component in a given scene
  46088. */
  46089. register(): void;
  46090. /**
  46091. * Rebuilds the elements related to this component in case of
  46092. * context lost for instance.
  46093. */
  46094. rebuild(): void;
  46095. /**
  46096. * Disposes the component and the associated ressources
  46097. */
  46098. dispose(): void;
  46099. private _beforeCameraUpdate;
  46100. }
  46101. }
  46102. declare module BABYLON {
  46103. /**
  46104. * 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,
  46105. * which still works and will still be found in many Playgrounds.
  46106. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46107. */
  46108. export class UniversalCamera extends TouchCamera {
  46109. /**
  46110. * Defines the gamepad rotation sensiblity.
  46111. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46112. */
  46113. get gamepadAngularSensibility(): number;
  46114. set gamepadAngularSensibility(value: number);
  46115. /**
  46116. * Defines the gamepad move sensiblity.
  46117. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46118. */
  46119. get gamepadMoveSensibility(): number;
  46120. set gamepadMoveSensibility(value: number);
  46121. /**
  46122. * 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,
  46123. * which still works and will still be found in many Playgrounds.
  46124. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46125. * @param name Define the name of the camera in the scene
  46126. * @param position Define the start position of the camera in the scene
  46127. * @param scene Define the scene the camera belongs to
  46128. */
  46129. constructor(name: string, position: Vector3, scene: Scene);
  46130. /**
  46131. * Gets the current object class name.
  46132. * @return the class name
  46133. */
  46134. getClassName(): string;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. /**
  46139. * This represents a FPS type of camera. This is only here for back compat purpose.
  46140. * Please use the UniversalCamera instead as both are identical.
  46141. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46142. */
  46143. export class GamepadCamera extends UniversalCamera {
  46144. /**
  46145. * Instantiates a new Gamepad Camera
  46146. * This represents a FPS type of camera. This is only here for back compat purpose.
  46147. * Please use the UniversalCamera instead as both are identical.
  46148. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46149. * @param name Define the name of the camera in the scene
  46150. * @param position Define the start position of the camera in the scene
  46151. * @param scene Define the scene the camera belongs to
  46152. */
  46153. constructor(name: string, position: Vector3, scene: Scene);
  46154. /**
  46155. * Gets the current object class name.
  46156. * @return the class name
  46157. */
  46158. getClassName(): string;
  46159. }
  46160. }
  46161. declare module BABYLON {
  46162. /** @hidden */
  46163. export var passPixelShader: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module BABYLON {
  46169. /** @hidden */
  46170. export var passCubePixelShader: {
  46171. name: string;
  46172. shader: string;
  46173. };
  46174. }
  46175. declare module BABYLON {
  46176. /**
  46177. * PassPostProcess which produces an output the same as it's input
  46178. */
  46179. export class PassPostProcess extends PostProcess {
  46180. /**
  46181. * Gets a string identifying the name of the class
  46182. * @returns "PassPostProcess" string
  46183. */
  46184. getClassName(): string;
  46185. /**
  46186. * Creates the PassPostProcess
  46187. * @param name The name of the effect.
  46188. * @param options The required width/height ratio to downsize to before computing the render pass.
  46189. * @param camera The camera to apply the render pass to.
  46190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46191. * @param engine The engine which the post process will be applied. (default: current engine)
  46192. * @param reusable If the post process can be reused on the same frame. (default: false)
  46193. * @param textureType The type of texture to be used when performing the post processing.
  46194. * @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)
  46195. */
  46196. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46197. /** @hidden */
  46198. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46199. }
  46200. /**
  46201. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46202. */
  46203. export class PassCubePostProcess extends PostProcess {
  46204. private _face;
  46205. /**
  46206. * Gets or sets the cube face to display.
  46207. * * 0 is +X
  46208. * * 1 is -X
  46209. * * 2 is +Y
  46210. * * 3 is -Y
  46211. * * 4 is +Z
  46212. * * 5 is -Z
  46213. */
  46214. get face(): number;
  46215. set face(value: number);
  46216. /**
  46217. * Gets a string identifying the name of the class
  46218. * @returns "PassCubePostProcess" string
  46219. */
  46220. getClassName(): string;
  46221. /**
  46222. * Creates the PassCubePostProcess
  46223. * @param name The name of the effect.
  46224. * @param options The required width/height ratio to downsize to before computing the render pass.
  46225. * @param camera The camera to apply the render pass to.
  46226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46227. * @param engine The engine which the post process will be applied. (default: current engine)
  46228. * @param reusable If the post process can be reused on the same frame. (default: false)
  46229. * @param textureType The type of texture to be used when performing the post processing.
  46230. * @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)
  46231. */
  46232. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46233. /** @hidden */
  46234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46235. }
  46236. }
  46237. declare module BABYLON {
  46238. /** @hidden */
  46239. export var anaglyphPixelShader: {
  46240. name: string;
  46241. shader: string;
  46242. };
  46243. }
  46244. declare module BABYLON {
  46245. /**
  46246. * Postprocess used to generate anaglyphic rendering
  46247. */
  46248. export class AnaglyphPostProcess extends PostProcess {
  46249. private _passedProcess;
  46250. /**
  46251. * Gets a string identifying the name of the class
  46252. * @returns "AnaglyphPostProcess" string
  46253. */
  46254. getClassName(): string;
  46255. /**
  46256. * Creates a new AnaglyphPostProcess
  46257. * @param name defines postprocess name
  46258. * @param options defines creation options or target ratio scale
  46259. * @param rigCameras defines cameras using this postprocess
  46260. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46261. * @param engine defines hosting engine
  46262. * @param reusable defines if the postprocess will be reused multiple times per frame
  46263. */
  46264. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /**
  46269. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46270. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46271. */
  46272. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46273. /**
  46274. * Creates a new AnaglyphArcRotateCamera
  46275. * @param name defines camera name
  46276. * @param alpha defines alpha angle (in radians)
  46277. * @param beta defines beta angle (in radians)
  46278. * @param radius defines radius
  46279. * @param target defines camera target
  46280. * @param interaxialDistance defines distance between each color axis
  46281. * @param scene defines the hosting scene
  46282. */
  46283. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46284. /**
  46285. * Gets camera class name
  46286. * @returns AnaglyphArcRotateCamera
  46287. */
  46288. getClassName(): string;
  46289. }
  46290. }
  46291. declare module BABYLON {
  46292. /**
  46293. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46294. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46295. */
  46296. export class AnaglyphFreeCamera extends FreeCamera {
  46297. /**
  46298. * Creates a new AnaglyphFreeCamera
  46299. * @param name defines camera name
  46300. * @param position defines initial position
  46301. * @param interaxialDistance defines distance between each color axis
  46302. * @param scene defines the hosting scene
  46303. */
  46304. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46305. /**
  46306. * Gets camera class name
  46307. * @returns AnaglyphFreeCamera
  46308. */
  46309. getClassName(): string;
  46310. }
  46311. }
  46312. declare module BABYLON {
  46313. /**
  46314. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46315. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46316. */
  46317. export class AnaglyphGamepadCamera extends GamepadCamera {
  46318. /**
  46319. * Creates a new AnaglyphGamepadCamera
  46320. * @param name defines camera name
  46321. * @param position defines initial position
  46322. * @param interaxialDistance defines distance between each color axis
  46323. * @param scene defines the hosting scene
  46324. */
  46325. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46326. /**
  46327. * Gets camera class name
  46328. * @returns AnaglyphGamepadCamera
  46329. */
  46330. getClassName(): string;
  46331. }
  46332. }
  46333. declare module BABYLON {
  46334. /**
  46335. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46336. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46337. */
  46338. export class AnaglyphUniversalCamera extends UniversalCamera {
  46339. /**
  46340. * Creates a new AnaglyphUniversalCamera
  46341. * @param name defines camera name
  46342. * @param position defines initial position
  46343. * @param interaxialDistance defines distance between each color axis
  46344. * @param scene defines the hosting scene
  46345. */
  46346. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46347. /**
  46348. * Gets camera class name
  46349. * @returns AnaglyphUniversalCamera
  46350. */
  46351. getClassName(): string;
  46352. }
  46353. }
  46354. declare module BABYLON {
  46355. /**
  46356. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46357. * @see https://doc.babylonjs.com/features/cameras
  46358. */
  46359. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46360. /**
  46361. * Creates a new StereoscopicArcRotateCamera
  46362. * @param name defines camera name
  46363. * @param alpha defines alpha angle (in radians)
  46364. * @param beta defines beta angle (in radians)
  46365. * @param radius defines radius
  46366. * @param target defines camera target
  46367. * @param interaxialDistance defines distance between each color axis
  46368. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46369. * @param scene defines the hosting scene
  46370. */
  46371. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46372. /**
  46373. * Gets camera class name
  46374. * @returns StereoscopicArcRotateCamera
  46375. */
  46376. getClassName(): string;
  46377. }
  46378. }
  46379. declare module BABYLON {
  46380. /**
  46381. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46382. * @see https://doc.babylonjs.com/features/cameras
  46383. */
  46384. export class StereoscopicFreeCamera extends FreeCamera {
  46385. /**
  46386. * Creates a new StereoscopicFreeCamera
  46387. * @param name defines camera name
  46388. * @param position defines initial position
  46389. * @param interaxialDistance defines distance between each color axis
  46390. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46391. * @param scene defines the hosting scene
  46392. */
  46393. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46394. /**
  46395. * Gets camera class name
  46396. * @returns StereoscopicFreeCamera
  46397. */
  46398. getClassName(): string;
  46399. }
  46400. }
  46401. declare module BABYLON {
  46402. /**
  46403. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46404. * @see https://doc.babylonjs.com/features/cameras
  46405. */
  46406. export class StereoscopicGamepadCamera extends GamepadCamera {
  46407. /**
  46408. * Creates a new StereoscopicGamepadCamera
  46409. * @param name defines camera name
  46410. * @param position defines initial position
  46411. * @param interaxialDistance defines distance between each color axis
  46412. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46413. * @param scene defines the hosting scene
  46414. */
  46415. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46416. /**
  46417. * Gets camera class name
  46418. * @returns StereoscopicGamepadCamera
  46419. */
  46420. getClassName(): string;
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46426. * @see https://doc.babylonjs.com/features/cameras
  46427. */
  46428. export class StereoscopicUniversalCamera extends UniversalCamera {
  46429. /**
  46430. * Creates a new StereoscopicUniversalCamera
  46431. * @param name defines camera name
  46432. * @param position defines initial position
  46433. * @param interaxialDistance defines distance between each color axis
  46434. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46435. * @param scene defines the hosting scene
  46436. */
  46437. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46438. /**
  46439. * Gets camera class name
  46440. * @returns StereoscopicUniversalCamera
  46441. */
  46442. getClassName(): string;
  46443. }
  46444. }
  46445. declare module BABYLON {
  46446. /**
  46447. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46448. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46449. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46450. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46451. */
  46452. export class VirtualJoysticksCamera extends FreeCamera {
  46453. /**
  46454. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46455. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46456. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46457. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46458. * @param name Define the name of the camera in the scene
  46459. * @param position Define the start position of the camera in the scene
  46460. * @param scene Define the scene the camera belongs to
  46461. */
  46462. constructor(name: string, position: Vector3, scene: Scene);
  46463. /**
  46464. * Gets the current object class name.
  46465. * @return the class name
  46466. */
  46467. getClassName(): string;
  46468. }
  46469. }
  46470. declare module BABYLON {
  46471. /**
  46472. * This represents all the required metrics to create a VR camera.
  46473. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46474. */
  46475. export class VRCameraMetrics {
  46476. /**
  46477. * Define the horizontal resolution off the screen.
  46478. */
  46479. hResolution: number;
  46480. /**
  46481. * Define the vertical resolution off the screen.
  46482. */
  46483. vResolution: number;
  46484. /**
  46485. * Define the horizontal screen size.
  46486. */
  46487. hScreenSize: number;
  46488. /**
  46489. * Define the vertical screen size.
  46490. */
  46491. vScreenSize: number;
  46492. /**
  46493. * Define the vertical screen center position.
  46494. */
  46495. vScreenCenter: number;
  46496. /**
  46497. * Define the distance of the eyes to the screen.
  46498. */
  46499. eyeToScreenDistance: number;
  46500. /**
  46501. * Define the distance between both lenses
  46502. */
  46503. lensSeparationDistance: number;
  46504. /**
  46505. * Define the distance between both viewer's eyes.
  46506. */
  46507. interpupillaryDistance: number;
  46508. /**
  46509. * Define the distortion factor of the VR postprocess.
  46510. * Please, touch with care.
  46511. */
  46512. distortionK: number[];
  46513. /**
  46514. * Define the chromatic aberration correction factors for the VR post process.
  46515. */
  46516. chromaAbCorrection: number[];
  46517. /**
  46518. * Define the scale factor of the post process.
  46519. * The smaller the better but the slower.
  46520. */
  46521. postProcessScaleFactor: number;
  46522. /**
  46523. * Define an offset for the lens center.
  46524. */
  46525. lensCenterOffset: number;
  46526. /**
  46527. * Define if the current vr camera should compensate the distortion of the lense or not.
  46528. */
  46529. compensateDistortion: boolean;
  46530. /**
  46531. * Defines if multiview should be enabled when rendering (Default: false)
  46532. */
  46533. multiviewEnabled: boolean;
  46534. /**
  46535. * Gets the rendering aspect ratio based on the provided resolutions.
  46536. */
  46537. get aspectRatio(): number;
  46538. /**
  46539. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46540. */
  46541. get aspectRatioFov(): number;
  46542. /**
  46543. * @hidden
  46544. */
  46545. get leftHMatrix(): Matrix;
  46546. /**
  46547. * @hidden
  46548. */
  46549. get rightHMatrix(): Matrix;
  46550. /**
  46551. * @hidden
  46552. */
  46553. get leftPreViewMatrix(): Matrix;
  46554. /**
  46555. * @hidden
  46556. */
  46557. get rightPreViewMatrix(): Matrix;
  46558. /**
  46559. * Get the default VRMetrics based on the most generic setup.
  46560. * @returns the default vr metrics
  46561. */
  46562. static GetDefault(): VRCameraMetrics;
  46563. }
  46564. }
  46565. declare module BABYLON {
  46566. /** @hidden */
  46567. export var vrDistortionCorrectionPixelShader: {
  46568. name: string;
  46569. shader: string;
  46570. };
  46571. }
  46572. declare module BABYLON {
  46573. /**
  46574. * VRDistortionCorrectionPostProcess used for mobile VR
  46575. */
  46576. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46577. private _isRightEye;
  46578. private _distortionFactors;
  46579. private _postProcessScaleFactor;
  46580. private _lensCenterOffset;
  46581. private _scaleIn;
  46582. private _scaleFactor;
  46583. private _lensCenter;
  46584. /**
  46585. * Gets a string identifying the name of the class
  46586. * @returns "VRDistortionCorrectionPostProcess" string
  46587. */
  46588. getClassName(): string;
  46589. /**
  46590. * Initializes the VRDistortionCorrectionPostProcess
  46591. * @param name The name of the effect.
  46592. * @param camera The camera to apply the render pass to.
  46593. * @param isRightEye If this is for the right eye distortion
  46594. * @param vrMetrics All the required metrics for the VR camera
  46595. */
  46596. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46597. }
  46598. }
  46599. declare module BABYLON {
  46600. /**
  46601. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46602. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46603. */
  46604. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46605. /**
  46606. * Creates a new VRDeviceOrientationArcRotateCamera
  46607. * @param name defines camera name
  46608. * @param alpha defines the camera rotation along the logitudinal axis
  46609. * @param beta defines the camera rotation along the latitudinal axis
  46610. * @param radius defines the camera distance from its target
  46611. * @param target defines the camera target
  46612. * @param scene defines the scene the camera belongs to
  46613. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46614. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46615. */
  46616. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46617. /**
  46618. * Gets camera class name
  46619. * @returns VRDeviceOrientationArcRotateCamera
  46620. */
  46621. getClassName(): string;
  46622. }
  46623. }
  46624. declare module BABYLON {
  46625. /**
  46626. * Camera used to simulate VR rendering (based on FreeCamera)
  46627. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46628. */
  46629. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46630. /**
  46631. * Creates a new VRDeviceOrientationFreeCamera
  46632. * @param name defines camera name
  46633. * @param position defines the start position of the camera
  46634. * @param scene defines the scene the camera belongs to
  46635. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46636. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46637. */
  46638. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46639. /**
  46640. * Gets camera class name
  46641. * @returns VRDeviceOrientationFreeCamera
  46642. */
  46643. getClassName(): string;
  46644. }
  46645. }
  46646. declare module BABYLON {
  46647. /**
  46648. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46649. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46650. */
  46651. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46652. /**
  46653. * Creates a new VRDeviceOrientationGamepadCamera
  46654. * @param name defines camera name
  46655. * @param position defines the start position of the camera
  46656. * @param scene defines the scene the camera belongs to
  46657. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46658. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46659. */
  46660. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46661. /**
  46662. * Gets camera class name
  46663. * @returns VRDeviceOrientationGamepadCamera
  46664. */
  46665. getClassName(): string;
  46666. }
  46667. }
  46668. declare module BABYLON {
  46669. /**
  46670. * A class extending Texture allowing drawing on a texture
  46671. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46672. */
  46673. export class DynamicTexture extends Texture {
  46674. private _generateMipMaps;
  46675. private _canvas;
  46676. private _context;
  46677. /**
  46678. * Creates a DynamicTexture
  46679. * @param name defines the name of the texture
  46680. * @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
  46681. * @param scene defines the scene where you want the texture
  46682. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46683. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46684. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46685. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  46686. */
  46687. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  46688. /**
  46689. * Get the current class name of the texture useful for serialization or dynamic coding.
  46690. * @returns "DynamicTexture"
  46691. */
  46692. getClassName(): string;
  46693. /**
  46694. * Gets the current state of canRescale
  46695. */
  46696. get canRescale(): boolean;
  46697. private _recreate;
  46698. /**
  46699. * Scales the texture
  46700. * @param ratio the scale factor to apply to both width and height
  46701. */
  46702. scale(ratio: number): void;
  46703. /**
  46704. * Resizes the texture
  46705. * @param width the new width
  46706. * @param height the new height
  46707. */
  46708. scaleTo(width: number, height: number): void;
  46709. /**
  46710. * Gets the context of the canvas used by the texture
  46711. * @returns the canvas context of the dynamic texture
  46712. */
  46713. getContext(): CanvasRenderingContext2D;
  46714. /**
  46715. * Clears the texture
  46716. */
  46717. clear(): void;
  46718. /**
  46719. * Updates the texture
  46720. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46721. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46722. */
  46723. update(invertY?: boolean, premulAlpha?: boolean): void;
  46724. /**
  46725. * Draws text onto the texture
  46726. * @param text defines the text to be drawn
  46727. * @param x defines the placement of the text from the left
  46728. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46729. * @param font defines the font to be used with font-style, font-size, font-name
  46730. * @param color defines the color used for the text
  46731. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46732. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46733. * @param update defines whether texture is immediately update (default is true)
  46734. */
  46735. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46736. /**
  46737. * Clones the texture
  46738. * @returns the clone of the texture.
  46739. */
  46740. clone(): DynamicTexture;
  46741. /**
  46742. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46743. * @returns a serialized dynamic texture object
  46744. */
  46745. serialize(): any;
  46746. private _IsCanvasElement;
  46747. /** @hidden */
  46748. _rebuild(): void;
  46749. }
  46750. }
  46751. declare module BABYLON {
  46752. /**
  46753. * Class containing static functions to help procedurally build meshes
  46754. */
  46755. export class GroundBuilder {
  46756. /**
  46757. * Creates a ground mesh
  46758. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46759. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46761. * @param name defines the name of the mesh
  46762. * @param options defines the options used to create the mesh
  46763. * @param scene defines the hosting scene
  46764. * @returns the ground mesh
  46765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46766. */
  46767. static CreateGround(name: string, options: {
  46768. width?: number;
  46769. height?: number;
  46770. subdivisions?: number;
  46771. subdivisionsX?: number;
  46772. subdivisionsY?: number;
  46773. updatable?: boolean;
  46774. }, scene: any): Mesh;
  46775. /**
  46776. * Creates a tiled ground mesh
  46777. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46778. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46779. * * 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
  46780. * * 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
  46781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46782. * @param name defines the name of the mesh
  46783. * @param options defines the options used to create the mesh
  46784. * @param scene defines the hosting scene
  46785. * @returns the tiled ground mesh
  46786. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46787. */
  46788. static CreateTiledGround(name: string, options: {
  46789. xmin: number;
  46790. zmin: number;
  46791. xmax: number;
  46792. zmax: number;
  46793. subdivisions?: {
  46794. w: number;
  46795. h: number;
  46796. };
  46797. precision?: {
  46798. w: number;
  46799. h: number;
  46800. };
  46801. updatable?: boolean;
  46802. }, scene?: Nullable<Scene>): Mesh;
  46803. /**
  46804. * Creates a ground mesh from a height map
  46805. * * The parameter `url` sets the URL of the height map image resource.
  46806. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46807. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46808. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46809. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46810. * * 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.
  46811. * * 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).
  46812. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46814. * @param name defines the name of the mesh
  46815. * @param url defines the url to the height map
  46816. * @param options defines the options used to create the mesh
  46817. * @param scene defines the hosting scene
  46818. * @returns the ground mesh
  46819. * @see https://doc.babylonjs.com/babylon101/height_map
  46820. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46821. */
  46822. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46823. width?: number;
  46824. height?: number;
  46825. subdivisions?: number;
  46826. minHeight?: number;
  46827. maxHeight?: number;
  46828. colorFilter?: Color3;
  46829. alphaFilter?: number;
  46830. updatable?: boolean;
  46831. onReady?: (mesh: GroundMesh) => void;
  46832. }, scene?: Nullable<Scene>): GroundMesh;
  46833. }
  46834. }
  46835. declare module BABYLON {
  46836. /**
  46837. * Class containing static functions to help procedurally build meshes
  46838. */
  46839. export class TorusBuilder {
  46840. /**
  46841. * Creates a torus mesh
  46842. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46843. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46844. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46846. * * 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
  46847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46848. * @param name defines the name of the mesh
  46849. * @param options defines the options used to create the mesh
  46850. * @param scene defines the hosting scene
  46851. * @returns the torus mesh
  46852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46853. */
  46854. static CreateTorus(name: string, options: {
  46855. diameter?: number;
  46856. thickness?: number;
  46857. tessellation?: number;
  46858. updatable?: boolean;
  46859. sideOrientation?: number;
  46860. frontUVs?: Vector4;
  46861. backUVs?: Vector4;
  46862. }, scene: any): Mesh;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * Class containing static functions to help procedurally build meshes
  46868. */
  46869. export class CylinderBuilder {
  46870. /**
  46871. * Creates a cylinder or a cone mesh
  46872. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46873. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46874. * * 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.
  46875. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46876. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46877. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46878. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46879. * * 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).
  46880. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46881. * * 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).
  46882. * * 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
  46883. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46884. * * 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
  46885. * * 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.
  46886. * * If `enclose` is false, a ring surface is one element.
  46887. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46888. * * 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
  46889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46890. * * 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
  46891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46892. * @param name defines the name of the mesh
  46893. * @param options defines the options used to create the mesh
  46894. * @param scene defines the hosting scene
  46895. * @returns the cylinder mesh
  46896. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46897. */
  46898. static CreateCylinder(name: string, options: {
  46899. height?: number;
  46900. diameterTop?: number;
  46901. diameterBottom?: number;
  46902. diameter?: number;
  46903. tessellation?: number;
  46904. subdivisions?: number;
  46905. arc?: number;
  46906. faceColors?: Color4[];
  46907. faceUV?: Vector4[];
  46908. updatable?: boolean;
  46909. hasRings?: boolean;
  46910. enclose?: boolean;
  46911. cap?: number;
  46912. sideOrientation?: number;
  46913. frontUVs?: Vector4;
  46914. backUVs?: Vector4;
  46915. }, scene: any): Mesh;
  46916. }
  46917. }
  46918. declare module BABYLON {
  46919. /**
  46920. * States of the webXR experience
  46921. */
  46922. export enum WebXRState {
  46923. /**
  46924. * Transitioning to being in XR mode
  46925. */
  46926. ENTERING_XR = 0,
  46927. /**
  46928. * Transitioning to non XR mode
  46929. */
  46930. EXITING_XR = 1,
  46931. /**
  46932. * In XR mode and presenting
  46933. */
  46934. IN_XR = 2,
  46935. /**
  46936. * Not entered XR mode
  46937. */
  46938. NOT_IN_XR = 3
  46939. }
  46940. /**
  46941. * Abstraction of the XR render target
  46942. */
  46943. export interface WebXRRenderTarget extends IDisposable {
  46944. /**
  46945. * xrpresent context of the canvas which can be used to display/mirror xr content
  46946. */
  46947. canvasContext: WebGLRenderingContext;
  46948. /**
  46949. * xr layer for the canvas
  46950. */
  46951. xrLayer: Nullable<XRWebGLLayer>;
  46952. /**
  46953. * Initializes the xr layer for the session
  46954. * @param xrSession xr session
  46955. * @returns a promise that will resolve once the XR Layer has been created
  46956. */
  46957. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46958. }
  46959. }
  46960. declare module BABYLON {
  46961. /**
  46962. * COnfiguration object for WebXR output canvas
  46963. */
  46964. export class WebXRManagedOutputCanvasOptions {
  46965. /**
  46966. * An optional canvas in case you wish to create it yourself and provide it here.
  46967. * If not provided, a new canvas will be created
  46968. */
  46969. canvasElement?: HTMLCanvasElement;
  46970. /**
  46971. * Options for this XR Layer output
  46972. */
  46973. canvasOptions?: XRWebGLLayerOptions;
  46974. /**
  46975. * CSS styling for a newly created canvas (if not provided)
  46976. */
  46977. newCanvasCssStyle?: string;
  46978. /**
  46979. * Get the default values of the configuration object
  46980. * @param engine defines the engine to use (can be null)
  46981. * @returns default values of this configuration object
  46982. */
  46983. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46984. }
  46985. /**
  46986. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46987. */
  46988. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46989. private _options;
  46990. private _canvas;
  46991. private _engine;
  46992. private _originalCanvasSize;
  46993. /**
  46994. * Rendering context of the canvas which can be used to display/mirror xr content
  46995. */
  46996. canvasContext: WebGLRenderingContext;
  46997. /**
  46998. * xr layer for the canvas
  46999. */
  47000. xrLayer: Nullable<XRWebGLLayer>;
  47001. /**
  47002. * Obseervers registered here will be triggered when the xr layer was initialized
  47003. */
  47004. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47005. /**
  47006. * Initializes the canvas to be added/removed upon entering/exiting xr
  47007. * @param _xrSessionManager The XR Session manager
  47008. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47009. */
  47010. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47011. /**
  47012. * Disposes of the object
  47013. */
  47014. dispose(): void;
  47015. /**
  47016. * Initializes the xr layer for the session
  47017. * @param xrSession xr session
  47018. * @returns a promise that will resolve once the XR Layer has been created
  47019. */
  47020. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47021. private _addCanvas;
  47022. private _removeCanvas;
  47023. private _setCanvasSize;
  47024. private _setManagedOutputCanvas;
  47025. }
  47026. }
  47027. declare module BABYLON {
  47028. /**
  47029. * Manages an XRSession to work with Babylon's engine
  47030. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47031. */
  47032. export class WebXRSessionManager implements IDisposable {
  47033. /** The scene which the session should be created for */
  47034. scene: Scene;
  47035. private _referenceSpace;
  47036. private _rttProvider;
  47037. private _sessionEnded;
  47038. private _xrNavigator;
  47039. private baseLayer;
  47040. /**
  47041. * The base reference space from which the session started. good if you want to reset your
  47042. * reference space
  47043. */
  47044. baseReferenceSpace: XRReferenceSpace;
  47045. /**
  47046. * Current XR frame
  47047. */
  47048. currentFrame: Nullable<XRFrame>;
  47049. /** WebXR timestamp updated every frame */
  47050. currentTimestamp: number;
  47051. /**
  47052. * Used just in case of a failure to initialize an immersive session.
  47053. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47054. */
  47055. defaultHeightCompensation: number;
  47056. /**
  47057. * Fires every time a new xrFrame arrives which can be used to update the camera
  47058. */
  47059. onXRFrameObservable: Observable<XRFrame>;
  47060. /**
  47061. * Fires when the reference space changed
  47062. */
  47063. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47064. /**
  47065. * Fires when the xr session is ended either by the device or manually done
  47066. */
  47067. onXRSessionEnded: Observable<any>;
  47068. /**
  47069. * Fires when the xr session is ended either by the device or manually done
  47070. */
  47071. onXRSessionInit: Observable<XRSession>;
  47072. /**
  47073. * Underlying xr session
  47074. */
  47075. session: XRSession;
  47076. /**
  47077. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47078. * or get the offset the player is currently at.
  47079. */
  47080. viewerReferenceSpace: XRReferenceSpace;
  47081. /**
  47082. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47083. * @param scene The scene which the session should be created for
  47084. */
  47085. constructor(
  47086. /** The scene which the session should be created for */
  47087. scene: Scene);
  47088. /**
  47089. * The current reference space used in this session. This reference space can constantly change!
  47090. * It is mainly used to offset the camera's position.
  47091. */
  47092. get referenceSpace(): XRReferenceSpace;
  47093. /**
  47094. * Set a new reference space and triggers the observable
  47095. */
  47096. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47097. /**
  47098. * Disposes of the session manager
  47099. */
  47100. dispose(): void;
  47101. /**
  47102. * Stops the xrSession and restores the render loop
  47103. * @returns Promise which resolves after it exits XR
  47104. */
  47105. exitXRAsync(): Promise<void>;
  47106. /**
  47107. * Gets the correct render target texture to be rendered this frame for this eye
  47108. * @param eye the eye for which to get the render target
  47109. * @returns the render target for the specified eye
  47110. */
  47111. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47112. /**
  47113. * Creates a WebXRRenderTarget object for the XR session
  47114. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47115. * @param options optional options to provide when creating a new render target
  47116. * @returns a WebXR render target to which the session can render
  47117. */
  47118. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47119. /**
  47120. * Initializes the manager
  47121. * After initialization enterXR can be called to start an XR session
  47122. * @returns Promise which resolves after it is initialized
  47123. */
  47124. initializeAsync(): Promise<void>;
  47125. /**
  47126. * Initializes an xr session
  47127. * @param xrSessionMode mode to initialize
  47128. * @param xrSessionInit defines optional and required values to pass to the session builder
  47129. * @returns a promise which will resolve once the session has been initialized
  47130. */
  47131. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47132. /**
  47133. * Checks if a session would be supported for the creation options specified
  47134. * @param sessionMode session mode to check if supported eg. immersive-vr
  47135. * @returns A Promise that resolves to true if supported and false if not
  47136. */
  47137. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47138. /**
  47139. * Resets the reference space to the one started the session
  47140. */
  47141. resetReferenceSpace(): void;
  47142. /**
  47143. * Starts rendering to the xr layer
  47144. */
  47145. runXRRenderLoop(): void;
  47146. /**
  47147. * Sets the reference space on the xr session
  47148. * @param referenceSpaceType space to set
  47149. * @returns a promise that will resolve once the reference space has been set
  47150. */
  47151. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47152. /**
  47153. * Updates the render state of the session
  47154. * @param state state to set
  47155. * @returns a promise that resolves once the render state has been updated
  47156. */
  47157. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47158. /**
  47159. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47160. * @param sessionMode defines the session to test
  47161. * @returns a promise with boolean as final value
  47162. */
  47163. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47164. private _createRenderTargetTexture;
  47165. }
  47166. }
  47167. declare module BABYLON {
  47168. /**
  47169. * WebXR Camera which holds the views for the xrSession
  47170. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47171. */
  47172. export class WebXRCamera extends FreeCamera {
  47173. private _xrSessionManager;
  47174. private _firstFrame;
  47175. private _referenceQuaternion;
  47176. private _referencedPosition;
  47177. private _xrInvPositionCache;
  47178. private _xrInvQuaternionCache;
  47179. /**
  47180. * Observable raised before camera teleportation
  47181. */
  47182. onBeforeCameraTeleport: Observable<Vector3>;
  47183. /**
  47184. * Observable raised after camera teleportation
  47185. */
  47186. onAfterCameraTeleport: Observable<Vector3>;
  47187. /**
  47188. * Should position compensation execute on first frame.
  47189. * This is used when copying the position from a native (non XR) camera
  47190. */
  47191. compensateOnFirstFrame: boolean;
  47192. /**
  47193. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47194. * @param name the name of the camera
  47195. * @param scene the scene to add the camera to
  47196. * @param _xrSessionManager a constructed xr session manager
  47197. */
  47198. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47199. /**
  47200. * Return the user's height, unrelated to the current ground.
  47201. * This will be the y position of this camera, when ground level is 0.
  47202. */
  47203. get realWorldHeight(): number;
  47204. /** @hidden */
  47205. _updateForDualEyeDebugging(): void;
  47206. /**
  47207. * Sets this camera's transformation based on a non-vr camera
  47208. * @param otherCamera the non-vr camera to copy the transformation from
  47209. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47210. */
  47211. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47212. /**
  47213. * Gets the current instance class name ("WebXRCamera").
  47214. * @returns the class name
  47215. */
  47216. getClassName(): string;
  47217. private _rotate180;
  47218. private _updateFromXRSession;
  47219. private _updateNumberOfRigCameras;
  47220. private _updateReferenceSpace;
  47221. private _updateReferenceSpaceOffset;
  47222. }
  47223. }
  47224. declare module BABYLON {
  47225. /**
  47226. * Defining the interface required for a (webxr) feature
  47227. */
  47228. export interface IWebXRFeature extends IDisposable {
  47229. /**
  47230. * Is this feature attached
  47231. */
  47232. attached: boolean;
  47233. /**
  47234. * Should auto-attach be disabled?
  47235. */
  47236. disableAutoAttach: boolean;
  47237. /**
  47238. * Attach the feature to the session
  47239. * Will usually be called by the features manager
  47240. *
  47241. * @param force should attachment be forced (even when already attached)
  47242. * @returns true if successful.
  47243. */
  47244. attach(force?: boolean): boolean;
  47245. /**
  47246. * Detach the feature from the session
  47247. * Will usually be called by the features manager
  47248. *
  47249. * @returns true if successful.
  47250. */
  47251. detach(): boolean;
  47252. /**
  47253. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47254. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47255. *
  47256. * @returns whether or not the feature is compatible in this environment
  47257. */
  47258. isCompatible(): boolean;
  47259. /**
  47260. * Was this feature disposed;
  47261. */
  47262. isDisposed: boolean;
  47263. /**
  47264. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47265. */
  47266. xrNativeFeatureName?: string;
  47267. /**
  47268. * A list of (Babylon WebXR) features this feature depends on
  47269. */
  47270. dependsOn?: string[];
  47271. }
  47272. /**
  47273. * A list of the currently available features without referencing them
  47274. */
  47275. export class WebXRFeatureName {
  47276. /**
  47277. * The name of the anchor system feature
  47278. */
  47279. static readonly ANCHOR_SYSTEM: string;
  47280. /**
  47281. * The name of the background remover feature
  47282. */
  47283. static readonly BACKGROUND_REMOVER: string;
  47284. /**
  47285. * The name of the hit test feature
  47286. */
  47287. static readonly HIT_TEST: string;
  47288. /**
  47289. * physics impostors for xr controllers feature
  47290. */
  47291. static readonly PHYSICS_CONTROLLERS: string;
  47292. /**
  47293. * The name of the plane detection feature
  47294. */
  47295. static readonly PLANE_DETECTION: string;
  47296. /**
  47297. * The name of the pointer selection feature
  47298. */
  47299. static readonly POINTER_SELECTION: string;
  47300. /**
  47301. * The name of the teleportation feature
  47302. */
  47303. static readonly TELEPORTATION: string;
  47304. /**
  47305. * The name of the feature points feature.
  47306. */
  47307. static readonly FEATURE_POINTS: string;
  47308. /**
  47309. * The name of the hand tracking feature.
  47310. */
  47311. static readonly HAND_TRACKING: string;
  47312. }
  47313. /**
  47314. * Defining the constructor of a feature. Used to register the modules.
  47315. */
  47316. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47317. /**
  47318. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47319. * It is mainly used in AR sessions.
  47320. *
  47321. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47322. */
  47323. export class WebXRFeaturesManager implements IDisposable {
  47324. private _xrSessionManager;
  47325. private static readonly _AvailableFeatures;
  47326. private _features;
  47327. /**
  47328. * constructs a new features manages.
  47329. *
  47330. * @param _xrSessionManager an instance of WebXRSessionManager
  47331. */
  47332. constructor(_xrSessionManager: WebXRSessionManager);
  47333. /**
  47334. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47335. * Mainly used internally.
  47336. *
  47337. * @param featureName the name of the feature to register
  47338. * @param constructorFunction the function used to construct the module
  47339. * @param version the (babylon) version of the module
  47340. * @param stable is that a stable version of this module
  47341. */
  47342. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47343. /**
  47344. * Returns a constructor of a specific feature.
  47345. *
  47346. * @param featureName the name of the feature to construct
  47347. * @param version the version of the feature to load
  47348. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47349. * @param options optional options provided to the module.
  47350. * @returns a function that, when called, will return a new instance of this feature
  47351. */
  47352. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47353. /**
  47354. * Can be used to return the list of features currently registered
  47355. *
  47356. * @returns an Array of available features
  47357. */
  47358. static GetAvailableFeatures(): string[];
  47359. /**
  47360. * Gets the versions available for a specific feature
  47361. * @param featureName the name of the feature
  47362. * @returns an array with the available versions
  47363. */
  47364. static GetAvailableVersions(featureName: string): string[];
  47365. /**
  47366. * Return the latest unstable version of this feature
  47367. * @param featureName the name of the feature to search
  47368. * @returns the version number. if not found will return -1
  47369. */
  47370. static GetLatestVersionOfFeature(featureName: string): number;
  47371. /**
  47372. * Return the latest stable version of this feature
  47373. * @param featureName the name of the feature to search
  47374. * @returns the version number. if not found will return -1
  47375. */
  47376. static GetStableVersionOfFeature(featureName: string): number;
  47377. /**
  47378. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47379. * Can be used during a session to start a feature
  47380. * @param featureName the name of feature to attach
  47381. */
  47382. attachFeature(featureName: string): void;
  47383. /**
  47384. * Can be used inside a session or when the session ends to detach a specific feature
  47385. * @param featureName the name of the feature to detach
  47386. */
  47387. detachFeature(featureName: string): void;
  47388. /**
  47389. * Used to disable an already-enabled feature
  47390. * The feature will be disposed and will be recreated once enabled.
  47391. * @param featureName the feature to disable
  47392. * @returns true if disable was successful
  47393. */
  47394. disableFeature(featureName: string | {
  47395. Name: string;
  47396. }): boolean;
  47397. /**
  47398. * dispose this features manager
  47399. */
  47400. dispose(): void;
  47401. /**
  47402. * 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.
  47403. * 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.
  47404. *
  47405. * @param featureName the name of the feature to load or the class of the feature
  47406. * @param version optional version to load. if not provided the latest version will be enabled
  47407. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47408. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47409. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47410. * @returns a new constructed feature or throws an error if feature not found.
  47411. */
  47412. enableFeature(featureName: string | {
  47413. Name: string;
  47414. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47415. /**
  47416. * get the implementation of an enabled feature.
  47417. * @param featureName the name of the feature to load
  47418. * @returns the feature class, if found
  47419. */
  47420. getEnabledFeature(featureName: string): IWebXRFeature;
  47421. /**
  47422. * Get the list of enabled features
  47423. * @returns an array of enabled features
  47424. */
  47425. getEnabledFeatures(): string[];
  47426. /**
  47427. * This function will exten the session creation configuration object with enabled features.
  47428. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47429. * according to the defined "required" variable, provided during enableFeature call
  47430. * @param xrSessionInit the xr Session init object to extend
  47431. *
  47432. * @returns an extended XRSessionInit object
  47433. */
  47434. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47435. }
  47436. }
  47437. declare module BABYLON {
  47438. /**
  47439. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47440. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47441. */
  47442. export class WebXRExperienceHelper implements IDisposable {
  47443. private scene;
  47444. private _nonVRCamera;
  47445. private _originalSceneAutoClear;
  47446. private _supported;
  47447. /**
  47448. * Camera used to render xr content
  47449. */
  47450. camera: WebXRCamera;
  47451. /** A features manager for this xr session */
  47452. featuresManager: WebXRFeaturesManager;
  47453. /**
  47454. * Observers registered here will be triggered after the camera's initial transformation is set
  47455. * This can be used to set a different ground level or an extra rotation.
  47456. *
  47457. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47458. * to the position set after this observable is done executing.
  47459. */
  47460. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47461. /**
  47462. * Fires when the state of the experience helper has changed
  47463. */
  47464. onStateChangedObservable: Observable<WebXRState>;
  47465. /** Session manager used to keep track of xr session */
  47466. sessionManager: WebXRSessionManager;
  47467. /**
  47468. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47469. */
  47470. state: WebXRState;
  47471. /**
  47472. * Creates a WebXRExperienceHelper
  47473. * @param scene The scene the helper should be created in
  47474. */
  47475. private constructor();
  47476. /**
  47477. * Creates the experience helper
  47478. * @param scene the scene to attach the experience helper to
  47479. * @returns a promise for the experience helper
  47480. */
  47481. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47482. /**
  47483. * Disposes of the experience helper
  47484. */
  47485. dispose(): void;
  47486. /**
  47487. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47488. * @param sessionMode options for the XR session
  47489. * @param referenceSpaceType frame of reference of the XR session
  47490. * @param renderTarget the output canvas that will be used to enter XR mode
  47491. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47492. * @returns promise that resolves after xr mode has entered
  47493. */
  47494. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47495. /**
  47496. * Exits XR mode and returns the scene to its original state
  47497. * @returns promise that resolves after xr mode has exited
  47498. */
  47499. exitXRAsync(): Promise<void>;
  47500. private _nonXRToXRCamera;
  47501. private _setState;
  47502. }
  47503. }
  47504. declare module BABYLON {
  47505. /**
  47506. * X-Y values for axes in WebXR
  47507. */
  47508. export interface IWebXRMotionControllerAxesValue {
  47509. /**
  47510. * The value of the x axis
  47511. */
  47512. x: number;
  47513. /**
  47514. * The value of the y-axis
  47515. */
  47516. y: number;
  47517. }
  47518. /**
  47519. * changed / previous values for the values of this component
  47520. */
  47521. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47522. /**
  47523. * current (this frame) value
  47524. */
  47525. current: T;
  47526. /**
  47527. * previous (last change) value
  47528. */
  47529. previous: T;
  47530. }
  47531. /**
  47532. * Represents changes in the component between current frame and last values recorded
  47533. */
  47534. export interface IWebXRMotionControllerComponentChanges {
  47535. /**
  47536. * will be populated with previous and current values if axes changed
  47537. */
  47538. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47539. /**
  47540. * will be populated with previous and current values if pressed changed
  47541. */
  47542. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47543. /**
  47544. * will be populated with previous and current values if touched changed
  47545. */
  47546. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47547. /**
  47548. * will be populated with previous and current values if value changed
  47549. */
  47550. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47551. }
  47552. /**
  47553. * This class represents a single component (for example button or thumbstick) of a motion controller
  47554. */
  47555. export class WebXRControllerComponent implements IDisposable {
  47556. /**
  47557. * the id of this component
  47558. */
  47559. id: string;
  47560. /**
  47561. * the type of the component
  47562. */
  47563. type: MotionControllerComponentType;
  47564. private _buttonIndex;
  47565. private _axesIndices;
  47566. private _axes;
  47567. private _changes;
  47568. private _currentValue;
  47569. private _hasChanges;
  47570. private _pressed;
  47571. private _touched;
  47572. /**
  47573. * button component type
  47574. */
  47575. static BUTTON_TYPE: MotionControllerComponentType;
  47576. /**
  47577. * squeeze component type
  47578. */
  47579. static SQUEEZE_TYPE: MotionControllerComponentType;
  47580. /**
  47581. * Thumbstick component type
  47582. */
  47583. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47584. /**
  47585. * Touchpad component type
  47586. */
  47587. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47588. /**
  47589. * trigger component type
  47590. */
  47591. static TRIGGER_TYPE: MotionControllerComponentType;
  47592. /**
  47593. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47594. * the axes data changes
  47595. */
  47596. onAxisValueChangedObservable: Observable<{
  47597. x: number;
  47598. y: number;
  47599. }>;
  47600. /**
  47601. * Observers registered here will be triggered when the state of a button changes
  47602. * State change is either pressed / touched / value
  47603. */
  47604. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47605. /**
  47606. * Creates a new component for a motion controller.
  47607. * It is created by the motion controller itself
  47608. *
  47609. * @param id the id of this component
  47610. * @param type the type of the component
  47611. * @param _buttonIndex index in the buttons array of the gamepad
  47612. * @param _axesIndices indices of the values in the axes array of the gamepad
  47613. */
  47614. constructor(
  47615. /**
  47616. * the id of this component
  47617. */
  47618. id: string,
  47619. /**
  47620. * the type of the component
  47621. */
  47622. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47623. /**
  47624. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47625. */
  47626. get axes(): IWebXRMotionControllerAxesValue;
  47627. /**
  47628. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47629. */
  47630. get changes(): IWebXRMotionControllerComponentChanges;
  47631. /**
  47632. * Return whether or not the component changed the last frame
  47633. */
  47634. get hasChanges(): boolean;
  47635. /**
  47636. * is the button currently pressed
  47637. */
  47638. get pressed(): boolean;
  47639. /**
  47640. * is the button currently touched
  47641. */
  47642. get touched(): boolean;
  47643. /**
  47644. * Get the current value of this component
  47645. */
  47646. get value(): number;
  47647. /**
  47648. * Dispose this component
  47649. */
  47650. dispose(): void;
  47651. /**
  47652. * Are there axes correlating to this component
  47653. * @return true is axes data is available
  47654. */
  47655. isAxes(): boolean;
  47656. /**
  47657. * Is this component a button (hence - pressable)
  47658. * @returns true if can be pressed
  47659. */
  47660. isButton(): boolean;
  47661. /**
  47662. * update this component using the gamepad object it is in. Called on every frame
  47663. * @param nativeController the native gamepad controller object
  47664. */
  47665. update(nativeController: IMinimalMotionControllerObject): void;
  47666. }
  47667. }
  47668. declare module BABYLON {
  47669. /**
  47670. * Interface used to represent data loading progression
  47671. */
  47672. export interface ISceneLoaderProgressEvent {
  47673. /**
  47674. * Defines if data length to load can be evaluated
  47675. */
  47676. readonly lengthComputable: boolean;
  47677. /**
  47678. * Defines the loaded data length
  47679. */
  47680. readonly loaded: number;
  47681. /**
  47682. * Defines the data length to load
  47683. */
  47684. readonly total: number;
  47685. }
  47686. /**
  47687. * Interface used by SceneLoader plugins to define supported file extensions
  47688. */
  47689. export interface ISceneLoaderPluginExtensions {
  47690. /**
  47691. * Defines the list of supported extensions
  47692. */
  47693. [extension: string]: {
  47694. isBinary: boolean;
  47695. };
  47696. }
  47697. /**
  47698. * Interface used by SceneLoader plugin factory
  47699. */
  47700. export interface ISceneLoaderPluginFactory {
  47701. /**
  47702. * Defines the name of the factory
  47703. */
  47704. name: string;
  47705. /**
  47706. * Function called to create a new plugin
  47707. * @return the new plugin
  47708. */
  47709. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47710. /**
  47711. * The callback that returns true if the data can be directly loaded.
  47712. * @param data string containing the file data
  47713. * @returns if the data can be loaded directly
  47714. */
  47715. canDirectLoad?(data: string): boolean;
  47716. }
  47717. /**
  47718. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47719. */
  47720. export interface ISceneLoaderPluginBase {
  47721. /**
  47722. * The friendly name of this plugin.
  47723. */
  47724. name: string;
  47725. /**
  47726. * The file extensions supported by this plugin.
  47727. */
  47728. extensions: string | ISceneLoaderPluginExtensions;
  47729. /**
  47730. * The callback called when loading from a url.
  47731. * @param scene scene loading this url
  47732. * @param url url to load
  47733. * @param onSuccess callback called when the file successfully loads
  47734. * @param onProgress callback called while file is loading (if the server supports this mode)
  47735. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47736. * @param onError callback called when the file fails to load
  47737. * @returns a file request object
  47738. */
  47739. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47740. /**
  47741. * The callback called when loading from a file object.
  47742. * @param scene scene loading this file
  47743. * @param file defines the file to load
  47744. * @param onSuccess defines the callback to call when data is loaded
  47745. * @param onProgress defines the callback to call during loading process
  47746. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47747. * @param onError defines the callback to call when an error occurs
  47748. * @returns a file request object
  47749. */
  47750. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47751. /**
  47752. * The callback that returns true if the data can be directly loaded.
  47753. * @param data string containing the file data
  47754. * @returns if the data can be loaded directly
  47755. */
  47756. canDirectLoad?(data: string): boolean;
  47757. /**
  47758. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47759. * @param scene scene loading this data
  47760. * @param data string containing the data
  47761. * @returns data to pass to the plugin
  47762. */
  47763. directLoad?(scene: Scene, data: string): any;
  47764. /**
  47765. * The callback that allows custom handling of the root url based on the response url.
  47766. * @param rootUrl the original root url
  47767. * @param responseURL the response url if available
  47768. * @returns the new root url
  47769. */
  47770. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47771. }
  47772. /**
  47773. * Interface used to define a SceneLoader plugin
  47774. */
  47775. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47776. /**
  47777. * Import meshes into a scene.
  47778. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47779. * @param scene The scene to import into
  47780. * @param data The data to import
  47781. * @param rootUrl The root url for scene and resources
  47782. * @param meshes The meshes array to import into
  47783. * @param particleSystems The particle systems array to import into
  47784. * @param skeletons The skeletons array to import into
  47785. * @param onError The callback when import fails
  47786. * @returns True if successful or false otherwise
  47787. */
  47788. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47789. /**
  47790. * Load into a scene.
  47791. * @param scene The scene to load into
  47792. * @param data The data to import
  47793. * @param rootUrl The root url for scene and resources
  47794. * @param onError The callback when import fails
  47795. * @returns True if successful or false otherwise
  47796. */
  47797. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47798. /**
  47799. * Load into an asset container.
  47800. * @param scene The scene to load into
  47801. * @param data The data to import
  47802. * @param rootUrl The root url for scene and resources
  47803. * @param onError The callback when import fails
  47804. * @returns The loaded asset container
  47805. */
  47806. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47807. }
  47808. /**
  47809. * Interface used to define an async SceneLoader plugin
  47810. */
  47811. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47812. /**
  47813. * Import meshes into a scene.
  47814. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47815. * @param scene The scene to import into
  47816. * @param data The data to import
  47817. * @param rootUrl The root url for scene and resources
  47818. * @param onProgress The callback when the load progresses
  47819. * @param fileName Defines the name of the file to load
  47820. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47821. */
  47822. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47823. meshes: AbstractMesh[];
  47824. particleSystems: IParticleSystem[];
  47825. skeletons: Skeleton[];
  47826. animationGroups: AnimationGroup[];
  47827. }>;
  47828. /**
  47829. * Load into a scene.
  47830. * @param scene The scene to load into
  47831. * @param data The data to import
  47832. * @param rootUrl The root url for scene and resources
  47833. * @param onProgress The callback when the load progresses
  47834. * @param fileName Defines the name of the file to load
  47835. * @returns Nothing
  47836. */
  47837. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47838. /**
  47839. * Load into an asset container.
  47840. * @param scene The scene to load into
  47841. * @param data The data to import
  47842. * @param rootUrl The root url for scene and resources
  47843. * @param onProgress The callback when the load progresses
  47844. * @param fileName Defines the name of the file to load
  47845. * @returns The loaded asset container
  47846. */
  47847. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47848. }
  47849. /**
  47850. * Mode that determines how to handle old animation groups before loading new ones.
  47851. */
  47852. export enum SceneLoaderAnimationGroupLoadingMode {
  47853. /**
  47854. * Reset all old animations to initial state then dispose them.
  47855. */
  47856. Clean = 0,
  47857. /**
  47858. * Stop all old animations.
  47859. */
  47860. Stop = 1,
  47861. /**
  47862. * Restart old animations from first frame.
  47863. */
  47864. Sync = 2,
  47865. /**
  47866. * Old animations remains untouched.
  47867. */
  47868. NoSync = 3
  47869. }
  47870. /**
  47871. * Defines a plugin registered by the SceneLoader
  47872. */
  47873. interface IRegisteredPlugin {
  47874. /**
  47875. * Defines the plugin to use
  47876. */
  47877. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47878. /**
  47879. * Defines if the plugin supports binary data
  47880. */
  47881. isBinary: boolean;
  47882. }
  47883. /**
  47884. * Class used to load scene from various file formats using registered plugins
  47885. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47886. */
  47887. export class SceneLoader {
  47888. /**
  47889. * No logging while loading
  47890. */
  47891. static readonly NO_LOGGING: number;
  47892. /**
  47893. * Minimal logging while loading
  47894. */
  47895. static readonly MINIMAL_LOGGING: number;
  47896. /**
  47897. * Summary logging while loading
  47898. */
  47899. static readonly SUMMARY_LOGGING: number;
  47900. /**
  47901. * Detailled logging while loading
  47902. */
  47903. static readonly DETAILED_LOGGING: number;
  47904. /**
  47905. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47906. */
  47907. static get ForceFullSceneLoadingForIncremental(): boolean;
  47908. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47909. /**
  47910. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47911. */
  47912. static get ShowLoadingScreen(): boolean;
  47913. static set ShowLoadingScreen(value: boolean);
  47914. /**
  47915. * Defines the current logging level (while loading the scene)
  47916. * @ignorenaming
  47917. */
  47918. static get loggingLevel(): number;
  47919. static set loggingLevel(value: number);
  47920. /**
  47921. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47922. */
  47923. static get CleanBoneMatrixWeights(): boolean;
  47924. static set CleanBoneMatrixWeights(value: boolean);
  47925. /**
  47926. * Event raised when a plugin is used to load a scene
  47927. */
  47928. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47929. private static _registeredPlugins;
  47930. private static _showingLoadingScreen;
  47931. /**
  47932. * Gets the default plugin (used to load Babylon files)
  47933. * @returns the .babylon plugin
  47934. */
  47935. static GetDefaultPlugin(): IRegisteredPlugin;
  47936. private static _GetPluginForExtension;
  47937. private static _GetPluginForDirectLoad;
  47938. private static _GetPluginForFilename;
  47939. private static _GetDirectLoad;
  47940. private static _LoadData;
  47941. private static _GetFileInfo;
  47942. /**
  47943. * Gets a plugin that can load the given extension
  47944. * @param extension defines the extension to load
  47945. * @returns a plugin or null if none works
  47946. */
  47947. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47948. /**
  47949. * Gets a boolean indicating that the given extension can be loaded
  47950. * @param extension defines the extension to load
  47951. * @returns true if the extension is supported
  47952. */
  47953. static IsPluginForExtensionAvailable(extension: string): boolean;
  47954. /**
  47955. * Adds a new plugin to the list of registered plugins
  47956. * @param plugin defines the plugin to add
  47957. */
  47958. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47959. /**
  47960. * Import meshes into a scene
  47961. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47962. * @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)
  47963. * @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)
  47964. * @param scene the instance of BABYLON.Scene to append to
  47965. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  47966. * @param onProgress a callback with a progress event for each file being loaded
  47967. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47968. * @param pluginExtension the extension used to determine the plugin
  47969. * @returns The loaded plugin
  47970. */
  47971. 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>;
  47972. /**
  47973. * Import meshes into a scene
  47974. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47975. * @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)
  47976. * @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)
  47977. * @param scene the instance of BABYLON.Scene to append to
  47978. * @param onProgress a callback with a progress event for each file being loaded
  47979. * @param pluginExtension the extension used to determine the plugin
  47980. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47981. */
  47982. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47983. meshes: AbstractMesh[];
  47984. particleSystems: IParticleSystem[];
  47985. skeletons: Skeleton[];
  47986. animationGroups: AnimationGroup[];
  47987. }>;
  47988. /**
  47989. * Load a scene
  47990. * @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)
  47991. * @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)
  47992. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47993. * @param onSuccess a callback with the scene when import succeeds
  47994. * @param onProgress a callback with a progress event for each file being loaded
  47995. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47996. * @param pluginExtension the extension used to determine the plugin
  47997. * @returns The loaded plugin
  47998. */
  47999. 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>;
  48000. /**
  48001. * Load a scene
  48002. * @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)
  48003. * @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)
  48004. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48005. * @param onProgress a callback with a progress event for each file being loaded
  48006. * @param pluginExtension the extension used to determine the plugin
  48007. * @returns The loaded scene
  48008. */
  48009. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48010. /**
  48011. * Append a scene
  48012. * @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)
  48013. * @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)
  48014. * @param scene is the instance of BABYLON.Scene to append to
  48015. * @param onSuccess a callback with the scene when import succeeds
  48016. * @param onProgress a callback with a progress event for each file being loaded
  48017. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48018. * @param pluginExtension the extension used to determine the plugin
  48019. * @returns The loaded plugin
  48020. */
  48021. 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>;
  48022. /**
  48023. * Append a scene
  48024. * @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)
  48025. * @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)
  48026. * @param scene is the instance of BABYLON.Scene to append to
  48027. * @param onProgress a callback with a progress event for each file being loaded
  48028. * @param pluginExtension the extension used to determine the plugin
  48029. * @returns The given scene
  48030. */
  48031. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48032. /**
  48033. * Load a scene into an asset container
  48034. * @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)
  48035. * @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)
  48036. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48037. * @param onSuccess a callback with the scene when import succeeds
  48038. * @param onProgress a callback with a progress event for each file being loaded
  48039. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48040. * @param pluginExtension the extension used to determine the plugin
  48041. * @returns The loaded plugin
  48042. */
  48043. 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>;
  48044. /**
  48045. * Load a scene into an asset container
  48046. * @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)
  48047. * @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)
  48048. * @param scene is the instance of Scene to append to
  48049. * @param onProgress a callback with a progress event for each file being loaded
  48050. * @param pluginExtension the extension used to determine the plugin
  48051. * @returns The loaded asset container
  48052. */
  48053. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48054. /**
  48055. * Import animations from a file into a scene
  48056. * @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)
  48057. * @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)
  48058. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48059. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48060. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48061. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48062. * @param onSuccess a callback with the scene when import succeeds
  48063. * @param onProgress a callback with a progress event for each file being loaded
  48064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48065. * @param pluginExtension the extension used to determine the plugin
  48066. */
  48067. 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;
  48068. /**
  48069. * Import animations from a file into a scene
  48070. * @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)
  48071. * @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)
  48072. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48073. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48074. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48075. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48076. * @param onSuccess a callback with the scene when import succeeds
  48077. * @param onProgress a callback with a progress event for each file being loaded
  48078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48079. * @param pluginExtension the extension used to determine the plugin
  48080. * @returns the updated scene with imported animations
  48081. */
  48082. 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>;
  48083. }
  48084. }
  48085. declare module BABYLON {
  48086. /**
  48087. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48088. */
  48089. export type MotionControllerHandedness = "none" | "left" | "right";
  48090. /**
  48091. * The type of components available in motion controllers.
  48092. * This is not the name of the component.
  48093. */
  48094. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48095. /**
  48096. * The state of a controller component
  48097. */
  48098. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48099. /**
  48100. * The schema of motion controller layout.
  48101. * No object will be initialized using this interface
  48102. * This is used just to define the profile.
  48103. */
  48104. export interface IMotionControllerLayout {
  48105. /**
  48106. * Path to load the assets. Usually relative to the base path
  48107. */
  48108. assetPath: string;
  48109. /**
  48110. * Available components (unsorted)
  48111. */
  48112. components: {
  48113. /**
  48114. * A map of component Ids
  48115. */
  48116. [componentId: string]: {
  48117. /**
  48118. * The type of input the component outputs
  48119. */
  48120. type: MotionControllerComponentType;
  48121. /**
  48122. * The indices of this component in the gamepad object
  48123. */
  48124. gamepadIndices: {
  48125. /**
  48126. * Index of button
  48127. */
  48128. button?: number;
  48129. /**
  48130. * If available, index of x-axis
  48131. */
  48132. xAxis?: number;
  48133. /**
  48134. * If available, index of y-axis
  48135. */
  48136. yAxis?: number;
  48137. };
  48138. /**
  48139. * The mesh's root node name
  48140. */
  48141. rootNodeName: string;
  48142. /**
  48143. * Animation definitions for this model
  48144. */
  48145. visualResponses: {
  48146. [stateKey: string]: {
  48147. /**
  48148. * What property will be animated
  48149. */
  48150. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48151. /**
  48152. * What states influence this visual response
  48153. */
  48154. states: MotionControllerComponentStateType[];
  48155. /**
  48156. * Type of animation - movement or visibility
  48157. */
  48158. valueNodeProperty: "transform" | "visibility";
  48159. /**
  48160. * Base node name to move. Its position will be calculated according to the min and max nodes
  48161. */
  48162. valueNodeName?: string;
  48163. /**
  48164. * Minimum movement node
  48165. */
  48166. minNodeName?: string;
  48167. /**
  48168. * Max movement node
  48169. */
  48170. maxNodeName?: string;
  48171. };
  48172. };
  48173. /**
  48174. * If touch enabled, what is the name of node to display user feedback
  48175. */
  48176. touchPointNodeName?: string;
  48177. };
  48178. };
  48179. /**
  48180. * Is it xr standard mapping or not
  48181. */
  48182. gamepadMapping: "" | "xr-standard";
  48183. /**
  48184. * Base root node of this entire model
  48185. */
  48186. rootNodeName: string;
  48187. /**
  48188. * Defines the main button component id
  48189. */
  48190. selectComponentId: string;
  48191. }
  48192. /**
  48193. * A definition for the layout map in the input profile
  48194. */
  48195. export interface IMotionControllerLayoutMap {
  48196. /**
  48197. * Layouts with handedness type as a key
  48198. */
  48199. [handedness: string]: IMotionControllerLayout;
  48200. }
  48201. /**
  48202. * The XR Input profile schema
  48203. * Profiles can be found here:
  48204. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48205. */
  48206. export interface IMotionControllerProfile {
  48207. /**
  48208. * fallback profiles for this profileId
  48209. */
  48210. fallbackProfileIds: string[];
  48211. /**
  48212. * The layout map, with handedness as key
  48213. */
  48214. layouts: IMotionControllerLayoutMap;
  48215. /**
  48216. * The id of this profile
  48217. * correlates to the profile(s) in the xrInput.profiles array
  48218. */
  48219. profileId: string;
  48220. }
  48221. /**
  48222. * A helper-interface for the 3 meshes needed for controller button animation
  48223. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48224. */
  48225. export interface IMotionControllerButtonMeshMap {
  48226. /**
  48227. * the mesh that defines the pressed value mesh position.
  48228. * This is used to find the max-position of this button
  48229. */
  48230. pressedMesh: AbstractMesh;
  48231. /**
  48232. * the mesh that defines the unpressed value mesh position.
  48233. * This is used to find the min (or initial) position of this button
  48234. */
  48235. unpressedMesh: AbstractMesh;
  48236. /**
  48237. * The mesh that will be changed when value changes
  48238. */
  48239. valueMesh: AbstractMesh;
  48240. }
  48241. /**
  48242. * A helper-interface for the 3 meshes needed for controller axis animation.
  48243. * This will be expanded when touchpad animations are fully supported
  48244. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48245. */
  48246. export interface IMotionControllerMeshMap {
  48247. /**
  48248. * the mesh that defines the maximum value mesh position.
  48249. */
  48250. maxMesh?: AbstractMesh;
  48251. /**
  48252. * the mesh that defines the minimum value mesh position.
  48253. */
  48254. minMesh?: AbstractMesh;
  48255. /**
  48256. * The mesh that will be changed when axis value changes
  48257. */
  48258. valueMesh?: AbstractMesh;
  48259. }
  48260. /**
  48261. * The elements needed for change-detection of the gamepad objects in motion controllers
  48262. */
  48263. export interface IMinimalMotionControllerObject {
  48264. /**
  48265. * Available axes of this controller
  48266. */
  48267. axes: number[];
  48268. /**
  48269. * An array of available buttons
  48270. */
  48271. buttons: Array<{
  48272. /**
  48273. * Value of the button/trigger
  48274. */
  48275. value: number;
  48276. /**
  48277. * If the button/trigger is currently touched
  48278. */
  48279. touched: boolean;
  48280. /**
  48281. * If the button/trigger is currently pressed
  48282. */
  48283. pressed: boolean;
  48284. }>;
  48285. /**
  48286. * EXPERIMENTAL haptic support.
  48287. */
  48288. hapticActuators?: Array<{
  48289. pulse: (value: number, duration: number) => Promise<boolean>;
  48290. }>;
  48291. }
  48292. /**
  48293. * An Abstract Motion controller
  48294. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48295. * Each component has an observable to check for changes in value and state
  48296. */
  48297. export abstract class WebXRAbstractMotionController implements IDisposable {
  48298. protected scene: Scene;
  48299. protected layout: IMotionControllerLayout;
  48300. /**
  48301. * The gamepad object correlating to this controller
  48302. */
  48303. gamepadObject: IMinimalMotionControllerObject;
  48304. /**
  48305. * handedness (left/right/none) of this controller
  48306. */
  48307. handedness: MotionControllerHandedness;
  48308. private _initComponent;
  48309. private _modelReady;
  48310. /**
  48311. * A map of components (WebXRControllerComponent) in this motion controller
  48312. * Components have a ComponentType and can also have both button and axis definitions
  48313. */
  48314. readonly components: {
  48315. [id: string]: WebXRControllerComponent;
  48316. };
  48317. /**
  48318. * Disable the model's animation. Can be set at any time.
  48319. */
  48320. disableAnimation: boolean;
  48321. /**
  48322. * Observers registered here will be triggered when the model of this controller is done loading
  48323. */
  48324. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48325. /**
  48326. * The profile id of this motion controller
  48327. */
  48328. abstract profileId: string;
  48329. /**
  48330. * The root mesh of the model. It is null if the model was not yet initialized
  48331. */
  48332. rootMesh: Nullable<AbstractMesh>;
  48333. /**
  48334. * constructs a new abstract motion controller
  48335. * @param scene the scene to which the model of the controller will be added
  48336. * @param layout The profile layout to load
  48337. * @param gamepadObject The gamepad object correlating to this controller
  48338. * @param handedness handedness (left/right/none) of this controller
  48339. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48340. */
  48341. constructor(scene: Scene, layout: IMotionControllerLayout,
  48342. /**
  48343. * The gamepad object correlating to this controller
  48344. */
  48345. gamepadObject: IMinimalMotionControllerObject,
  48346. /**
  48347. * handedness (left/right/none) of this controller
  48348. */
  48349. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48350. /**
  48351. * Dispose this controller, the model mesh and all its components
  48352. */
  48353. dispose(): void;
  48354. /**
  48355. * Returns all components of specific type
  48356. * @param type the type to search for
  48357. * @return an array of components with this type
  48358. */
  48359. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48360. /**
  48361. * get a component based an its component id as defined in layout.components
  48362. * @param id the id of the component
  48363. * @returns the component correlates to the id or undefined if not found
  48364. */
  48365. getComponent(id: string): WebXRControllerComponent;
  48366. /**
  48367. * Get the list of components available in this motion controller
  48368. * @returns an array of strings correlating to available components
  48369. */
  48370. getComponentIds(): string[];
  48371. /**
  48372. * Get the first component of specific type
  48373. * @param type type of component to find
  48374. * @return a controller component or null if not found
  48375. */
  48376. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48377. /**
  48378. * Get the main (Select) component of this controller as defined in the layout
  48379. * @returns the main component of this controller
  48380. */
  48381. getMainComponent(): WebXRControllerComponent;
  48382. /**
  48383. * Loads the model correlating to this controller
  48384. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48385. * @returns A promise fulfilled with the result of the model loading
  48386. */
  48387. loadModel(): Promise<boolean>;
  48388. /**
  48389. * Update this model using the current XRFrame
  48390. * @param xrFrame the current xr frame to use and update the model
  48391. */
  48392. updateFromXRFrame(xrFrame: XRFrame): void;
  48393. /**
  48394. * Backwards compatibility due to a deeply-integrated typo
  48395. */
  48396. get handness(): XREye;
  48397. /**
  48398. * Pulse (vibrate) this controller
  48399. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48400. * Consecutive calls to this function will cancel the last pulse call
  48401. *
  48402. * @param value the strength of the pulse in 0.0...1.0 range
  48403. * @param duration Duration of the pulse in milliseconds
  48404. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48405. * @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
  48406. */
  48407. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48408. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48409. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48410. /**
  48411. * Moves the axis on the controller mesh based on its current state
  48412. * @param axis the index of the axis
  48413. * @param axisValue the value of the axis which determines the meshes new position
  48414. * @hidden
  48415. */
  48416. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48417. /**
  48418. * Update the model itself with the current frame data
  48419. * @param xrFrame the frame to use for updating the model mesh
  48420. */
  48421. protected updateModel(xrFrame: XRFrame): void;
  48422. /**
  48423. * Get the filename and path for this controller's model
  48424. * @returns a map of filename and path
  48425. */
  48426. protected abstract _getFilenameAndPath(): {
  48427. filename: string;
  48428. path: string;
  48429. };
  48430. /**
  48431. * This function is called before the mesh is loaded. It checks for loading constraints.
  48432. * For example, this function can check if the GLB loader is available
  48433. * If this function returns false, the generic controller will be loaded instead
  48434. * @returns Is the client ready to load the mesh
  48435. */
  48436. protected abstract _getModelLoadingConstraints(): boolean;
  48437. /**
  48438. * This function will be called after the model was successfully loaded and can be used
  48439. * for mesh transformations before it is available for the user
  48440. * @param meshes the loaded meshes
  48441. */
  48442. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48443. /**
  48444. * Set the root mesh for this controller. Important for the WebXR controller class
  48445. * @param meshes the loaded meshes
  48446. */
  48447. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48448. /**
  48449. * A function executed each frame that updates the mesh (if needed)
  48450. * @param xrFrame the current xrFrame
  48451. */
  48452. protected abstract _updateModel(xrFrame: XRFrame): void;
  48453. private _getGenericFilenameAndPath;
  48454. private _getGenericParentMesh;
  48455. }
  48456. }
  48457. declare module BABYLON {
  48458. /**
  48459. * A generic trigger-only motion controller for WebXR
  48460. */
  48461. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48462. /**
  48463. * Static version of the profile id of this controller
  48464. */
  48465. static ProfileId: string;
  48466. profileId: string;
  48467. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48468. protected _getFilenameAndPath(): {
  48469. filename: string;
  48470. path: string;
  48471. };
  48472. protected _getModelLoadingConstraints(): boolean;
  48473. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48474. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48475. protected _updateModel(): void;
  48476. }
  48477. }
  48478. declare module BABYLON {
  48479. /**
  48480. * Class containing static functions to help procedurally build meshes
  48481. */
  48482. export class SphereBuilder {
  48483. /**
  48484. * Creates a sphere mesh
  48485. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48486. * * 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`)
  48487. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48488. * * 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
  48489. * * 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)
  48490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48491. * * 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
  48492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48493. * @param name defines the name of the mesh
  48494. * @param options defines the options used to create the mesh
  48495. * @param scene defines the hosting scene
  48496. * @returns the sphere mesh
  48497. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48498. */
  48499. static CreateSphere(name: string, options: {
  48500. segments?: number;
  48501. diameter?: number;
  48502. diameterX?: number;
  48503. diameterY?: number;
  48504. diameterZ?: number;
  48505. arc?: number;
  48506. slice?: number;
  48507. sideOrientation?: number;
  48508. frontUVs?: Vector4;
  48509. backUVs?: Vector4;
  48510. updatable?: boolean;
  48511. }, scene?: Nullable<Scene>): Mesh;
  48512. }
  48513. }
  48514. declare module BABYLON {
  48515. /**
  48516. * A profiled motion controller has its profile loaded from an online repository.
  48517. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48518. */
  48519. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48520. private _repositoryUrl;
  48521. private _buttonMeshMapping;
  48522. private _touchDots;
  48523. /**
  48524. * The profile ID of this controller. Will be populated when the controller initializes.
  48525. */
  48526. profileId: string;
  48527. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48528. dispose(): void;
  48529. protected _getFilenameAndPath(): {
  48530. filename: string;
  48531. path: string;
  48532. };
  48533. protected _getModelLoadingConstraints(): boolean;
  48534. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48535. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48536. protected _updateModel(_xrFrame: XRFrame): void;
  48537. }
  48538. }
  48539. declare module BABYLON {
  48540. /**
  48541. * A construction function type to create a new controller based on an xrInput object
  48542. */
  48543. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48544. /**
  48545. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48546. *
  48547. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48548. * it should be replaced with auto-loaded controllers.
  48549. *
  48550. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48551. */
  48552. export class WebXRMotionControllerManager {
  48553. private static _AvailableControllers;
  48554. private static _Fallbacks;
  48555. private static _ProfileLoadingPromises;
  48556. private static _ProfilesList;
  48557. /**
  48558. * The base URL of the online controller repository. Can be changed at any time.
  48559. */
  48560. static BaseRepositoryUrl: string;
  48561. /**
  48562. * Which repository gets priority - local or online
  48563. */
  48564. static PrioritizeOnlineRepository: boolean;
  48565. /**
  48566. * Use the online repository, or use only locally-defined controllers
  48567. */
  48568. static UseOnlineRepository: boolean;
  48569. /**
  48570. * Clear the cache used for profile loading and reload when requested again
  48571. */
  48572. static ClearProfilesCache(): void;
  48573. /**
  48574. * Register the default fallbacks.
  48575. * This function is called automatically when this file is imported.
  48576. */
  48577. static DefaultFallbacks(): void;
  48578. /**
  48579. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48580. * @param profileId the profile to which a fallback needs to be found
  48581. * @return an array with corresponding fallback profiles
  48582. */
  48583. static FindFallbackWithProfileId(profileId: string): string[];
  48584. /**
  48585. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48586. * The order of search:
  48587. *
  48588. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48589. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48590. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48591. * 4) return the generic trigger controller if none were found
  48592. *
  48593. * @param xrInput the xrInput to which a new controller is initialized
  48594. * @param scene the scene to which the model will be added
  48595. * @param forceProfile force a certain profile for this controller
  48596. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48597. */
  48598. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48599. /**
  48600. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48601. *
  48602. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48603. *
  48604. * @param type the profile type to register
  48605. * @param constructFunction the function to be called when loading this profile
  48606. */
  48607. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48608. /**
  48609. * Register a fallback to a specific profile.
  48610. * @param profileId the profileId that will receive the fallbacks
  48611. * @param fallbacks A list of fallback profiles
  48612. */
  48613. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48614. /**
  48615. * Will update the list of profiles available in the repository
  48616. * @return a promise that resolves to a map of profiles available online
  48617. */
  48618. static UpdateProfilesList(): Promise<{
  48619. [profile: string]: string;
  48620. }>;
  48621. private static _LoadProfileFromRepository;
  48622. private static _LoadProfilesFromAvailableControllers;
  48623. }
  48624. }
  48625. declare module BABYLON {
  48626. /**
  48627. * Configuration options for the WebXR controller creation
  48628. */
  48629. export interface IWebXRControllerOptions {
  48630. /**
  48631. * Should the controller mesh be animated when a user interacts with it
  48632. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48633. */
  48634. disableMotionControllerAnimation?: boolean;
  48635. /**
  48636. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48637. */
  48638. doNotLoadControllerMesh?: boolean;
  48639. /**
  48640. * Force a specific controller type for this controller.
  48641. * This can be used when creating your own profile or when testing different controllers
  48642. */
  48643. forceControllerProfile?: string;
  48644. /**
  48645. * Defines a rendering group ID for meshes that will be loaded.
  48646. * This is for the default controllers only.
  48647. */
  48648. renderingGroupId?: number;
  48649. }
  48650. /**
  48651. * Represents an XR controller
  48652. */
  48653. export class WebXRInputSource {
  48654. private _scene;
  48655. /** The underlying input source for the controller */
  48656. inputSource: XRInputSource;
  48657. private _options;
  48658. private _tmpVector;
  48659. private _uniqueId;
  48660. private _disposed;
  48661. /**
  48662. * 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
  48663. */
  48664. grip?: AbstractMesh;
  48665. /**
  48666. * If available, this is the gamepad object related to this controller.
  48667. * Using this object it is possible to get click events and trackpad changes of the
  48668. * webxr controller that is currently being used.
  48669. */
  48670. motionController?: WebXRAbstractMotionController;
  48671. /**
  48672. * Event that fires when the controller is removed/disposed.
  48673. * The object provided as event data is this controller, after associated assets were disposed.
  48674. * uniqueId is still available.
  48675. */
  48676. onDisposeObservable: Observable<WebXRInputSource>;
  48677. /**
  48678. * Will be triggered when the mesh associated with the motion controller is done loading.
  48679. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48680. * A shortened version of controller -> motion controller -> on mesh loaded.
  48681. */
  48682. onMeshLoadedObservable: Observable<AbstractMesh>;
  48683. /**
  48684. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48685. */
  48686. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48687. /**
  48688. * Pointer which can be used to select objects or attach a visible laser to
  48689. */
  48690. pointer: AbstractMesh;
  48691. /**
  48692. * Creates the input source object
  48693. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48694. * @param _scene the scene which the controller should be associated to
  48695. * @param inputSource the underlying input source for the controller
  48696. * @param _options options for this controller creation
  48697. */
  48698. constructor(_scene: Scene,
  48699. /** The underlying input source for the controller */
  48700. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48701. /**
  48702. * Get this controllers unique id
  48703. */
  48704. get uniqueId(): string;
  48705. /**
  48706. * Disposes of the object
  48707. */
  48708. dispose(): void;
  48709. /**
  48710. * Gets a world space ray coming from the pointer or grip
  48711. * @param result the resulting ray
  48712. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48713. */
  48714. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48715. /**
  48716. * Updates the controller pose based on the given XRFrame
  48717. * @param xrFrame xr frame to update the pose with
  48718. * @param referenceSpace reference space to use
  48719. */
  48720. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48721. }
  48722. }
  48723. declare module BABYLON {
  48724. /**
  48725. * The schema for initialization options of the XR Input class
  48726. */
  48727. export interface IWebXRInputOptions {
  48728. /**
  48729. * If set to true no model will be automatically loaded
  48730. */
  48731. doNotLoadControllerMeshes?: boolean;
  48732. /**
  48733. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48734. * If not found, the xr input profile data will be used.
  48735. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48736. */
  48737. forceInputProfile?: string;
  48738. /**
  48739. * Do not send a request to the controller repository to load the profile.
  48740. *
  48741. * Instead, use the controllers available in babylon itself.
  48742. */
  48743. disableOnlineControllerRepository?: boolean;
  48744. /**
  48745. * A custom URL for the controllers repository
  48746. */
  48747. customControllersRepositoryURL?: string;
  48748. /**
  48749. * Should the controller model's components not move according to the user input
  48750. */
  48751. disableControllerAnimation?: boolean;
  48752. /**
  48753. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48754. */
  48755. controllerOptions?: IWebXRControllerOptions;
  48756. }
  48757. /**
  48758. * XR input used to track XR inputs such as controllers/rays
  48759. */
  48760. export class WebXRInput implements IDisposable {
  48761. /**
  48762. * the xr session manager for this session
  48763. */
  48764. xrSessionManager: WebXRSessionManager;
  48765. /**
  48766. * the WebXR camera for this session. Mainly used for teleportation
  48767. */
  48768. xrCamera: WebXRCamera;
  48769. private readonly options;
  48770. /**
  48771. * XR controllers being tracked
  48772. */
  48773. controllers: Array<WebXRInputSource>;
  48774. private _frameObserver;
  48775. private _sessionEndedObserver;
  48776. private _sessionInitObserver;
  48777. /**
  48778. * Event when a controller has been connected/added
  48779. */
  48780. onControllerAddedObservable: Observable<WebXRInputSource>;
  48781. /**
  48782. * Event when a controller has been removed/disconnected
  48783. */
  48784. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48785. /**
  48786. * Initializes the WebXRInput
  48787. * @param xrSessionManager the xr session manager for this session
  48788. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48789. * @param options = initialization options for this xr input
  48790. */
  48791. constructor(
  48792. /**
  48793. * the xr session manager for this session
  48794. */
  48795. xrSessionManager: WebXRSessionManager,
  48796. /**
  48797. * the WebXR camera for this session. Mainly used for teleportation
  48798. */
  48799. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48800. private _onInputSourcesChange;
  48801. private _addAndRemoveControllers;
  48802. /**
  48803. * Disposes of the object
  48804. */
  48805. dispose(): void;
  48806. }
  48807. }
  48808. declare module BABYLON {
  48809. /**
  48810. * This is the base class for all WebXR features.
  48811. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48812. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48813. */
  48814. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48815. protected _xrSessionManager: WebXRSessionManager;
  48816. private _attached;
  48817. private _removeOnDetach;
  48818. /**
  48819. * Is this feature disposed?
  48820. */
  48821. isDisposed: boolean;
  48822. /**
  48823. * Should auto-attach be disabled?
  48824. */
  48825. disableAutoAttach: boolean;
  48826. /**
  48827. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48828. */
  48829. xrNativeFeatureName: string;
  48830. /**
  48831. * Construct a new (abstract) WebXR feature
  48832. * @param _xrSessionManager the xr session manager for this feature
  48833. */
  48834. constructor(_xrSessionManager: WebXRSessionManager);
  48835. /**
  48836. * Is this feature attached
  48837. */
  48838. get attached(): boolean;
  48839. /**
  48840. * attach this feature
  48841. *
  48842. * @param force should attachment be forced (even when already attached)
  48843. * @returns true if successful, false is failed or already attached
  48844. */
  48845. attach(force?: boolean): boolean;
  48846. /**
  48847. * detach this feature.
  48848. *
  48849. * @returns true if successful, false if failed or already detached
  48850. */
  48851. detach(): boolean;
  48852. /**
  48853. * Dispose this feature and all of the resources attached
  48854. */
  48855. dispose(): void;
  48856. /**
  48857. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48858. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48859. *
  48860. * @returns whether or not the feature is compatible in this environment
  48861. */
  48862. isCompatible(): boolean;
  48863. /**
  48864. * This is used to register callbacks that will automatically be removed when detach is called.
  48865. * @param observable the observable to which the observer will be attached
  48866. * @param callback the callback to register
  48867. */
  48868. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48869. /**
  48870. * Code in this function will be executed on each xrFrame received from the browser.
  48871. * This function will not execute after the feature is detached.
  48872. * @param _xrFrame the current frame
  48873. */
  48874. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48875. }
  48876. }
  48877. declare module BABYLON {
  48878. /**
  48879. * Renders a layer on top of an existing scene
  48880. */
  48881. export class UtilityLayerRenderer implements IDisposable {
  48882. /** the original scene that will be rendered on top of */
  48883. originalScene: Scene;
  48884. private _pointerCaptures;
  48885. private _lastPointerEvents;
  48886. private static _DefaultUtilityLayer;
  48887. private static _DefaultKeepDepthUtilityLayer;
  48888. private _sharedGizmoLight;
  48889. private _renderCamera;
  48890. /**
  48891. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48892. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48893. * @returns the camera that is used when rendering the utility layer
  48894. */
  48895. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48896. /**
  48897. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48898. * @param cam the camera that should be used when rendering the utility layer
  48899. */
  48900. setRenderCamera(cam: Nullable<Camera>): void;
  48901. /**
  48902. * @hidden
  48903. * Light which used by gizmos to get light shading
  48904. */
  48905. _getSharedGizmoLight(): HemisphericLight;
  48906. /**
  48907. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48908. */
  48909. pickUtilitySceneFirst: boolean;
  48910. /**
  48911. * 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)
  48912. */
  48913. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48914. /**
  48915. * 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)
  48916. */
  48917. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48918. /**
  48919. * The scene that is rendered on top of the original scene
  48920. */
  48921. utilityLayerScene: Scene;
  48922. /**
  48923. * If the utility layer should automatically be rendered on top of existing scene
  48924. */
  48925. shouldRender: boolean;
  48926. /**
  48927. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48928. */
  48929. onlyCheckPointerDownEvents: boolean;
  48930. /**
  48931. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48932. */
  48933. processAllEvents: boolean;
  48934. /**
  48935. * Observable raised when the pointer move from the utility layer scene to the main scene
  48936. */
  48937. onPointerOutObservable: Observable<number>;
  48938. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48939. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48940. private _afterRenderObserver;
  48941. private _sceneDisposeObserver;
  48942. private _originalPointerObserver;
  48943. /**
  48944. * Instantiates a UtilityLayerRenderer
  48945. * @param originalScene the original scene that will be rendered on top of
  48946. * @param handleEvents boolean indicating if the utility layer should handle events
  48947. */
  48948. constructor(
  48949. /** the original scene that will be rendered on top of */
  48950. originalScene: Scene, handleEvents?: boolean);
  48951. private _notifyObservers;
  48952. /**
  48953. * Renders the utility layers scene on top of the original scene
  48954. */
  48955. render(): void;
  48956. /**
  48957. * Disposes of the renderer
  48958. */
  48959. dispose(): void;
  48960. private _updateCamera;
  48961. }
  48962. }
  48963. declare module BABYLON {
  48964. /**
  48965. * Options interface for the pointer selection module
  48966. */
  48967. export interface IWebXRControllerPointerSelectionOptions {
  48968. /**
  48969. * if provided, this scene will be used to render meshes.
  48970. */
  48971. customUtilityLayerScene?: Scene;
  48972. /**
  48973. * 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)
  48974. * If not disabled, the last picked point will be used to execute a pointer up event
  48975. * If disabled, pointer up event will be triggered right after the pointer down event.
  48976. * Used in screen and gaze target ray mode only
  48977. */
  48978. disablePointerUpOnTouchOut: boolean;
  48979. /**
  48980. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48981. */
  48982. forceGazeMode: boolean;
  48983. /**
  48984. * 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
  48985. * to start a new countdown to the pointer down event.
  48986. * Defaults to 1.
  48987. */
  48988. gazeModePointerMovedFactor?: number;
  48989. /**
  48990. * Different button type to use instead of the main component
  48991. */
  48992. overrideButtonId?: string;
  48993. /**
  48994. * use this rendering group id for the meshes (optional)
  48995. */
  48996. renderingGroupId?: number;
  48997. /**
  48998. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48999. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49000. * 3000 means 3 seconds between pointing at something and selecting it
  49001. */
  49002. timeToSelect?: number;
  49003. /**
  49004. * Should meshes created here be added to a utility layer or the main scene
  49005. */
  49006. useUtilityLayer?: boolean;
  49007. /**
  49008. * Optional WebXR camera to be used for gaze selection
  49009. */
  49010. gazeCamera?: WebXRCamera;
  49011. /**
  49012. * the xr input to use with this pointer selection
  49013. */
  49014. xrInput: WebXRInput;
  49015. }
  49016. /**
  49017. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49018. */
  49019. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49020. private readonly _options;
  49021. private static _idCounter;
  49022. private _attachController;
  49023. private _controllers;
  49024. private _scene;
  49025. private _tmpVectorForPickCompare;
  49026. /**
  49027. * The module's name
  49028. */
  49029. static readonly Name: string;
  49030. /**
  49031. * The (Babylon) version of this module.
  49032. * This is an integer representing the implementation version.
  49033. * This number does not correspond to the WebXR specs version
  49034. */
  49035. static readonly Version: number;
  49036. /**
  49037. * Disable lighting on the laser pointer (so it will always be visible)
  49038. */
  49039. disablePointerLighting: boolean;
  49040. /**
  49041. * Disable lighting on the selection mesh (so it will always be visible)
  49042. */
  49043. disableSelectionMeshLighting: boolean;
  49044. /**
  49045. * Should the laser pointer be displayed
  49046. */
  49047. displayLaserPointer: boolean;
  49048. /**
  49049. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49050. */
  49051. displaySelectionMesh: boolean;
  49052. /**
  49053. * This color will be set to the laser pointer when selection is triggered
  49054. */
  49055. laserPointerPickedColor: Color3;
  49056. /**
  49057. * Default color of the laser pointer
  49058. */
  49059. laserPointerDefaultColor: Color3;
  49060. /**
  49061. * default color of the selection ring
  49062. */
  49063. selectionMeshDefaultColor: Color3;
  49064. /**
  49065. * This color will be applied to the selection ring when selection is triggered
  49066. */
  49067. selectionMeshPickedColor: Color3;
  49068. /**
  49069. * Optional filter to be used for ray selection. This predicate shares behavior with
  49070. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49071. */
  49072. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49073. /**
  49074. * constructs a new background remover module
  49075. * @param _xrSessionManager the session manager for this module
  49076. * @param _options read-only options to be used in this module
  49077. */
  49078. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49079. /**
  49080. * attach this feature
  49081. * Will usually be called by the features manager
  49082. *
  49083. * @returns true if successful.
  49084. */
  49085. attach(): boolean;
  49086. /**
  49087. * detach this feature.
  49088. * Will usually be called by the features manager
  49089. *
  49090. * @returns true if successful.
  49091. */
  49092. detach(): boolean;
  49093. /**
  49094. * Will get the mesh under a specific pointer.
  49095. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49096. * @param controllerId the controllerId to check
  49097. * @returns The mesh under pointer or null if no mesh is under the pointer
  49098. */
  49099. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49100. /**
  49101. * Get the xr controller that correlates to the pointer id in the pointer event
  49102. *
  49103. * @param id the pointer id to search for
  49104. * @returns the controller that correlates to this id or null if not found
  49105. */
  49106. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49107. protected _onXRFrame(_xrFrame: XRFrame): void;
  49108. private _attachGazeMode;
  49109. private _attachScreenRayMode;
  49110. private _attachTrackedPointerRayMode;
  49111. private _convertNormalToDirectionOfRay;
  49112. private _detachController;
  49113. private _generateNewMeshPair;
  49114. private _pickingMoved;
  49115. private _updatePointerDistance;
  49116. /** @hidden */
  49117. get lasterPointerDefaultColor(): Color3;
  49118. }
  49119. }
  49120. declare module BABYLON {
  49121. /**
  49122. * Button which can be used to enter a different mode of XR
  49123. */
  49124. export class WebXREnterExitUIButton {
  49125. /** button element */
  49126. element: HTMLElement;
  49127. /** XR initialization options for the button */
  49128. sessionMode: XRSessionMode;
  49129. /** Reference space type */
  49130. referenceSpaceType: XRReferenceSpaceType;
  49131. /**
  49132. * Creates a WebXREnterExitUIButton
  49133. * @param element button element
  49134. * @param sessionMode XR initialization session mode
  49135. * @param referenceSpaceType the type of reference space to be used
  49136. */
  49137. constructor(
  49138. /** button element */
  49139. element: HTMLElement,
  49140. /** XR initialization options for the button */
  49141. sessionMode: XRSessionMode,
  49142. /** Reference space type */
  49143. referenceSpaceType: XRReferenceSpaceType);
  49144. /**
  49145. * Extendable function which can be used to update the button's visuals when the state changes
  49146. * @param activeButton the current active button in the UI
  49147. */
  49148. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49149. }
  49150. /**
  49151. * Options to create the webXR UI
  49152. */
  49153. export class WebXREnterExitUIOptions {
  49154. /**
  49155. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49156. */
  49157. customButtons?: Array<WebXREnterExitUIButton>;
  49158. /**
  49159. * A reference space type to use when creating the default button.
  49160. * Default is local-floor
  49161. */
  49162. referenceSpaceType?: XRReferenceSpaceType;
  49163. /**
  49164. * Context to enter xr with
  49165. */
  49166. renderTarget?: Nullable<WebXRRenderTarget>;
  49167. /**
  49168. * A session mode to use when creating the default button.
  49169. * Default is immersive-vr
  49170. */
  49171. sessionMode?: XRSessionMode;
  49172. /**
  49173. * A list of optional features to init the session with
  49174. */
  49175. optionalFeatures?: string[];
  49176. /**
  49177. * A list of optional features to init the session with
  49178. */
  49179. requiredFeatures?: string[];
  49180. }
  49181. /**
  49182. * UI to allow the user to enter/exit XR mode
  49183. */
  49184. export class WebXREnterExitUI implements IDisposable {
  49185. private scene;
  49186. /** version of the options passed to this UI */
  49187. options: WebXREnterExitUIOptions;
  49188. private _activeButton;
  49189. private _buttons;
  49190. /**
  49191. * The HTML Div Element to which buttons are added.
  49192. */
  49193. readonly overlay: HTMLDivElement;
  49194. /**
  49195. * Fired every time the active button is changed.
  49196. *
  49197. * When xr is entered via a button that launches xr that button will be the callback parameter
  49198. *
  49199. * When exiting xr the callback parameter will be null)
  49200. */
  49201. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49202. /**
  49203. *
  49204. * @param scene babylon scene object to use
  49205. * @param options (read-only) version of the options passed to this UI
  49206. */
  49207. private constructor();
  49208. /**
  49209. * Creates UI to allow the user to enter/exit XR mode
  49210. * @param scene the scene to add the ui to
  49211. * @param helper the xr experience helper to enter/exit xr with
  49212. * @param options options to configure the UI
  49213. * @returns the created ui
  49214. */
  49215. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49216. /**
  49217. * Disposes of the XR UI component
  49218. */
  49219. dispose(): void;
  49220. private _updateButtons;
  49221. }
  49222. }
  49223. declare module BABYLON {
  49224. /**
  49225. * Class containing static functions to help procedurally build meshes
  49226. */
  49227. export class LinesBuilder {
  49228. /**
  49229. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49230. * * 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
  49231. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49232. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49233. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49234. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49235. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49236. * * 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
  49237. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49240. * @param name defines the name of the new line system
  49241. * @param options defines the options used to create the line system
  49242. * @param scene defines the hosting scene
  49243. * @returns a new line system mesh
  49244. */
  49245. static CreateLineSystem(name: string, options: {
  49246. lines: Vector3[][];
  49247. updatable?: boolean;
  49248. instance?: Nullable<LinesMesh>;
  49249. colors?: Nullable<Color4[][]>;
  49250. useVertexAlpha?: boolean;
  49251. }, scene: Nullable<Scene>): LinesMesh;
  49252. /**
  49253. * Creates a line mesh
  49254. * 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
  49255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49256. * * The parameter `points` is an array successive Vector3
  49257. * * 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
  49258. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49259. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49260. * * When updating an instance, remember that only point positions can change, not the number of points
  49261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49263. * @param name defines the name of the new line system
  49264. * @param options defines the options used to create the line system
  49265. * @param scene defines the hosting scene
  49266. * @returns a new line mesh
  49267. */
  49268. static CreateLines(name: string, options: {
  49269. points: Vector3[];
  49270. updatable?: boolean;
  49271. instance?: Nullable<LinesMesh>;
  49272. colors?: Color4[];
  49273. useVertexAlpha?: boolean;
  49274. }, scene?: Nullable<Scene>): LinesMesh;
  49275. /**
  49276. * Creates a dashed line mesh
  49277. * * 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
  49278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49279. * * The parameter `points` is an array successive Vector3
  49280. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49281. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49282. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49283. * * 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
  49284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49285. * * When updating an instance, remember that only point positions can change, not the number of points
  49286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49287. * @param name defines the name of the mesh
  49288. * @param options defines the options used to create the mesh
  49289. * @param scene defines the hosting scene
  49290. * @returns the dashed line mesh
  49291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49292. */
  49293. static CreateDashedLines(name: string, options: {
  49294. points: Vector3[];
  49295. dashSize?: number;
  49296. gapSize?: number;
  49297. dashNb?: number;
  49298. updatable?: boolean;
  49299. instance?: LinesMesh;
  49300. useVertexAlpha?: boolean;
  49301. }, scene?: Nullable<Scene>): LinesMesh;
  49302. }
  49303. }
  49304. declare module BABYLON {
  49305. /**
  49306. * Construction options for a timer
  49307. */
  49308. export interface ITimerOptions<T> {
  49309. /**
  49310. * Time-to-end
  49311. */
  49312. timeout: number;
  49313. /**
  49314. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49315. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49316. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49317. */
  49318. contextObservable: Observable<T>;
  49319. /**
  49320. * Optional parameters when adding an observer to the observable
  49321. */
  49322. observableParameters?: {
  49323. mask?: number;
  49324. insertFirst?: boolean;
  49325. scope?: any;
  49326. };
  49327. /**
  49328. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49329. */
  49330. breakCondition?: (data?: ITimerData<T>) => boolean;
  49331. /**
  49332. * Will be triggered when the time condition has met
  49333. */
  49334. onEnded?: (data: ITimerData<any>) => void;
  49335. /**
  49336. * Will be triggered when the break condition has met (prematurely ended)
  49337. */
  49338. onAborted?: (data: ITimerData<any>) => void;
  49339. /**
  49340. * Optional function to execute on each tick (or count)
  49341. */
  49342. onTick?: (data: ITimerData<any>) => void;
  49343. }
  49344. /**
  49345. * An interface defining the data sent by the timer
  49346. */
  49347. export interface ITimerData<T> {
  49348. /**
  49349. * When did it start
  49350. */
  49351. startTime: number;
  49352. /**
  49353. * Time now
  49354. */
  49355. currentTime: number;
  49356. /**
  49357. * Time passed since started
  49358. */
  49359. deltaTime: number;
  49360. /**
  49361. * How much is completed, in [0.0...1.0].
  49362. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49363. */
  49364. completeRate: number;
  49365. /**
  49366. * What the registered observable sent in the last count
  49367. */
  49368. payload: T;
  49369. }
  49370. /**
  49371. * The current state of the timer
  49372. */
  49373. export enum TimerState {
  49374. /**
  49375. * Timer initialized, not yet started
  49376. */
  49377. INIT = 0,
  49378. /**
  49379. * Timer started and counting
  49380. */
  49381. STARTED = 1,
  49382. /**
  49383. * Timer ended (whether aborted or time reached)
  49384. */
  49385. ENDED = 2
  49386. }
  49387. /**
  49388. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49389. *
  49390. * @param options options with which to initialize this timer
  49391. */
  49392. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49393. /**
  49394. * An advanced implementation of a timer class
  49395. */
  49396. export class AdvancedTimer<T = any> implements IDisposable {
  49397. /**
  49398. * Will notify each time the timer calculates the remaining time
  49399. */
  49400. onEachCountObservable: Observable<ITimerData<T>>;
  49401. /**
  49402. * Will trigger when the timer was aborted due to the break condition
  49403. */
  49404. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49405. /**
  49406. * Will trigger when the timer ended successfully
  49407. */
  49408. onTimerEndedObservable: Observable<ITimerData<T>>;
  49409. /**
  49410. * Will trigger when the timer state has changed
  49411. */
  49412. onStateChangedObservable: Observable<TimerState>;
  49413. private _observer;
  49414. private _contextObservable;
  49415. private _observableParameters;
  49416. private _startTime;
  49417. private _timer;
  49418. private _state;
  49419. private _breakCondition;
  49420. private _timeToEnd;
  49421. private _breakOnNextTick;
  49422. /**
  49423. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49424. * @param options construction options for this advanced timer
  49425. */
  49426. constructor(options: ITimerOptions<T>);
  49427. /**
  49428. * set a breaking condition for this timer. Default is to never break during count
  49429. * @param predicate the new break condition. Returns true to break, false otherwise
  49430. */
  49431. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49432. /**
  49433. * Reset ALL associated observables in this advanced timer
  49434. */
  49435. clearObservables(): void;
  49436. /**
  49437. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49438. *
  49439. * @param timeToEnd how much time to measure until timer ended
  49440. */
  49441. start(timeToEnd?: number): void;
  49442. /**
  49443. * Will force a stop on the next tick.
  49444. */
  49445. stop(): void;
  49446. /**
  49447. * Dispose this timer, clearing all resources
  49448. */
  49449. dispose(): void;
  49450. private _setState;
  49451. private _tick;
  49452. private _stop;
  49453. }
  49454. }
  49455. declare module BABYLON {
  49456. /**
  49457. * The options container for the teleportation module
  49458. */
  49459. export interface IWebXRTeleportationOptions {
  49460. /**
  49461. * if provided, this scene will be used to render meshes.
  49462. */
  49463. customUtilityLayerScene?: Scene;
  49464. /**
  49465. * Values to configure the default target mesh
  49466. */
  49467. defaultTargetMeshOptions?: {
  49468. /**
  49469. * Fill color of the teleportation area
  49470. */
  49471. teleportationFillColor?: string;
  49472. /**
  49473. * Border color for the teleportation area
  49474. */
  49475. teleportationBorderColor?: string;
  49476. /**
  49477. * Disable the mesh's animation sequence
  49478. */
  49479. disableAnimation?: boolean;
  49480. /**
  49481. * Disable lighting on the material or the ring and arrow
  49482. */
  49483. disableLighting?: boolean;
  49484. /**
  49485. * Override the default material of the torus and arrow
  49486. */
  49487. torusArrowMaterial?: Material;
  49488. };
  49489. /**
  49490. * A list of meshes to use as floor meshes.
  49491. * Meshes can be added and removed after initializing the feature using the
  49492. * addFloorMesh and removeFloorMesh functions
  49493. * If empty, rotation will still work
  49494. */
  49495. floorMeshes?: AbstractMesh[];
  49496. /**
  49497. * use this rendering group id for the meshes (optional)
  49498. */
  49499. renderingGroupId?: number;
  49500. /**
  49501. * Should teleportation move only to snap points
  49502. */
  49503. snapPointsOnly?: boolean;
  49504. /**
  49505. * An array of points to which the teleportation will snap to.
  49506. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49507. */
  49508. snapPositions?: Vector3[];
  49509. /**
  49510. * How close should the teleportation ray be in order to snap to position.
  49511. * Default to 0.8 units (meters)
  49512. */
  49513. snapToPositionRadius?: number;
  49514. /**
  49515. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49516. * If you want to support rotation, make sure your mesh has a direction indicator.
  49517. *
  49518. * When left untouched, the default mesh will be initialized.
  49519. */
  49520. teleportationTargetMesh?: AbstractMesh;
  49521. /**
  49522. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49523. */
  49524. timeToTeleport?: number;
  49525. /**
  49526. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49527. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49528. */
  49529. useMainComponentOnly?: boolean;
  49530. /**
  49531. * Should meshes created here be added to a utility layer or the main scene
  49532. */
  49533. useUtilityLayer?: boolean;
  49534. /**
  49535. * Babylon XR Input class for controller
  49536. */
  49537. xrInput: WebXRInput;
  49538. /**
  49539. * Meshes that the teleportation ray cannot go through
  49540. */
  49541. pickBlockerMeshes?: AbstractMesh[];
  49542. }
  49543. /**
  49544. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49545. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49546. * the input of the attached controllers.
  49547. */
  49548. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49549. private _options;
  49550. private _controllers;
  49551. private _currentTeleportationControllerId;
  49552. private _floorMeshes;
  49553. private _quadraticBezierCurve;
  49554. private _selectionFeature;
  49555. private _snapToPositions;
  49556. private _snappedToPoint;
  49557. private _teleportationRingMaterial?;
  49558. private _tmpRay;
  49559. private _tmpVector;
  49560. private _tmpQuaternion;
  49561. /**
  49562. * The module's name
  49563. */
  49564. static readonly Name: string;
  49565. /**
  49566. * The (Babylon) version of this module.
  49567. * This is an integer representing the implementation version.
  49568. * This number does not correspond to the webxr specs version
  49569. */
  49570. static readonly Version: number;
  49571. /**
  49572. * Is movement backwards enabled
  49573. */
  49574. backwardsMovementEnabled: boolean;
  49575. /**
  49576. * Distance to travel when moving backwards
  49577. */
  49578. backwardsTeleportationDistance: number;
  49579. /**
  49580. * The distance from the user to the inspection point in the direction of the controller
  49581. * A higher number will allow the user to move further
  49582. * defaults to 5 (meters, in xr units)
  49583. */
  49584. parabolicCheckRadius: number;
  49585. /**
  49586. * Should the module support parabolic ray on top of direct ray
  49587. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49588. * Very helpful when moving between floors / different heights
  49589. */
  49590. parabolicRayEnabled: boolean;
  49591. /**
  49592. * How much rotation should be applied when rotating right and left
  49593. */
  49594. rotationAngle: number;
  49595. /**
  49596. * Is rotation enabled when moving forward?
  49597. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49598. */
  49599. rotationEnabled: boolean;
  49600. /**
  49601. * constructs a new anchor system
  49602. * @param _xrSessionManager an instance of WebXRSessionManager
  49603. * @param _options configuration object for this feature
  49604. */
  49605. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49606. /**
  49607. * Get the snapPointsOnly flag
  49608. */
  49609. get snapPointsOnly(): boolean;
  49610. /**
  49611. * Sets the snapPointsOnly flag
  49612. * @param snapToPoints should teleportation be exclusively to snap points
  49613. */
  49614. set snapPointsOnly(snapToPoints: boolean);
  49615. /**
  49616. * Add a new mesh to the floor meshes array
  49617. * @param mesh the mesh to use as floor mesh
  49618. */
  49619. addFloorMesh(mesh: AbstractMesh): void;
  49620. /**
  49621. * Add a new snap-to point to fix teleportation to this position
  49622. * @param newSnapPoint The new Snap-To point
  49623. */
  49624. addSnapPoint(newSnapPoint: Vector3): void;
  49625. attach(): boolean;
  49626. detach(): boolean;
  49627. dispose(): void;
  49628. /**
  49629. * Remove a mesh from the floor meshes array
  49630. * @param mesh the mesh to remove
  49631. */
  49632. removeFloorMesh(mesh: AbstractMesh): void;
  49633. /**
  49634. * Remove a mesh from the floor meshes array using its name
  49635. * @param name the mesh name to remove
  49636. */
  49637. removeFloorMeshByName(name: string): void;
  49638. /**
  49639. * 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
  49640. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49641. * @returns was the point found and removed or not
  49642. */
  49643. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49644. /**
  49645. * This function sets a selection feature that will be disabled when
  49646. * the forward ray is shown and will be reattached when hidden.
  49647. * This is used to remove the selection rays when moving.
  49648. * @param selectionFeature the feature to disable when forward movement is enabled
  49649. */
  49650. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49651. protected _onXRFrame(_xrFrame: XRFrame): void;
  49652. private _attachController;
  49653. private _createDefaultTargetMesh;
  49654. private _detachController;
  49655. private _findClosestSnapPointWithRadius;
  49656. private _setTargetMeshPosition;
  49657. private _setTargetMeshVisibility;
  49658. private _showParabolicPath;
  49659. private _teleportForward;
  49660. }
  49661. }
  49662. declare module BABYLON {
  49663. /**
  49664. * Options for the default xr helper
  49665. */
  49666. export class WebXRDefaultExperienceOptions {
  49667. /**
  49668. * Enable or disable default UI to enter XR
  49669. */
  49670. disableDefaultUI?: boolean;
  49671. /**
  49672. * Should teleportation not initialize. defaults to false.
  49673. */
  49674. disableTeleportation?: boolean;
  49675. /**
  49676. * Floor meshes that will be used for teleport
  49677. */
  49678. floorMeshes?: Array<AbstractMesh>;
  49679. /**
  49680. * If set to true, the first frame will not be used to reset position
  49681. * The first frame is mainly used when copying transformation from the old camera
  49682. * Mainly used in AR
  49683. */
  49684. ignoreNativeCameraTransformation?: boolean;
  49685. /**
  49686. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49687. */
  49688. inputOptions?: IWebXRInputOptions;
  49689. /**
  49690. * optional configuration for the output canvas
  49691. */
  49692. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49693. /**
  49694. * optional UI options. This can be used among other to change session mode and reference space type
  49695. */
  49696. uiOptions?: WebXREnterExitUIOptions;
  49697. /**
  49698. * When loading teleportation and pointer select, use stable versions instead of latest.
  49699. */
  49700. useStablePlugins?: boolean;
  49701. /**
  49702. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49703. */
  49704. renderingGroupId?: number;
  49705. /**
  49706. * A list of optional features to init the session with
  49707. * If set to true, all features we support will be added
  49708. */
  49709. optionalFeatures?: boolean | string[];
  49710. }
  49711. /**
  49712. * Default experience which provides a similar setup to the previous webVRExperience
  49713. */
  49714. export class WebXRDefaultExperience {
  49715. /**
  49716. * Base experience
  49717. */
  49718. baseExperience: WebXRExperienceHelper;
  49719. /**
  49720. * Enables ui for entering/exiting xr
  49721. */
  49722. enterExitUI: WebXREnterExitUI;
  49723. /**
  49724. * Input experience extension
  49725. */
  49726. input: WebXRInput;
  49727. /**
  49728. * Enables laser pointer and selection
  49729. */
  49730. pointerSelection: WebXRControllerPointerSelection;
  49731. /**
  49732. * Default target xr should render to
  49733. */
  49734. renderTarget: WebXRRenderTarget;
  49735. /**
  49736. * Enables teleportation
  49737. */
  49738. teleportation: WebXRMotionControllerTeleportation;
  49739. private constructor();
  49740. /**
  49741. * Creates the default xr experience
  49742. * @param scene scene
  49743. * @param options options for basic configuration
  49744. * @returns resulting WebXRDefaultExperience
  49745. */
  49746. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49747. /**
  49748. * DIsposes of the experience helper
  49749. */
  49750. dispose(): void;
  49751. }
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * Options to modify the vr teleportation behavior.
  49756. */
  49757. export interface VRTeleportationOptions {
  49758. /**
  49759. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49760. */
  49761. floorMeshName?: string;
  49762. /**
  49763. * A list of meshes to be used as the teleportation floor. (default: empty)
  49764. */
  49765. floorMeshes?: Mesh[];
  49766. /**
  49767. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49768. */
  49769. teleportationMode?: number;
  49770. /**
  49771. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49772. */
  49773. teleportationTime?: number;
  49774. /**
  49775. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49776. */
  49777. teleportationSpeed?: number;
  49778. /**
  49779. * The easing function used in the animation or null for Linear. (default CircleEase)
  49780. */
  49781. easingFunction?: EasingFunction;
  49782. }
  49783. /**
  49784. * Options to modify the vr experience helper's behavior.
  49785. */
  49786. export interface VRExperienceHelperOptions extends WebVROptions {
  49787. /**
  49788. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49789. */
  49790. createDeviceOrientationCamera?: boolean;
  49791. /**
  49792. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49793. */
  49794. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49795. /**
  49796. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49797. */
  49798. laserToggle?: boolean;
  49799. /**
  49800. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49801. */
  49802. floorMeshes?: Mesh[];
  49803. /**
  49804. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49805. */
  49806. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49807. /**
  49808. * Defines if WebXR should be used instead of WebVR (if available)
  49809. */
  49810. useXR?: boolean;
  49811. }
  49812. /**
  49813. * Event containing information after VR has been entered
  49814. */
  49815. export class OnAfterEnteringVRObservableEvent {
  49816. /**
  49817. * If entering vr was successful
  49818. */
  49819. success: boolean;
  49820. }
  49821. /**
  49822. * Helps to quickly add VR support to an existing scene.
  49823. * See https://doc.babylonjs.com/how_to/webvr_helper
  49824. */
  49825. export class VRExperienceHelper {
  49826. /** Options to modify the vr experience helper's behavior. */
  49827. webVROptions: VRExperienceHelperOptions;
  49828. private _scene;
  49829. private _position;
  49830. private _btnVR;
  49831. private _btnVRDisplayed;
  49832. private _webVRsupported;
  49833. private _webVRready;
  49834. private _webVRrequesting;
  49835. private _webVRpresenting;
  49836. private _hasEnteredVR;
  49837. private _fullscreenVRpresenting;
  49838. private _inputElement;
  49839. private _webVRCamera;
  49840. private _vrDeviceOrientationCamera;
  49841. private _deviceOrientationCamera;
  49842. private _existingCamera;
  49843. private _onKeyDown;
  49844. private _onVrDisplayPresentChange;
  49845. private _onVRDisplayChanged;
  49846. private _onVRRequestPresentStart;
  49847. private _onVRRequestPresentComplete;
  49848. /**
  49849. * 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)
  49850. */
  49851. enableGazeEvenWhenNoPointerLock: boolean;
  49852. /**
  49853. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49854. */
  49855. exitVROnDoubleTap: boolean;
  49856. /**
  49857. * Observable raised right before entering VR.
  49858. */
  49859. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49860. /**
  49861. * Observable raised when entering VR has completed.
  49862. */
  49863. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49864. /**
  49865. * Observable raised when exiting VR.
  49866. */
  49867. onExitingVRObservable: Observable<VRExperienceHelper>;
  49868. /**
  49869. * Observable raised when controller mesh is loaded.
  49870. */
  49871. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49872. /** Return this.onEnteringVRObservable
  49873. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49874. */
  49875. get onEnteringVR(): Observable<VRExperienceHelper>;
  49876. /** Return this.onExitingVRObservable
  49877. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49878. */
  49879. get onExitingVR(): Observable<VRExperienceHelper>;
  49880. /** Return this.onControllerMeshLoadedObservable
  49881. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49882. */
  49883. get onControllerMeshLoaded(): Observable<WebVRController>;
  49884. private _rayLength;
  49885. private _useCustomVRButton;
  49886. private _teleportationRequested;
  49887. private _teleportActive;
  49888. private _floorMeshName;
  49889. private _floorMeshesCollection;
  49890. private _teleportationMode;
  49891. private _teleportationTime;
  49892. private _teleportationSpeed;
  49893. private _teleportationEasing;
  49894. private _rotationAllowed;
  49895. private _teleportBackwardsVector;
  49896. private _teleportationTarget;
  49897. private _isDefaultTeleportationTarget;
  49898. private _postProcessMove;
  49899. private _teleportationFillColor;
  49900. private _teleportationBorderColor;
  49901. private _rotationAngle;
  49902. private _haloCenter;
  49903. private _cameraGazer;
  49904. private _padSensibilityUp;
  49905. private _padSensibilityDown;
  49906. private _leftController;
  49907. private _rightController;
  49908. private _gazeColor;
  49909. private _laserColor;
  49910. private _pickedLaserColor;
  49911. private _pickedGazeColor;
  49912. /**
  49913. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49914. */
  49915. onNewMeshSelected: Observable<AbstractMesh>;
  49916. /**
  49917. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49918. * This observable will provide the mesh and the controller used to select the mesh
  49919. */
  49920. onMeshSelectedWithController: Observable<{
  49921. mesh: AbstractMesh;
  49922. controller: WebVRController;
  49923. }>;
  49924. /**
  49925. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49926. */
  49927. onNewMeshPicked: Observable<PickingInfo>;
  49928. private _circleEase;
  49929. /**
  49930. * Observable raised before camera teleportation
  49931. */
  49932. onBeforeCameraTeleport: Observable<Vector3>;
  49933. /**
  49934. * Observable raised after camera teleportation
  49935. */
  49936. onAfterCameraTeleport: Observable<Vector3>;
  49937. /**
  49938. * Observable raised when current selected mesh gets unselected
  49939. */
  49940. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49941. private _raySelectionPredicate;
  49942. /**
  49943. * To be optionaly changed by user to define custom ray selection
  49944. */
  49945. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49946. /**
  49947. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49948. */
  49949. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49950. /**
  49951. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49952. */
  49953. teleportationEnabled: boolean;
  49954. private _defaultHeight;
  49955. private _teleportationInitialized;
  49956. private _interactionsEnabled;
  49957. private _interactionsRequested;
  49958. private _displayGaze;
  49959. private _displayLaserPointer;
  49960. /**
  49961. * The mesh used to display where the user is going to teleport.
  49962. */
  49963. get teleportationTarget(): Mesh;
  49964. /**
  49965. * Sets the mesh to be used to display where the user is going to teleport.
  49966. */
  49967. set teleportationTarget(value: Mesh);
  49968. /**
  49969. * 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
  49970. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49971. * See https://doc.babylonjs.com/resources/baking_transformations
  49972. */
  49973. get gazeTrackerMesh(): Mesh;
  49974. set gazeTrackerMesh(value: Mesh);
  49975. /**
  49976. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49977. */
  49978. updateGazeTrackerScale: boolean;
  49979. /**
  49980. * If the gaze trackers color should be updated when selecting meshes
  49981. */
  49982. updateGazeTrackerColor: boolean;
  49983. /**
  49984. * If the controller laser color should be updated when selecting meshes
  49985. */
  49986. updateControllerLaserColor: boolean;
  49987. /**
  49988. * The gaze tracking mesh corresponding to the left controller
  49989. */
  49990. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49991. /**
  49992. * The gaze tracking mesh corresponding to the right controller
  49993. */
  49994. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49995. /**
  49996. * If the ray of the gaze should be displayed.
  49997. */
  49998. get displayGaze(): boolean;
  49999. /**
  50000. * Sets if the ray of the gaze should be displayed.
  50001. */
  50002. set displayGaze(value: boolean);
  50003. /**
  50004. * If the ray of the LaserPointer should be displayed.
  50005. */
  50006. get displayLaserPointer(): boolean;
  50007. /**
  50008. * Sets if the ray of the LaserPointer should be displayed.
  50009. */
  50010. set displayLaserPointer(value: boolean);
  50011. /**
  50012. * The deviceOrientationCamera used as the camera when not in VR.
  50013. */
  50014. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50015. /**
  50016. * Based on the current WebVR support, returns the current VR camera used.
  50017. */
  50018. get currentVRCamera(): Nullable<Camera>;
  50019. /**
  50020. * The webVRCamera which is used when in VR.
  50021. */
  50022. get webVRCamera(): WebVRFreeCamera;
  50023. /**
  50024. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50025. */
  50026. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50027. /**
  50028. * The html button that is used to trigger entering into VR.
  50029. */
  50030. get vrButton(): Nullable<HTMLButtonElement>;
  50031. private get _teleportationRequestInitiated();
  50032. /**
  50033. * Defines whether or not Pointer lock should be requested when switching to
  50034. * full screen.
  50035. */
  50036. requestPointerLockOnFullScreen: boolean;
  50037. /**
  50038. * If asking to force XR, this will be populated with the default xr experience
  50039. */
  50040. xr: WebXRDefaultExperience;
  50041. /**
  50042. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50043. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50044. */
  50045. xrTestDone: boolean;
  50046. /**
  50047. * Instantiates a VRExperienceHelper.
  50048. * Helps to quickly add VR support to an existing scene.
  50049. * @param scene The scene the VRExperienceHelper belongs to.
  50050. * @param webVROptions Options to modify the vr experience helper's behavior.
  50051. */
  50052. constructor(scene: Scene,
  50053. /** Options to modify the vr experience helper's behavior. */
  50054. webVROptions?: VRExperienceHelperOptions);
  50055. private completeVRInit;
  50056. private _onDefaultMeshLoaded;
  50057. private _onResize;
  50058. private _onFullscreenChange;
  50059. /**
  50060. * Gets a value indicating if we are currently in VR mode.
  50061. */
  50062. get isInVRMode(): boolean;
  50063. private onVrDisplayPresentChange;
  50064. private onVRDisplayChanged;
  50065. private moveButtonToBottomRight;
  50066. private displayVRButton;
  50067. private updateButtonVisibility;
  50068. private _cachedAngularSensibility;
  50069. /**
  50070. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50071. * Otherwise, will use the fullscreen API.
  50072. */
  50073. enterVR(): void;
  50074. /**
  50075. * Attempt to exit VR, or fullscreen.
  50076. */
  50077. exitVR(): void;
  50078. /**
  50079. * The position of the vr experience helper.
  50080. */
  50081. get position(): Vector3;
  50082. /**
  50083. * Sets the position of the vr experience helper.
  50084. */
  50085. set position(value: Vector3);
  50086. /**
  50087. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50088. */
  50089. enableInteractions(): void;
  50090. private get _noControllerIsActive();
  50091. private beforeRender;
  50092. private _isTeleportationFloor;
  50093. /**
  50094. * Adds a floor mesh to be used for teleportation.
  50095. * @param floorMesh the mesh to be used for teleportation.
  50096. */
  50097. addFloorMesh(floorMesh: Mesh): void;
  50098. /**
  50099. * Removes a floor mesh from being used for teleportation.
  50100. * @param floorMesh the mesh to be removed.
  50101. */
  50102. removeFloorMesh(floorMesh: Mesh): void;
  50103. /**
  50104. * Enables interactions and teleportation using the VR controllers and gaze.
  50105. * @param vrTeleportationOptions options to modify teleportation behavior.
  50106. */
  50107. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50108. private _onNewGamepadConnected;
  50109. private _tryEnableInteractionOnController;
  50110. private _onNewGamepadDisconnected;
  50111. private _enableInteractionOnController;
  50112. private _checkTeleportWithRay;
  50113. private _checkRotate;
  50114. private _checkTeleportBackwards;
  50115. private _enableTeleportationOnController;
  50116. private _createTeleportationCircles;
  50117. private _displayTeleportationTarget;
  50118. private _hideTeleportationTarget;
  50119. private _rotateCamera;
  50120. private _moveTeleportationSelectorTo;
  50121. private _workingVector;
  50122. private _workingQuaternion;
  50123. private _workingMatrix;
  50124. /**
  50125. * Time Constant Teleportation Mode
  50126. */
  50127. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50128. /**
  50129. * Speed Constant Teleportation Mode
  50130. */
  50131. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50132. /**
  50133. * Teleports the users feet to the desired location
  50134. * @param location The location where the user's feet should be placed
  50135. */
  50136. teleportCamera(location: Vector3): void;
  50137. private _convertNormalToDirectionOfRay;
  50138. private _castRayAndSelectObject;
  50139. private _notifySelectedMeshUnselected;
  50140. /**
  50141. * Permanently set new colors for the laser pointer
  50142. * @param color the new laser color
  50143. * @param pickedColor the new laser color when picked mesh detected
  50144. */
  50145. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50146. /**
  50147. * Set lighting enabled / disabled on the laser pointer of both controllers
  50148. * @param enabled should the lighting be enabled on the laser pointer
  50149. */
  50150. setLaserLightingState(enabled?: boolean): void;
  50151. /**
  50152. * Permanently set new colors for the gaze pointer
  50153. * @param color the new gaze color
  50154. * @param pickedColor the new gaze color when picked mesh detected
  50155. */
  50156. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50157. /**
  50158. * Sets the color of the laser ray from the vr controllers.
  50159. * @param color new color for the ray.
  50160. */
  50161. changeLaserColor(color: Color3): void;
  50162. /**
  50163. * Sets the color of the ray from the vr headsets gaze.
  50164. * @param color new color for the ray.
  50165. */
  50166. changeGazeColor(color: Color3): void;
  50167. /**
  50168. * Exits VR and disposes of the vr experience helper
  50169. */
  50170. dispose(): void;
  50171. /**
  50172. * Gets the name of the VRExperienceHelper class
  50173. * @returns "VRExperienceHelper"
  50174. */
  50175. getClassName(): string;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. /**
  50180. * Contains an array of blocks representing the octree
  50181. */
  50182. export interface IOctreeContainer<T> {
  50183. /**
  50184. * Blocks within the octree
  50185. */
  50186. blocks: Array<OctreeBlock<T>>;
  50187. }
  50188. /**
  50189. * Class used to store a cell in an octree
  50190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50191. */
  50192. export class OctreeBlock<T> {
  50193. /**
  50194. * Gets the content of the current block
  50195. */
  50196. entries: T[];
  50197. /**
  50198. * Gets the list of block children
  50199. */
  50200. blocks: Array<OctreeBlock<T>>;
  50201. private _depth;
  50202. private _maxDepth;
  50203. private _capacity;
  50204. private _minPoint;
  50205. private _maxPoint;
  50206. private _boundingVectors;
  50207. private _creationFunc;
  50208. /**
  50209. * Creates a new block
  50210. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50211. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50212. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50213. * @param depth defines the current depth of this block in the octree
  50214. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50215. * @param creationFunc defines a callback to call when an element is added to the block
  50216. */
  50217. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50218. /**
  50219. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50220. */
  50221. get capacity(): number;
  50222. /**
  50223. * Gets the minimum vector (in world space) of the block's bounding box
  50224. */
  50225. get minPoint(): Vector3;
  50226. /**
  50227. * Gets the maximum vector (in world space) of the block's bounding box
  50228. */
  50229. get maxPoint(): Vector3;
  50230. /**
  50231. * Add a new element to this block
  50232. * @param entry defines the element to add
  50233. */
  50234. addEntry(entry: T): void;
  50235. /**
  50236. * Remove an element from this block
  50237. * @param entry defines the element to remove
  50238. */
  50239. removeEntry(entry: T): void;
  50240. /**
  50241. * Add an array of elements to this block
  50242. * @param entries defines the array of elements to add
  50243. */
  50244. addEntries(entries: T[]): void;
  50245. /**
  50246. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50247. * @param frustumPlanes defines the frustum planes to test
  50248. * @param selection defines the array to store current content if selection is positive
  50249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50250. */
  50251. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50252. /**
  50253. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50254. * @param sphereCenter defines the bounding sphere center
  50255. * @param sphereRadius defines the bounding sphere radius
  50256. * @param selection defines the array to store current content if selection is positive
  50257. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50258. */
  50259. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50260. /**
  50261. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50262. * @param ray defines the ray to test with
  50263. * @param selection defines the array to store current content if selection is positive
  50264. */
  50265. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50266. /**
  50267. * Subdivide the content into child blocks (this block will then be empty)
  50268. */
  50269. createInnerBlocks(): void;
  50270. /**
  50271. * @hidden
  50272. */
  50273. 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;
  50274. }
  50275. }
  50276. declare module BABYLON {
  50277. /**
  50278. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50280. */
  50281. export class Octree<T> {
  50282. /** 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.) */
  50283. maxDepth: number;
  50284. /**
  50285. * Blocks within the octree containing objects
  50286. */
  50287. blocks: Array<OctreeBlock<T>>;
  50288. /**
  50289. * Content stored in the octree
  50290. */
  50291. dynamicContent: T[];
  50292. private _maxBlockCapacity;
  50293. private _selectionContent;
  50294. private _creationFunc;
  50295. /**
  50296. * Creates a octree
  50297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50298. * @param creationFunc function to be used to instatiate the octree
  50299. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50300. * @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.)
  50301. */
  50302. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50303. /** 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.) */
  50304. maxDepth?: number);
  50305. /**
  50306. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50307. * @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);
  50308. * @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);
  50309. * @param entries meshes to be added to the octree blocks
  50310. */
  50311. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50312. /**
  50313. * Adds a mesh to the octree
  50314. * @param entry Mesh to add to the octree
  50315. */
  50316. addMesh(entry: T): void;
  50317. /**
  50318. * Remove an element from the octree
  50319. * @param entry defines the element to remove
  50320. */
  50321. removeMesh(entry: T): void;
  50322. /**
  50323. * Selects an array of meshes within the frustum
  50324. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50325. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50326. * @returns array of meshes within the frustum
  50327. */
  50328. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50329. /**
  50330. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50331. * @param sphereCenter defines the bounding sphere center
  50332. * @param sphereRadius defines the bounding sphere radius
  50333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50334. * @returns an array of objects that intersect the sphere
  50335. */
  50336. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50337. /**
  50338. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50339. * @param ray defines the ray to test with
  50340. * @returns array of intersected objects
  50341. */
  50342. intersectsRay(ray: Ray): SmartArray<T>;
  50343. /**
  50344. * Adds a mesh into the octree block if it intersects the block
  50345. */
  50346. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50347. /**
  50348. * Adds a submesh into the octree block if it intersects the block
  50349. */
  50350. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50351. }
  50352. }
  50353. declare module BABYLON {
  50354. interface Scene {
  50355. /**
  50356. * @hidden
  50357. * Backing Filed
  50358. */
  50359. _selectionOctree: Octree<AbstractMesh>;
  50360. /**
  50361. * Gets the octree used to boost mesh selection (picking)
  50362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50363. */
  50364. selectionOctree: Octree<AbstractMesh>;
  50365. /**
  50366. * Creates or updates the octree used to boost selection (picking)
  50367. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50368. * @param maxCapacity defines the maximum capacity per leaf
  50369. * @param maxDepth defines the maximum depth of the octree
  50370. * @returns an octree of AbstractMesh
  50371. */
  50372. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50373. }
  50374. interface AbstractMesh {
  50375. /**
  50376. * @hidden
  50377. * Backing Field
  50378. */
  50379. _submeshesOctree: Octree<SubMesh>;
  50380. /**
  50381. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50382. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50383. * @param maxCapacity defines the maximum size of each block (64 by default)
  50384. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50385. * @returns the new octree
  50386. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50387. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50388. */
  50389. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50390. }
  50391. /**
  50392. * Defines the octree scene component responsible to manage any octrees
  50393. * in a given scene.
  50394. */
  50395. export class OctreeSceneComponent {
  50396. /**
  50397. * The component name help to identify the component in the list of scene components.
  50398. */
  50399. readonly name: string;
  50400. /**
  50401. * The scene the component belongs to.
  50402. */
  50403. scene: Scene;
  50404. /**
  50405. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50406. */
  50407. readonly checksIsEnabled: boolean;
  50408. /**
  50409. * Creates a new instance of the component for the given scene
  50410. * @param scene Defines the scene to register the component in
  50411. */
  50412. constructor(scene: Scene);
  50413. /**
  50414. * Registers the component in a given scene
  50415. */
  50416. register(): void;
  50417. /**
  50418. * Return the list of active meshes
  50419. * @returns the list of active meshes
  50420. */
  50421. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50422. /**
  50423. * Return the list of active sub meshes
  50424. * @param mesh The mesh to get the candidates sub meshes from
  50425. * @returns the list of active sub meshes
  50426. */
  50427. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50428. private _tempRay;
  50429. /**
  50430. * Return the list of sub meshes intersecting with a given local ray
  50431. * @param mesh defines the mesh to find the submesh for
  50432. * @param localRay defines the ray in local space
  50433. * @returns the list of intersecting sub meshes
  50434. */
  50435. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50436. /**
  50437. * Return the list of sub meshes colliding with a collider
  50438. * @param mesh defines the mesh to find the submesh for
  50439. * @param collider defines the collider to evaluate the collision against
  50440. * @returns the list of colliding sub meshes
  50441. */
  50442. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50443. /**
  50444. * Rebuilds the elements related to this component in case of
  50445. * context lost for instance.
  50446. */
  50447. rebuild(): void;
  50448. /**
  50449. * Disposes the component and the associated ressources.
  50450. */
  50451. dispose(): void;
  50452. }
  50453. }
  50454. declare module BABYLON {
  50455. /**
  50456. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50457. */
  50458. export class Gizmo implements IDisposable {
  50459. /** The utility layer the gizmo will be added to */
  50460. gizmoLayer: UtilityLayerRenderer;
  50461. /**
  50462. * The root mesh of the gizmo
  50463. */
  50464. _rootMesh: Mesh;
  50465. private _attachedMesh;
  50466. private _attachedNode;
  50467. /**
  50468. * Ratio for the scale of the gizmo (Default: 1)
  50469. */
  50470. protected _scaleRatio: number;
  50471. /**
  50472. * boolean updated by pointermove when a gizmo mesh is hovered
  50473. */
  50474. protected _isHovered: boolean;
  50475. /**
  50476. * Ratio for the scale of the gizmo (Default: 1)
  50477. */
  50478. set scaleRatio(value: number);
  50479. get scaleRatio(): number;
  50480. /**
  50481. * True when the mouse pointer is hovered a gizmo mesh
  50482. */
  50483. get isHovered(): boolean;
  50484. /**
  50485. * If a custom mesh has been set (Default: false)
  50486. */
  50487. protected _customMeshSet: boolean;
  50488. /**
  50489. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50490. * * When set, interactions will be enabled
  50491. */
  50492. get attachedMesh(): Nullable<AbstractMesh>;
  50493. set attachedMesh(value: Nullable<AbstractMesh>);
  50494. /**
  50495. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50496. * * When set, interactions will be enabled
  50497. */
  50498. get attachedNode(): Nullable<Node>;
  50499. set attachedNode(value: Nullable<Node>);
  50500. /**
  50501. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50502. * @param mesh The mesh to replace the default mesh of the gizmo
  50503. */
  50504. setCustomMesh(mesh: Mesh): void;
  50505. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50506. /**
  50507. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50508. */
  50509. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50510. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50511. /**
  50512. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50513. */
  50514. updateGizmoPositionToMatchAttachedMesh: boolean;
  50515. /**
  50516. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50517. */
  50518. updateScale: boolean;
  50519. protected _interactionsEnabled: boolean;
  50520. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50521. private _beforeRenderObserver;
  50522. private _tempQuaternion;
  50523. private _tempVector;
  50524. private _tempVector2;
  50525. private _tempMatrix1;
  50526. private _tempMatrix2;
  50527. private _rightHandtoLeftHandMatrix;
  50528. /**
  50529. * Creates a gizmo
  50530. * @param gizmoLayer The utility layer the gizmo will be added to
  50531. */
  50532. constructor(
  50533. /** The utility layer the gizmo will be added to */
  50534. gizmoLayer?: UtilityLayerRenderer);
  50535. /**
  50536. * Updates the gizmo to match the attached mesh's position/rotation
  50537. */
  50538. protected _update(): void;
  50539. /**
  50540. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50541. * @param value Node, TransformNode or mesh
  50542. */
  50543. protected _matrixChanged(): void;
  50544. /**
  50545. * Disposes of the gizmo
  50546. */
  50547. dispose(): void;
  50548. }
  50549. }
  50550. declare module BABYLON {
  50551. /**
  50552. * Single plane drag gizmo
  50553. */
  50554. export class PlaneDragGizmo extends Gizmo {
  50555. /**
  50556. * Drag behavior responsible for the gizmos dragging interactions
  50557. */
  50558. dragBehavior: PointerDragBehavior;
  50559. private _pointerObserver;
  50560. /**
  50561. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50562. */
  50563. snapDistance: number;
  50564. /**
  50565. * Event that fires each time the gizmo snaps to a new location.
  50566. * * snapDistance is the the change in distance
  50567. */
  50568. onSnapObservable: Observable<{
  50569. snapDistance: number;
  50570. }>;
  50571. private _plane;
  50572. private _coloredMaterial;
  50573. private _hoverMaterial;
  50574. private _isEnabled;
  50575. private _parent;
  50576. /** @hidden */
  50577. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50578. /** @hidden */
  50579. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50580. /**
  50581. * Creates a PlaneDragGizmo
  50582. * @param gizmoLayer The utility layer the gizmo will be added to
  50583. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50584. * @param color The color of the gizmo
  50585. */
  50586. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50587. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50588. /**
  50589. * If the gizmo is enabled
  50590. */
  50591. set isEnabled(value: boolean);
  50592. get isEnabled(): boolean;
  50593. /**
  50594. * Disposes of the gizmo
  50595. */
  50596. dispose(): void;
  50597. }
  50598. }
  50599. declare module BABYLON {
  50600. /**
  50601. * Gizmo that enables dragging a mesh along 3 axis
  50602. */
  50603. export class PositionGizmo extends Gizmo {
  50604. /**
  50605. * Internal gizmo used for interactions on the x axis
  50606. */
  50607. xGizmo: AxisDragGizmo;
  50608. /**
  50609. * Internal gizmo used for interactions on the y axis
  50610. */
  50611. yGizmo: AxisDragGizmo;
  50612. /**
  50613. * Internal gizmo used for interactions on the z axis
  50614. */
  50615. zGizmo: AxisDragGizmo;
  50616. /**
  50617. * Internal gizmo used for interactions on the yz plane
  50618. */
  50619. xPlaneGizmo: PlaneDragGizmo;
  50620. /**
  50621. * Internal gizmo used for interactions on the xz plane
  50622. */
  50623. yPlaneGizmo: PlaneDragGizmo;
  50624. /**
  50625. * Internal gizmo used for interactions on the xy plane
  50626. */
  50627. zPlaneGizmo: PlaneDragGizmo;
  50628. /**
  50629. * private variables
  50630. */
  50631. private _meshAttached;
  50632. private _nodeAttached;
  50633. private _snapDistance;
  50634. /** Fires an event when any of it's sub gizmos are dragged */
  50635. onDragStartObservable: Observable<unknown>;
  50636. /** Fires an event when any of it's sub gizmos are released from dragging */
  50637. onDragEndObservable: Observable<unknown>;
  50638. /**
  50639. * If set to true, planar drag is enabled
  50640. */
  50641. private _planarGizmoEnabled;
  50642. get attachedMesh(): Nullable<AbstractMesh>;
  50643. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50644. get attachedNode(): Nullable<Node>;
  50645. set attachedNode(node: Nullable<Node>);
  50646. /**
  50647. * True when the mouse pointer is hovering a gizmo mesh
  50648. */
  50649. get isHovered(): boolean;
  50650. /**
  50651. * Creates a PositionGizmo
  50652. * @param gizmoLayer The utility layer the gizmo will be added to
  50653. @param thickness display gizmo axis thickness
  50654. */
  50655. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50656. /**
  50657. * If the planar drag gizmo is enabled
  50658. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50659. */
  50660. set planarGizmoEnabled(value: boolean);
  50661. get planarGizmoEnabled(): boolean;
  50662. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50663. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50664. /**
  50665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50666. */
  50667. set snapDistance(value: number);
  50668. get snapDistance(): number;
  50669. /**
  50670. * Ratio for the scale of the gizmo (Default: 1)
  50671. */
  50672. set scaleRatio(value: number);
  50673. get scaleRatio(): number;
  50674. /**
  50675. * Disposes of the gizmo
  50676. */
  50677. dispose(): void;
  50678. /**
  50679. * CustomMeshes are not supported by this gizmo
  50680. * @param mesh The mesh to replace the default mesh of the gizmo
  50681. */
  50682. setCustomMesh(mesh: Mesh): void;
  50683. }
  50684. }
  50685. declare module BABYLON {
  50686. /**
  50687. * Single axis drag gizmo
  50688. */
  50689. export class AxisDragGizmo extends Gizmo {
  50690. /**
  50691. * Drag behavior responsible for the gizmos dragging interactions
  50692. */
  50693. dragBehavior: PointerDragBehavior;
  50694. private _pointerObserver;
  50695. /**
  50696. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50697. */
  50698. snapDistance: number;
  50699. /**
  50700. * Event that fires each time the gizmo snaps to a new location.
  50701. * * snapDistance is the the change in distance
  50702. */
  50703. onSnapObservable: Observable<{
  50704. snapDistance: number;
  50705. }>;
  50706. private _isEnabled;
  50707. private _parent;
  50708. private _arrow;
  50709. private _coloredMaterial;
  50710. private _hoverMaterial;
  50711. /** @hidden */
  50712. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50713. /** @hidden */
  50714. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50715. /**
  50716. * Creates an AxisDragGizmo
  50717. * @param gizmoLayer The utility layer the gizmo will be added to
  50718. * @param dragAxis The axis which the gizmo will be able to drag on
  50719. * @param color The color of the gizmo
  50720. * @param thickness display gizmo axis thickness
  50721. */
  50722. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50723. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50724. /**
  50725. * If the gizmo is enabled
  50726. */
  50727. set isEnabled(value: boolean);
  50728. get isEnabled(): boolean;
  50729. /**
  50730. * Disposes of the gizmo
  50731. */
  50732. dispose(): void;
  50733. }
  50734. }
  50735. declare module BABYLON.Debug {
  50736. /**
  50737. * The Axes viewer will show 3 axes in a specific point in space
  50738. */
  50739. export class AxesViewer {
  50740. private _xAxis;
  50741. private _yAxis;
  50742. private _zAxis;
  50743. private _scaleLinesFactor;
  50744. private _instanced;
  50745. /**
  50746. * Gets the hosting scene
  50747. */
  50748. scene: Nullable<Scene>;
  50749. /**
  50750. * Gets or sets a number used to scale line length
  50751. */
  50752. scaleLines: number;
  50753. /** Gets the node hierarchy used to render x-axis */
  50754. get xAxis(): TransformNode;
  50755. /** Gets the node hierarchy used to render y-axis */
  50756. get yAxis(): TransformNode;
  50757. /** Gets the node hierarchy used to render z-axis */
  50758. get zAxis(): TransformNode;
  50759. /**
  50760. * Creates a new AxesViewer
  50761. * @param scene defines the hosting scene
  50762. * @param scaleLines defines a number used to scale line length (1 by default)
  50763. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50764. * @param xAxis defines the node hierarchy used to render the x-axis
  50765. * @param yAxis defines the node hierarchy used to render the y-axis
  50766. * @param zAxis defines the node hierarchy used to render the z-axis
  50767. */
  50768. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50769. /**
  50770. * Force the viewer to update
  50771. * @param position defines the position of the viewer
  50772. * @param xaxis defines the x axis of the viewer
  50773. * @param yaxis defines the y axis of the viewer
  50774. * @param zaxis defines the z axis of the viewer
  50775. */
  50776. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50777. /**
  50778. * Creates an instance of this axes viewer.
  50779. * @returns a new axes viewer with instanced meshes
  50780. */
  50781. createInstance(): AxesViewer;
  50782. /** Releases resources */
  50783. dispose(): void;
  50784. private static _SetRenderingGroupId;
  50785. }
  50786. }
  50787. declare module BABYLON.Debug {
  50788. /**
  50789. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50790. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50791. */
  50792. export class BoneAxesViewer extends AxesViewer {
  50793. /**
  50794. * Gets or sets the target mesh where to display the axes viewer
  50795. */
  50796. mesh: Nullable<Mesh>;
  50797. /**
  50798. * Gets or sets the target bone where to display the axes viewer
  50799. */
  50800. bone: Nullable<Bone>;
  50801. /** Gets current position */
  50802. pos: Vector3;
  50803. /** Gets direction of X axis */
  50804. xaxis: Vector3;
  50805. /** Gets direction of Y axis */
  50806. yaxis: Vector3;
  50807. /** Gets direction of Z axis */
  50808. zaxis: Vector3;
  50809. /**
  50810. * Creates a new BoneAxesViewer
  50811. * @param scene defines the hosting scene
  50812. * @param bone defines the target bone
  50813. * @param mesh defines the target mesh
  50814. * @param scaleLines defines a scaling factor for line length (1 by default)
  50815. */
  50816. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50817. /**
  50818. * Force the viewer to update
  50819. */
  50820. update(): void;
  50821. /** Releases resources */
  50822. dispose(): void;
  50823. }
  50824. }
  50825. declare module BABYLON {
  50826. /**
  50827. * Interface used to define scene explorer extensibility option
  50828. */
  50829. export interface IExplorerExtensibilityOption {
  50830. /**
  50831. * Define the option label
  50832. */
  50833. label: string;
  50834. /**
  50835. * Defines the action to execute on click
  50836. */
  50837. action: (entity: any) => void;
  50838. }
  50839. /**
  50840. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50841. */
  50842. export interface IExplorerExtensibilityGroup {
  50843. /**
  50844. * Defines a predicate to test if a given type mut be extended
  50845. */
  50846. predicate: (entity: any) => boolean;
  50847. /**
  50848. * Gets the list of options added to a type
  50849. */
  50850. entries: IExplorerExtensibilityOption[];
  50851. }
  50852. /**
  50853. * Interface used to define the options to use to create the Inspector
  50854. */
  50855. export interface IInspectorOptions {
  50856. /**
  50857. * Display in overlay mode (default: false)
  50858. */
  50859. overlay?: boolean;
  50860. /**
  50861. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50862. */
  50863. globalRoot?: HTMLElement;
  50864. /**
  50865. * Display the Scene explorer
  50866. */
  50867. showExplorer?: boolean;
  50868. /**
  50869. * Display the property inspector
  50870. */
  50871. showInspector?: boolean;
  50872. /**
  50873. * Display in embed mode (both panes on the right)
  50874. */
  50875. embedMode?: boolean;
  50876. /**
  50877. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50878. */
  50879. handleResize?: boolean;
  50880. /**
  50881. * Allow the panes to popup (default: true)
  50882. */
  50883. enablePopup?: boolean;
  50884. /**
  50885. * Allow the panes to be closed by users (default: true)
  50886. */
  50887. enableClose?: boolean;
  50888. /**
  50889. * Optional list of extensibility entries
  50890. */
  50891. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50892. /**
  50893. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50894. */
  50895. inspectorURL?: string;
  50896. /**
  50897. * Optional initial tab (default to DebugLayerTab.Properties)
  50898. */
  50899. initialTab?: DebugLayerTab;
  50900. }
  50901. interface Scene {
  50902. /**
  50903. * @hidden
  50904. * Backing field
  50905. */
  50906. _debugLayer: DebugLayer;
  50907. /**
  50908. * Gets the debug layer (aka Inspector) associated with the scene
  50909. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50910. */
  50911. debugLayer: DebugLayer;
  50912. }
  50913. /**
  50914. * Enum of inspector action tab
  50915. */
  50916. export enum DebugLayerTab {
  50917. /**
  50918. * Properties tag (default)
  50919. */
  50920. Properties = 0,
  50921. /**
  50922. * Debug tab
  50923. */
  50924. Debug = 1,
  50925. /**
  50926. * Statistics tab
  50927. */
  50928. Statistics = 2,
  50929. /**
  50930. * Tools tab
  50931. */
  50932. Tools = 3,
  50933. /**
  50934. * Settings tab
  50935. */
  50936. Settings = 4
  50937. }
  50938. /**
  50939. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50940. * what is happening in your scene
  50941. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50942. */
  50943. export class DebugLayer {
  50944. /**
  50945. * Define the url to get the inspector script from.
  50946. * By default it uses the babylonjs CDN.
  50947. * @ignoreNaming
  50948. */
  50949. static InspectorURL: string;
  50950. private _scene;
  50951. private BJSINSPECTOR;
  50952. private _onPropertyChangedObservable?;
  50953. /**
  50954. * Observable triggered when a property is changed through the inspector.
  50955. */
  50956. get onPropertyChangedObservable(): any;
  50957. /**
  50958. * Instantiates a new debug layer.
  50959. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50960. * what is happening in your scene
  50961. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50962. * @param scene Defines the scene to inspect
  50963. */
  50964. constructor(scene: Scene);
  50965. /** Creates the inspector window. */
  50966. private _createInspector;
  50967. /**
  50968. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50969. * @param entity defines the entity to select
  50970. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50971. */
  50972. select(entity: any, lineContainerTitles?: string | string[]): void;
  50973. /** Get the inspector from bundle or global */
  50974. private _getGlobalInspector;
  50975. /**
  50976. * Get if the inspector is visible or not.
  50977. * @returns true if visible otherwise, false
  50978. */
  50979. isVisible(): boolean;
  50980. /**
  50981. * Hide the inspector and close its window.
  50982. */
  50983. hide(): void;
  50984. /**
  50985. * Update the scene in the inspector
  50986. */
  50987. setAsActiveScene(): void;
  50988. /**
  50989. * Launch the debugLayer.
  50990. * @param config Define the configuration of the inspector
  50991. * @return a promise fulfilled when the debug layer is visible
  50992. */
  50993. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50994. }
  50995. }
  50996. declare module BABYLON {
  50997. /**
  50998. * Class containing static functions to help procedurally build meshes
  50999. */
  51000. export class BoxBuilder {
  51001. /**
  51002. * Creates a box mesh
  51003. * * The parameter `size` sets the size (float) of each box side (default 1)
  51004. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51005. * * 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)
  51006. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51008. * * 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
  51009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51010. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51011. * @param name defines the name of the mesh
  51012. * @param options defines the options used to create the mesh
  51013. * @param scene defines the hosting scene
  51014. * @returns the box mesh
  51015. */
  51016. static CreateBox(name: string, options: {
  51017. size?: number;
  51018. width?: number;
  51019. height?: number;
  51020. depth?: number;
  51021. faceUV?: Vector4[];
  51022. faceColors?: Color4[];
  51023. sideOrientation?: number;
  51024. frontUVs?: Vector4;
  51025. backUVs?: Vector4;
  51026. wrap?: boolean;
  51027. topBaseAt?: number;
  51028. bottomBaseAt?: number;
  51029. updatable?: boolean;
  51030. }, scene?: Nullable<Scene>): Mesh;
  51031. }
  51032. }
  51033. declare module BABYLON.Debug {
  51034. /**
  51035. * Used to show the physics impostor around the specific mesh
  51036. */
  51037. export class PhysicsViewer {
  51038. /** @hidden */
  51039. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51040. /** @hidden */
  51041. protected _meshes: Array<Nullable<AbstractMesh>>;
  51042. /** @hidden */
  51043. protected _scene: Nullable<Scene>;
  51044. /** @hidden */
  51045. protected _numMeshes: number;
  51046. /** @hidden */
  51047. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51048. private _renderFunction;
  51049. private _utilityLayer;
  51050. private _debugBoxMesh;
  51051. private _debugSphereMesh;
  51052. private _debugCylinderMesh;
  51053. private _debugMaterial;
  51054. private _debugMeshMeshes;
  51055. /**
  51056. * Creates a new PhysicsViewer
  51057. * @param scene defines the hosting scene
  51058. */
  51059. constructor(scene: Scene);
  51060. /** @hidden */
  51061. protected _updateDebugMeshes(): void;
  51062. /**
  51063. * Renders a specified physic impostor
  51064. * @param impostor defines the impostor to render
  51065. * @param targetMesh defines the mesh represented by the impostor
  51066. * @returns the new debug mesh used to render the impostor
  51067. */
  51068. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51069. /**
  51070. * Hides a specified physic impostor
  51071. * @param impostor defines the impostor to hide
  51072. */
  51073. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51074. private _getDebugMaterial;
  51075. private _getDebugBoxMesh;
  51076. private _getDebugSphereMesh;
  51077. private _getDebugCylinderMesh;
  51078. private _getDebugMeshMesh;
  51079. private _getDebugMesh;
  51080. /** Releases all resources */
  51081. dispose(): void;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /**
  51086. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51087. * in order to better appreciate the issue one might have.
  51088. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51089. */
  51090. export class RayHelper {
  51091. /**
  51092. * Defines the ray we are currently tryin to visualize.
  51093. */
  51094. ray: Nullable<Ray>;
  51095. private _renderPoints;
  51096. private _renderLine;
  51097. private _renderFunction;
  51098. private _scene;
  51099. private _onAfterRenderObserver;
  51100. private _onAfterStepObserver;
  51101. private _attachedToMesh;
  51102. private _meshSpaceDirection;
  51103. private _meshSpaceOrigin;
  51104. /**
  51105. * Helper function to create a colored helper in a scene in one line.
  51106. * @param ray Defines the ray we are currently tryin to visualize
  51107. * @param scene Defines the scene the ray is used in
  51108. * @param color Defines the color we want to see the ray in
  51109. * @returns The newly created ray helper.
  51110. */
  51111. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51112. /**
  51113. * Instantiate a new ray helper.
  51114. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51115. * in order to better appreciate the issue one might have.
  51116. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51117. * @param ray Defines the ray we are currently tryin to visualize
  51118. */
  51119. constructor(ray: Ray);
  51120. /**
  51121. * Shows the ray we are willing to debug.
  51122. * @param scene Defines the scene the ray needs to be rendered in
  51123. * @param color Defines the color the ray needs to be rendered in
  51124. */
  51125. show(scene: Scene, color?: Color3): void;
  51126. /**
  51127. * Hides the ray we are debugging.
  51128. */
  51129. hide(): void;
  51130. private _render;
  51131. /**
  51132. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51133. * @param mesh Defines the mesh we want the helper attached to
  51134. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51135. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51136. * @param length Defines the length of the ray
  51137. */
  51138. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51139. /**
  51140. * Detach the ray helper from the mesh it has previously been attached to.
  51141. */
  51142. detachFromMesh(): void;
  51143. private _updateToMesh;
  51144. /**
  51145. * Dispose the helper and release its associated resources.
  51146. */
  51147. dispose(): void;
  51148. }
  51149. }
  51150. declare module BABYLON {
  51151. /**
  51152. * Defines the options associated with the creation of a SkeletonViewer.
  51153. */
  51154. export interface ISkeletonViewerOptions {
  51155. /** Should the system pause animations before building the Viewer? */
  51156. pauseAnimations: boolean;
  51157. /** Should the system return the skeleton to rest before building? */
  51158. returnToRest: boolean;
  51159. /** public Display Mode of the Viewer */
  51160. displayMode: number;
  51161. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51162. displayOptions: ISkeletonViewerDisplayOptions;
  51163. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51164. computeBonesUsingShaders: boolean;
  51165. /** Flag ignore non weighted bones */
  51166. useAllBones: boolean;
  51167. }
  51168. /**
  51169. * Defines how to display the various bone meshes for the viewer.
  51170. */
  51171. export interface ISkeletonViewerDisplayOptions {
  51172. /** How far down to start tapering the bone spurs */
  51173. midStep?: number;
  51174. /** How big is the midStep? */
  51175. midStepFactor?: number;
  51176. /** Base for the Sphere Size */
  51177. sphereBaseSize?: number;
  51178. /** The ratio of the sphere to the longest bone in units */
  51179. sphereScaleUnit?: number;
  51180. /** Ratio for the Sphere Size */
  51181. sphereFactor?: number;
  51182. /** Whether a spur should attach its far end to the child bone position */
  51183. spurFollowsChild?: boolean;
  51184. /** Whether to show local axes or not */
  51185. showLocalAxes?: boolean;
  51186. /** Length of each local axis */
  51187. localAxesSize?: number;
  51188. }
  51189. /**
  51190. * Defines the constructor options for the BoneWeight Shader.
  51191. */
  51192. export interface IBoneWeightShaderOptions {
  51193. /** Skeleton to Map */
  51194. skeleton: Skeleton;
  51195. /** Colors for Uninfluenced bones */
  51196. colorBase?: Color3;
  51197. /** Colors for 0.0-0.25 Weight bones */
  51198. colorZero?: Color3;
  51199. /** Color for 0.25-0.5 Weight Influence */
  51200. colorQuarter?: Color3;
  51201. /** Color for 0.5-0.75 Weight Influence */
  51202. colorHalf?: Color3;
  51203. /** Color for 0.75-1 Weight Influence */
  51204. colorFull?: Color3;
  51205. /** Color for Zero Weight Influence */
  51206. targetBoneIndex?: number;
  51207. }
  51208. /**
  51209. * Simple structure of the gradient steps for the Color Map.
  51210. */
  51211. export interface ISkeletonMapShaderColorMapKnot {
  51212. /** Color of the Knot */
  51213. color: Color3;
  51214. /** Location of the Knot */
  51215. location: number;
  51216. }
  51217. /**
  51218. * Defines the constructor options for the SkeletonMap Shader.
  51219. */
  51220. export interface ISkeletonMapShaderOptions {
  51221. /** Skeleton to Map */
  51222. skeleton: Skeleton;
  51223. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51224. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51225. }
  51226. }
  51227. declare module BABYLON {
  51228. /**
  51229. * Class containing static functions to help procedurally build meshes
  51230. */
  51231. export class RibbonBuilder {
  51232. /**
  51233. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51234. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51235. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51236. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51237. * * 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
  51238. * * 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
  51239. * * 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
  51240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51241. * * 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
  51242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51243. * * 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
  51244. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51245. * * 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
  51246. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51248. * @param name defines the name of the mesh
  51249. * @param options defines the options used to create the mesh
  51250. * @param scene defines the hosting scene
  51251. * @returns the ribbon mesh
  51252. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51254. */
  51255. static CreateRibbon(name: string, options: {
  51256. pathArray: Vector3[][];
  51257. closeArray?: boolean;
  51258. closePath?: boolean;
  51259. offset?: number;
  51260. updatable?: boolean;
  51261. sideOrientation?: number;
  51262. frontUVs?: Vector4;
  51263. backUVs?: Vector4;
  51264. instance?: Mesh;
  51265. invertUV?: boolean;
  51266. uvs?: Vector2[];
  51267. colors?: Color4[];
  51268. }, scene?: Nullable<Scene>): Mesh;
  51269. }
  51270. }
  51271. declare module BABYLON {
  51272. /**
  51273. * Class containing static functions to help procedurally build meshes
  51274. */
  51275. export class ShapeBuilder {
  51276. /**
  51277. * 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.
  51278. * * 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.
  51279. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51280. * * 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.
  51281. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51282. * * 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
  51283. * * 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
  51284. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51286. * * 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
  51287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51289. * @param name defines the name of the mesh
  51290. * @param options defines the options used to create the mesh
  51291. * @param scene defines the hosting scene
  51292. * @returns the extruded shape mesh
  51293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51295. */
  51296. static ExtrudeShape(name: string, options: {
  51297. shape: Vector3[];
  51298. path: Vector3[];
  51299. scale?: number;
  51300. rotation?: number;
  51301. cap?: number;
  51302. updatable?: boolean;
  51303. sideOrientation?: number;
  51304. frontUVs?: Vector4;
  51305. backUVs?: Vector4;
  51306. instance?: Mesh;
  51307. invertUV?: boolean;
  51308. }, scene?: Nullable<Scene>): Mesh;
  51309. /**
  51310. * Creates an custom extruded shape mesh.
  51311. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51312. * * 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.
  51313. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51314. * * 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
  51315. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51316. * * 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
  51317. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51318. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51319. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51320. * * 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
  51321. * * 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
  51322. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51324. * * 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
  51325. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51327. * @param name defines the name of the mesh
  51328. * @param options defines the options used to create the mesh
  51329. * @param scene defines the hosting scene
  51330. * @returns the custom extruded shape mesh
  51331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51334. */
  51335. static ExtrudeShapeCustom(name: string, options: {
  51336. shape: Vector3[];
  51337. path: Vector3[];
  51338. scaleFunction?: any;
  51339. rotationFunction?: any;
  51340. ribbonCloseArray?: boolean;
  51341. ribbonClosePath?: boolean;
  51342. cap?: number;
  51343. updatable?: boolean;
  51344. sideOrientation?: number;
  51345. frontUVs?: Vector4;
  51346. backUVs?: Vector4;
  51347. instance?: Mesh;
  51348. invertUV?: boolean;
  51349. }, scene?: Nullable<Scene>): Mesh;
  51350. private static _ExtrudeShapeGeneric;
  51351. }
  51352. }
  51353. declare module BABYLON.Debug {
  51354. /**
  51355. * Class used to render a debug view of a given skeleton
  51356. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51357. */
  51358. export class SkeletonViewer {
  51359. /** defines the skeleton to render */
  51360. skeleton: Skeleton;
  51361. /** defines the mesh attached to the skeleton */
  51362. mesh: AbstractMesh;
  51363. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51364. autoUpdateBonesMatrices: boolean;
  51365. /** defines the rendering group id to use with the viewer */
  51366. renderingGroupId: number;
  51367. /** is the options for the viewer */
  51368. options: Partial<ISkeletonViewerOptions>;
  51369. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51370. static readonly DISPLAY_LINES: number;
  51371. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51372. static readonly DISPLAY_SPHERES: number;
  51373. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51374. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51375. /** public static method to create a BoneWeight Shader
  51376. * @param options The constructor options
  51377. * @param scene The scene that the shader is scoped to
  51378. * @returns The created ShaderMaterial
  51379. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51380. */
  51381. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51382. /** public static method to create a BoneWeight Shader
  51383. * @param options The constructor options
  51384. * @param scene The scene that the shader is scoped to
  51385. * @returns The created ShaderMaterial
  51386. */
  51387. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51388. /** private static method to create a BoneWeight Shader
  51389. * @param size The size of the buffer to create (usually the bone count)
  51390. * @param colorMap The gradient data to generate
  51391. * @param scene The scene that the shader is scoped to
  51392. * @returns an Array of floats from the color gradient values
  51393. */
  51394. private static _CreateBoneMapColorBuffer;
  51395. /** If SkeletonViewer scene scope. */
  51396. private _scene;
  51397. /** Gets or sets the color used to render the skeleton */
  51398. color: Color3;
  51399. /** Array of the points of the skeleton fo the line view. */
  51400. private _debugLines;
  51401. /** The SkeletonViewers Mesh. */
  51402. private _debugMesh;
  51403. /** The local axes Meshes. */
  51404. private _localAxes;
  51405. /** If SkeletonViewer is enabled. */
  51406. private _isEnabled;
  51407. /** If SkeletonViewer is ready. */
  51408. private _ready;
  51409. /** SkeletonViewer render observable. */
  51410. private _obs;
  51411. /** The Utility Layer to render the gizmos in. */
  51412. private _utilityLayer;
  51413. private _boneIndices;
  51414. /** Gets the Scene. */
  51415. get scene(): Scene;
  51416. /** Gets the utilityLayer. */
  51417. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51418. /** Checks Ready Status. */
  51419. get isReady(): Boolean;
  51420. /** Sets Ready Status. */
  51421. set ready(value: boolean);
  51422. /** Gets the debugMesh */
  51423. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51424. /** Sets the debugMesh */
  51425. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51426. /** Gets the displayMode */
  51427. get displayMode(): number;
  51428. /** Sets the displayMode */
  51429. set displayMode(value: number);
  51430. /**
  51431. * Creates a new SkeletonViewer
  51432. * @param skeleton defines the skeleton to render
  51433. * @param mesh defines the mesh attached to the skeleton
  51434. * @param scene defines the hosting scene
  51435. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51436. * @param renderingGroupId defines the rendering group id to use with the viewer
  51437. * @param options All of the extra constructor options for the SkeletonViewer
  51438. */
  51439. constructor(
  51440. /** defines the skeleton to render */
  51441. skeleton: Skeleton,
  51442. /** defines the mesh attached to the skeleton */
  51443. mesh: AbstractMesh,
  51444. /** The Scene scope*/
  51445. scene: Scene,
  51446. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51447. autoUpdateBonesMatrices?: boolean,
  51448. /** defines the rendering group id to use with the viewer */
  51449. renderingGroupId?: number,
  51450. /** is the options for the viewer */
  51451. options?: Partial<ISkeletonViewerOptions>);
  51452. /** The Dynamic bindings for the update functions */
  51453. private _bindObs;
  51454. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51455. update(): void;
  51456. /** Gets or sets a boolean indicating if the viewer is enabled */
  51457. set isEnabled(value: boolean);
  51458. get isEnabled(): boolean;
  51459. private _getBonePosition;
  51460. private _getLinesForBonesWithLength;
  51461. private _getLinesForBonesNoLength;
  51462. /** function to revert the mesh and scene back to the initial state. */
  51463. private _revert;
  51464. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  51465. private _getAbsoluteBindPoseToRef;
  51466. /** function to build and bind sphere joint points and spur bone representations. */
  51467. private _buildSpheresAndSpurs;
  51468. private _buildLocalAxes;
  51469. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51470. private _displayLinesUpdate;
  51471. /** Changes the displayMode of the skeleton viewer
  51472. * @param mode The displayMode numerical value
  51473. */
  51474. changeDisplayMode(mode: number): void;
  51475. /** Sets a display option of the skeleton viewer
  51476. *
  51477. * | Option | Type | Default | Description |
  51478. * | ---------------- | ------- | ------- | ----------- |
  51479. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51480. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51481. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51482. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51483. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  51484. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51485. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51486. *
  51487. * @param option String of the option name
  51488. * @param value The numerical option value
  51489. */
  51490. changeDisplayOptions(option: string, value: number): void;
  51491. /** Release associated resources */
  51492. dispose(): void;
  51493. }
  51494. }
  51495. declare module BABYLON {
  51496. /**
  51497. * Enum for Device Types
  51498. */
  51499. export enum DeviceType {
  51500. /** Generic */
  51501. Generic = 0,
  51502. /** Keyboard */
  51503. Keyboard = 1,
  51504. /** Mouse */
  51505. Mouse = 2,
  51506. /** Touch Pointers */
  51507. Touch = 3,
  51508. /** PS4 Dual Shock */
  51509. DualShock = 4,
  51510. /** Xbox */
  51511. Xbox = 5,
  51512. /** Switch Controller */
  51513. Switch = 6
  51514. }
  51515. /**
  51516. * Enum for All Pointers (Touch/Mouse)
  51517. */
  51518. export enum PointerInput {
  51519. /** Horizontal Axis */
  51520. Horizontal = 0,
  51521. /** Vertical Axis */
  51522. Vertical = 1,
  51523. /** Left Click or Touch */
  51524. LeftClick = 2,
  51525. /** Middle Click */
  51526. MiddleClick = 3,
  51527. /** Right Click */
  51528. RightClick = 4,
  51529. /** Browser Back */
  51530. BrowserBack = 5,
  51531. /** Browser Forward */
  51532. BrowserForward = 6
  51533. }
  51534. /**
  51535. * Enum for Dual Shock Gamepad
  51536. */
  51537. export enum DualShockInput {
  51538. /** Cross */
  51539. Cross = 0,
  51540. /** Circle */
  51541. Circle = 1,
  51542. /** Square */
  51543. Square = 2,
  51544. /** Triangle */
  51545. Triangle = 3,
  51546. /** L1 */
  51547. L1 = 4,
  51548. /** R1 */
  51549. R1 = 5,
  51550. /** L2 */
  51551. L2 = 6,
  51552. /** R2 */
  51553. R2 = 7,
  51554. /** Share */
  51555. Share = 8,
  51556. /** Options */
  51557. Options = 9,
  51558. /** L3 */
  51559. L3 = 10,
  51560. /** R3 */
  51561. R3 = 11,
  51562. /** DPadUp */
  51563. DPadUp = 12,
  51564. /** DPadDown */
  51565. DPadDown = 13,
  51566. /** DPadLeft */
  51567. DPadLeft = 14,
  51568. /** DRight */
  51569. DPadRight = 15,
  51570. /** Home */
  51571. Home = 16,
  51572. /** TouchPad */
  51573. TouchPad = 17,
  51574. /** LStickXAxis */
  51575. LStickXAxis = 18,
  51576. /** LStickYAxis */
  51577. LStickYAxis = 19,
  51578. /** RStickXAxis */
  51579. RStickXAxis = 20,
  51580. /** RStickYAxis */
  51581. RStickYAxis = 21
  51582. }
  51583. /**
  51584. * Enum for Xbox Gamepad
  51585. */
  51586. export enum XboxInput {
  51587. /** A */
  51588. A = 0,
  51589. /** B */
  51590. B = 1,
  51591. /** X */
  51592. X = 2,
  51593. /** Y */
  51594. Y = 3,
  51595. /** LB */
  51596. LB = 4,
  51597. /** RB */
  51598. RB = 5,
  51599. /** LT */
  51600. LT = 6,
  51601. /** RT */
  51602. RT = 7,
  51603. /** Back */
  51604. Back = 8,
  51605. /** Start */
  51606. Start = 9,
  51607. /** LS */
  51608. LS = 10,
  51609. /** RS */
  51610. RS = 11,
  51611. /** DPadUp */
  51612. DPadUp = 12,
  51613. /** DPadDown */
  51614. DPadDown = 13,
  51615. /** DPadLeft */
  51616. DPadLeft = 14,
  51617. /** DRight */
  51618. DPadRight = 15,
  51619. /** Home */
  51620. Home = 16,
  51621. /** LStickXAxis */
  51622. LStickXAxis = 17,
  51623. /** LStickYAxis */
  51624. LStickYAxis = 18,
  51625. /** RStickXAxis */
  51626. RStickXAxis = 19,
  51627. /** RStickYAxis */
  51628. RStickYAxis = 20
  51629. }
  51630. /**
  51631. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51632. */
  51633. export enum SwitchInput {
  51634. /** B */
  51635. B = 0,
  51636. /** A */
  51637. A = 1,
  51638. /** Y */
  51639. Y = 2,
  51640. /** X */
  51641. X = 3,
  51642. /** L */
  51643. L = 4,
  51644. /** R */
  51645. R = 5,
  51646. /** ZL */
  51647. ZL = 6,
  51648. /** ZR */
  51649. ZR = 7,
  51650. /** Minus */
  51651. Minus = 8,
  51652. /** Plus */
  51653. Plus = 9,
  51654. /** LS */
  51655. LS = 10,
  51656. /** RS */
  51657. RS = 11,
  51658. /** DPadUp */
  51659. DPadUp = 12,
  51660. /** DPadDown */
  51661. DPadDown = 13,
  51662. /** DPadLeft */
  51663. DPadLeft = 14,
  51664. /** DRight */
  51665. DPadRight = 15,
  51666. /** Home */
  51667. Home = 16,
  51668. /** Capture */
  51669. Capture = 17,
  51670. /** LStickXAxis */
  51671. LStickXAxis = 18,
  51672. /** LStickYAxis */
  51673. LStickYAxis = 19,
  51674. /** RStickXAxis */
  51675. RStickXAxis = 20,
  51676. /** RStickYAxis */
  51677. RStickYAxis = 21
  51678. }
  51679. }
  51680. declare module BABYLON {
  51681. /**
  51682. * This class will take all inputs from Keyboard, Pointer, and
  51683. * any Gamepads and provide a polling system that all devices
  51684. * will use. This class assumes that there will only be one
  51685. * pointer device and one keyboard.
  51686. */
  51687. export class DeviceInputSystem implements IDisposable {
  51688. /**
  51689. * Callback to be triggered when a device is connected
  51690. */
  51691. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51692. /**
  51693. * Callback to be triggered when a device is disconnected
  51694. */
  51695. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51696. /**
  51697. * Callback to be triggered when event driven input is updated
  51698. */
  51699. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51700. private _inputs;
  51701. private _gamepads;
  51702. private _keyboardActive;
  51703. private _pointerActive;
  51704. private _elementToAttachTo;
  51705. private _keyboardDownEvent;
  51706. private _keyboardUpEvent;
  51707. private _pointerMoveEvent;
  51708. private _pointerDownEvent;
  51709. private _pointerUpEvent;
  51710. private _gamepadConnectedEvent;
  51711. private _gamepadDisconnectedEvent;
  51712. private static _MAX_KEYCODES;
  51713. private static _MAX_POINTER_INPUTS;
  51714. private constructor();
  51715. /**
  51716. * Creates a new DeviceInputSystem instance
  51717. * @param engine Engine to pull input element from
  51718. * @returns The new instance
  51719. */
  51720. static Create(engine: Engine): DeviceInputSystem;
  51721. /**
  51722. * Checks for current device input value, given an id and input index
  51723. * @param deviceName Id of connected device
  51724. * @param inputIndex Index of device input
  51725. * @returns Current value of input
  51726. */
  51727. /**
  51728. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51729. * @param deviceType Enum specifiying device type
  51730. * @param deviceSlot "Slot" or index that device is referenced in
  51731. * @param inputIndex Id of input to be checked
  51732. * @returns Current value of input
  51733. */
  51734. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51735. /**
  51736. * Dispose of all the eventlisteners
  51737. */
  51738. dispose(): void;
  51739. /**
  51740. * Add device and inputs to device array
  51741. * @param deviceType Enum specifiying device type
  51742. * @param deviceSlot "Slot" or index that device is referenced in
  51743. * @param numberOfInputs Number of input entries to create for given device
  51744. */
  51745. private _registerDevice;
  51746. /**
  51747. * Given a specific device name, remove that device from the device map
  51748. * @param deviceType Enum specifiying device type
  51749. * @param deviceSlot "Slot" or index that device is referenced in
  51750. */
  51751. private _unregisterDevice;
  51752. /**
  51753. * Handle all actions that come from keyboard interaction
  51754. */
  51755. private _handleKeyActions;
  51756. /**
  51757. * Handle all actions that come from pointer interaction
  51758. */
  51759. private _handlePointerActions;
  51760. /**
  51761. * Handle all actions that come from gamepad interaction
  51762. */
  51763. private _handleGamepadActions;
  51764. /**
  51765. * Update all non-event based devices with each frame
  51766. * @param deviceType Enum specifiying device type
  51767. * @param deviceSlot "Slot" or index that device is referenced in
  51768. * @param inputIndex Id of input to be checked
  51769. */
  51770. private _updateDevice;
  51771. /**
  51772. * Gets DeviceType from the device name
  51773. * @param deviceName Name of Device from DeviceInputSystem
  51774. * @returns DeviceType enum value
  51775. */
  51776. private _getGamepadDeviceType;
  51777. }
  51778. }
  51779. declare module BABYLON {
  51780. /**
  51781. * Type to handle enforcement of inputs
  51782. */
  51783. 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;
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Class that handles all input for a specific device
  51788. */
  51789. export class DeviceSource<T extends DeviceType> {
  51790. /** Type of device */
  51791. readonly deviceType: DeviceType;
  51792. /** "Slot" or index that device is referenced in */
  51793. readonly deviceSlot: number;
  51794. /**
  51795. * Observable to handle device input changes per device
  51796. */
  51797. readonly onInputChangedObservable: Observable<{
  51798. inputIndex: DeviceInput<T>;
  51799. previousState: Nullable<number>;
  51800. currentState: Nullable<number>;
  51801. }>;
  51802. private readonly _deviceInputSystem;
  51803. /**
  51804. * Default Constructor
  51805. * @param deviceInputSystem Reference to DeviceInputSystem
  51806. * @param deviceType Type of device
  51807. * @param deviceSlot "Slot" or index that device is referenced in
  51808. */
  51809. constructor(deviceInputSystem: DeviceInputSystem,
  51810. /** Type of device */
  51811. deviceType: DeviceType,
  51812. /** "Slot" or index that device is referenced in */
  51813. deviceSlot?: number);
  51814. /**
  51815. * Get input for specific input
  51816. * @param inputIndex index of specific input on device
  51817. * @returns Input value from DeviceInputSystem
  51818. */
  51819. getInput(inputIndex: DeviceInput<T>): number;
  51820. }
  51821. /**
  51822. * Class to keep track of devices
  51823. */
  51824. export class DeviceSourceManager implements IDisposable {
  51825. /**
  51826. * Observable to be triggered when before a device is connected
  51827. */
  51828. readonly onBeforeDeviceConnectedObservable: Observable<{
  51829. deviceType: DeviceType;
  51830. deviceSlot: number;
  51831. }>;
  51832. /**
  51833. * Observable to be triggered when before a device is disconnected
  51834. */
  51835. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51836. deviceType: DeviceType;
  51837. deviceSlot: number;
  51838. }>;
  51839. /**
  51840. * Observable to be triggered when after a device is connected
  51841. */
  51842. readonly onAfterDeviceConnectedObservable: Observable<{
  51843. deviceType: DeviceType;
  51844. deviceSlot: number;
  51845. }>;
  51846. /**
  51847. * Observable to be triggered when after a device is disconnected
  51848. */
  51849. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51850. deviceType: DeviceType;
  51851. deviceSlot: number;
  51852. }>;
  51853. private readonly _devices;
  51854. private readonly _firstDevice;
  51855. private readonly _deviceInputSystem;
  51856. /**
  51857. * Default Constructor
  51858. * @param engine engine to pull input element from
  51859. */
  51860. constructor(engine: Engine);
  51861. /**
  51862. * Gets a DeviceSource, given a type and slot
  51863. * @param deviceType Enum specifying device type
  51864. * @param deviceSlot "Slot" or index that device is referenced in
  51865. * @returns DeviceSource object
  51866. */
  51867. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51868. /**
  51869. * Gets an array of DeviceSource objects for a given device type
  51870. * @param deviceType Enum specifying device type
  51871. * @returns Array of DeviceSource objects
  51872. */
  51873. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51874. /**
  51875. * Dispose of DeviceInputSystem and other parts
  51876. */
  51877. dispose(): void;
  51878. /**
  51879. * Function to add device name to device list
  51880. * @param deviceType Enum specifying device type
  51881. * @param deviceSlot "Slot" or index that device is referenced in
  51882. */
  51883. private _addDevice;
  51884. /**
  51885. * Function to remove device name to device list
  51886. * @param deviceType Enum specifying device type
  51887. * @param deviceSlot "Slot" or index that device is referenced in
  51888. */
  51889. private _removeDevice;
  51890. /**
  51891. * Updates array storing first connected device of each type
  51892. * @param type Type of Device
  51893. */
  51894. private _updateFirstDevices;
  51895. }
  51896. }
  51897. declare module BABYLON {
  51898. /**
  51899. * Options to create the null engine
  51900. */
  51901. export class NullEngineOptions {
  51902. /**
  51903. * Render width (Default: 512)
  51904. */
  51905. renderWidth: number;
  51906. /**
  51907. * Render height (Default: 256)
  51908. */
  51909. renderHeight: number;
  51910. /**
  51911. * Texture size (Default: 512)
  51912. */
  51913. textureSize: number;
  51914. /**
  51915. * If delta time between frames should be constant
  51916. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51917. */
  51918. deterministicLockstep: boolean;
  51919. /**
  51920. * Maximum about of steps between frames (Default: 4)
  51921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51922. */
  51923. lockstepMaxSteps: number;
  51924. /**
  51925. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51926. */
  51927. useHighPrecisionMatrix?: boolean;
  51928. }
  51929. /**
  51930. * The null engine class provides support for headless version of babylon.js.
  51931. * This can be used in server side scenario or for testing purposes
  51932. */
  51933. export class NullEngine extends Engine {
  51934. private _options;
  51935. /**
  51936. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51937. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51938. * @returns true if engine is in deterministic lock step mode
  51939. */
  51940. isDeterministicLockStep(): boolean;
  51941. /**
  51942. * Gets the max steps when engine is running in deterministic lock step
  51943. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51944. * @returns the max steps
  51945. */
  51946. getLockstepMaxSteps(): number;
  51947. /**
  51948. * Gets the current hardware scaling level.
  51949. * By default the hardware scaling level is computed from the window device ratio.
  51950. * 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.
  51951. * @returns a number indicating the current hardware scaling level
  51952. */
  51953. getHardwareScalingLevel(): number;
  51954. constructor(options?: NullEngineOptions);
  51955. /**
  51956. * Creates a vertex buffer
  51957. * @param vertices the data for the vertex buffer
  51958. * @returns the new WebGL static buffer
  51959. */
  51960. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51961. /**
  51962. * Creates a new index buffer
  51963. * @param indices defines the content of the index buffer
  51964. * @param updatable defines if the index buffer must be updatable
  51965. * @returns a new webGL buffer
  51966. */
  51967. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51968. /**
  51969. * Clear the current render buffer or the current render target (if any is set up)
  51970. * @param color defines the color to use
  51971. * @param backBuffer defines if the back buffer must be cleared
  51972. * @param depth defines if the depth buffer must be cleared
  51973. * @param stencil defines if the stencil buffer must be cleared
  51974. */
  51975. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51976. /**
  51977. * Gets the current render width
  51978. * @param useScreen defines if screen size must be used (or the current render target if any)
  51979. * @returns a number defining the current render width
  51980. */
  51981. getRenderWidth(useScreen?: boolean): number;
  51982. /**
  51983. * Gets the current render height
  51984. * @param useScreen defines if screen size must be used (or the current render target if any)
  51985. * @returns a number defining the current render height
  51986. */
  51987. getRenderHeight(useScreen?: boolean): number;
  51988. /**
  51989. * Set the WebGL's viewport
  51990. * @param viewport defines the viewport element to be used
  51991. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51992. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51993. */
  51994. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51995. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51996. /**
  51997. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51998. * @param pipelineContext defines the pipeline context to use
  51999. * @param uniformsNames defines the list of uniform names
  52000. * @returns an array of webGL uniform locations
  52001. */
  52002. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52003. /**
  52004. * Gets the lsit of active attributes for a given webGL program
  52005. * @param pipelineContext defines the pipeline context to use
  52006. * @param attributesNames defines the list of attribute names to get
  52007. * @returns an array of indices indicating the offset of each attribute
  52008. */
  52009. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52010. /**
  52011. * Binds an effect to the webGL context
  52012. * @param effect defines the effect to bind
  52013. */
  52014. bindSamplers(effect: Effect): void;
  52015. /**
  52016. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52017. * @param effect defines the effect to activate
  52018. */
  52019. enableEffect(effect: Effect): void;
  52020. /**
  52021. * Set various states to the webGL context
  52022. * @param culling defines backface culling state
  52023. * @param zOffset defines the value to apply to zOffset (0 by default)
  52024. * @param force defines if states must be applied even if cache is up to date
  52025. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52026. */
  52027. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52028. /**
  52029. * Set the value of an uniform to an array of int32
  52030. * @param uniform defines the webGL uniform location where to store the value
  52031. * @param array defines the array of int32 to store
  52032. * @returns true if value was set
  52033. */
  52034. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52035. /**
  52036. * Set the value of an uniform to an array of int32 (stored as vec2)
  52037. * @param uniform defines the webGL uniform location where to store the value
  52038. * @param array defines the array of int32 to store
  52039. * @returns true if value was set
  52040. */
  52041. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52042. /**
  52043. * Set the value of an uniform to an array of int32 (stored as vec3)
  52044. * @param uniform defines the webGL uniform location where to store the value
  52045. * @param array defines the array of int32 to store
  52046. * @returns true if value was set
  52047. */
  52048. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52049. /**
  52050. * Set the value of an uniform to an array of int32 (stored as vec4)
  52051. * @param uniform defines the webGL uniform location where to store the value
  52052. * @param array defines the array of int32 to store
  52053. * @returns true if value was set
  52054. */
  52055. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52056. /**
  52057. * Set the value of an uniform to an array of float32
  52058. * @param uniform defines the webGL uniform location where to store the value
  52059. * @param array defines the array of float32 to store
  52060. * @returns true if value was set
  52061. */
  52062. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52063. /**
  52064. * Set the value of an uniform to an array of float32 (stored as vec2)
  52065. * @param uniform defines the webGL uniform location where to store the value
  52066. * @param array defines the array of float32 to store
  52067. * @returns true if value was set
  52068. */
  52069. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52070. /**
  52071. * Set the value of an uniform to an array of float32 (stored as vec3)
  52072. * @param uniform defines the webGL uniform location where to store the value
  52073. * @param array defines the array of float32 to store
  52074. * @returns true if value was set
  52075. */
  52076. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52077. /**
  52078. * Set the value of an uniform to an array of float32 (stored as vec4)
  52079. * @param uniform defines the webGL uniform location where to store the value
  52080. * @param array defines the array of float32 to store
  52081. * @returns true if value was set
  52082. */
  52083. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52084. /**
  52085. * Set the value of an uniform to an array of number
  52086. * @param uniform defines the webGL uniform location where to store the value
  52087. * @param array defines the array of number to store
  52088. * @returns true if value was set
  52089. */
  52090. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52091. /**
  52092. * Set the value of an uniform to an array of number (stored as vec2)
  52093. * @param uniform defines the webGL uniform location where to store the value
  52094. * @param array defines the array of number to store
  52095. * @returns true if value was set
  52096. */
  52097. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52098. /**
  52099. * Set the value of an uniform to an array of number (stored as vec3)
  52100. * @param uniform defines the webGL uniform location where to store the value
  52101. * @param array defines the array of number to store
  52102. * @returns true if value was set
  52103. */
  52104. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52105. /**
  52106. * Set the value of an uniform to an array of number (stored as vec4)
  52107. * @param uniform defines the webGL uniform location where to store the value
  52108. * @param array defines the array of number to store
  52109. * @returns true if value was set
  52110. */
  52111. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52112. /**
  52113. * Set the value of an uniform to an array of float32 (stored as matrices)
  52114. * @param uniform defines the webGL uniform location where to store the value
  52115. * @param matrices defines the array of float32 to store
  52116. * @returns true if value was set
  52117. */
  52118. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52119. /**
  52120. * Set the value of an uniform to a matrix (3x3)
  52121. * @param uniform defines the webGL uniform location where to store the value
  52122. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52123. * @returns true if value was set
  52124. */
  52125. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52126. /**
  52127. * Set the value of an uniform to a matrix (2x2)
  52128. * @param uniform defines the webGL uniform location where to store the value
  52129. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52130. * @returns true if value was set
  52131. */
  52132. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52133. /**
  52134. * Set the value of an uniform to a number (float)
  52135. * @param uniform defines the webGL uniform location where to store the value
  52136. * @param value defines the float number to store
  52137. * @returns true if value was set
  52138. */
  52139. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52140. /**
  52141. * Set the value of an uniform to a vec2
  52142. * @param uniform defines the webGL uniform location where to store the value
  52143. * @param x defines the 1st component of the value
  52144. * @param y defines the 2nd component of the value
  52145. * @returns true if value was set
  52146. */
  52147. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52148. /**
  52149. * Set the value of an uniform to a vec3
  52150. * @param uniform defines the webGL uniform location where to store the value
  52151. * @param x defines the 1st component of the value
  52152. * @param y defines the 2nd component of the value
  52153. * @param z defines the 3rd component of the value
  52154. * @returns true if value was set
  52155. */
  52156. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52157. /**
  52158. * Set the value of an uniform to a boolean
  52159. * @param uniform defines the webGL uniform location where to store the value
  52160. * @param bool defines the boolean to store
  52161. * @returns true if value was set
  52162. */
  52163. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52164. /**
  52165. * Set the value of an uniform to a vec4
  52166. * @param uniform defines the webGL uniform location where to store the value
  52167. * @param x defines the 1st component of the value
  52168. * @param y defines the 2nd component of the value
  52169. * @param z defines the 3rd component of the value
  52170. * @param w defines the 4th component of the value
  52171. * @returns true if value was set
  52172. */
  52173. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52174. /**
  52175. * Sets the current alpha mode
  52176. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52177. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52178. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52179. */
  52180. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52181. /**
  52182. * Bind webGl buffers directly to the webGL context
  52183. * @param vertexBuffers defines the vertex buffer to bind
  52184. * @param indexBuffer defines the index buffer to bind
  52185. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52186. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52187. * @param effect defines the effect associated with the vertex buffer
  52188. */
  52189. bindBuffers(vertexBuffers: {
  52190. [key: string]: VertexBuffer;
  52191. }, indexBuffer: DataBuffer, effect: Effect): void;
  52192. /**
  52193. * Force the entire cache to be cleared
  52194. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52195. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52196. */
  52197. wipeCaches(bruteForce?: boolean): void;
  52198. /**
  52199. * Send a draw order
  52200. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52201. * @param indexStart defines the starting index
  52202. * @param indexCount defines the number of index to draw
  52203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52204. */
  52205. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52206. /**
  52207. * Draw a list of indexed primitives
  52208. * @param fillMode defines the primitive to use
  52209. * @param indexStart defines the starting index
  52210. * @param indexCount defines the number of index to draw
  52211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52212. */
  52213. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52214. /**
  52215. * Draw a list of unindexed primitives
  52216. * @param fillMode defines the primitive to use
  52217. * @param verticesStart defines the index of first vertex to draw
  52218. * @param verticesCount defines the count of vertices to draw
  52219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52220. */
  52221. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52222. /** @hidden */
  52223. _createTexture(): WebGLTexture;
  52224. /** @hidden */
  52225. _releaseTexture(texture: InternalTexture): void;
  52226. /**
  52227. * Usually called from Texture.ts.
  52228. * Passed information to create a WebGLTexture
  52229. * @param urlArg defines a value which contains one of the following:
  52230. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52231. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52232. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52233. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52234. * @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)
  52235. * @param scene needed for loading to the correct scene
  52236. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52237. * @param onLoad optional callback to be called upon successful completion
  52238. * @param onError optional callback to be called upon failure
  52239. * @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
  52240. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52241. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52242. * @param forcedExtension defines the extension to use to pick the right loader
  52243. * @param mimeType defines an optional mime type
  52244. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52245. */
  52246. 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;
  52247. /**
  52248. * Creates a new render target texture
  52249. * @param size defines the size of the texture
  52250. * @param options defines the options used to create the texture
  52251. * @returns a new render target texture stored in an InternalTexture
  52252. */
  52253. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52254. /**
  52255. * Update the sampling mode of a given texture
  52256. * @param samplingMode defines the required sampling mode
  52257. * @param texture defines the texture to update
  52258. */
  52259. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52260. /**
  52261. * Binds the frame buffer to the specified texture.
  52262. * @param texture The texture to render to or null for the default canvas
  52263. * @param faceIndex The face of the texture to render to in case of cube texture
  52264. * @param requiredWidth The width of the target to render to
  52265. * @param requiredHeight The height of the target to render to
  52266. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52267. * @param lodLevel defines le lod level to bind to the frame buffer
  52268. */
  52269. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52270. /**
  52271. * Unbind the current render target texture from the webGL context
  52272. * @param texture defines the render target texture to unbind
  52273. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52274. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52275. */
  52276. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52277. /**
  52278. * Creates a dynamic vertex buffer
  52279. * @param vertices the data for the dynamic vertex buffer
  52280. * @returns the new WebGL dynamic buffer
  52281. */
  52282. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52283. /**
  52284. * Update the content of a dynamic texture
  52285. * @param texture defines the texture to update
  52286. * @param canvas defines the canvas containing the source
  52287. * @param invertY defines if data must be stored with Y axis inverted
  52288. * @param premulAlpha defines if alpha is stored as premultiplied
  52289. * @param format defines the format of the data
  52290. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52291. */
  52292. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52293. /**
  52294. * Gets a boolean indicating if all created effects are ready
  52295. * @returns true if all effects are ready
  52296. */
  52297. areAllEffectsReady(): boolean;
  52298. /**
  52299. * @hidden
  52300. * Get the current error code of the webGL context
  52301. * @returns the error code
  52302. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52303. */
  52304. getError(): number;
  52305. /** @hidden */
  52306. _getUnpackAlignement(): number;
  52307. /** @hidden */
  52308. _unpackFlipY(value: boolean): void;
  52309. /**
  52310. * Update a dynamic index buffer
  52311. * @param indexBuffer defines the target index buffer
  52312. * @param indices defines the data to update
  52313. * @param offset defines the offset in the target index buffer where update should start
  52314. */
  52315. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52316. /**
  52317. * Updates a dynamic vertex buffer.
  52318. * @param vertexBuffer the vertex buffer to update
  52319. * @param vertices the data used to update the vertex buffer
  52320. * @param byteOffset the byte offset of the data (optional)
  52321. * @param byteLength the byte length of the data (optional)
  52322. */
  52323. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52324. /** @hidden */
  52325. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52326. /** @hidden */
  52327. _bindTexture(channel: number, texture: InternalTexture): void;
  52328. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52329. /**
  52330. * 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
  52331. */
  52332. releaseEffects(): void;
  52333. displayLoadingUI(): void;
  52334. hideLoadingUI(): void;
  52335. /** @hidden */
  52336. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52337. /** @hidden */
  52338. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52339. /** @hidden */
  52340. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52341. /** @hidden */
  52342. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52343. }
  52344. }
  52345. declare module BABYLON {
  52346. /**
  52347. * @hidden
  52348. **/
  52349. export class _TimeToken {
  52350. _startTimeQuery: Nullable<WebGLQuery>;
  52351. _endTimeQuery: Nullable<WebGLQuery>;
  52352. _timeElapsedQuery: Nullable<WebGLQuery>;
  52353. _timeElapsedQueryEnded: boolean;
  52354. }
  52355. }
  52356. declare module BABYLON {
  52357. /** @hidden */
  52358. export class _OcclusionDataStorage {
  52359. /** @hidden */
  52360. occlusionInternalRetryCounter: number;
  52361. /** @hidden */
  52362. isOcclusionQueryInProgress: boolean;
  52363. /** @hidden */
  52364. isOccluded: boolean;
  52365. /** @hidden */
  52366. occlusionRetryCount: number;
  52367. /** @hidden */
  52368. occlusionType: number;
  52369. /** @hidden */
  52370. occlusionQueryAlgorithmType: number;
  52371. }
  52372. interface Engine {
  52373. /**
  52374. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52375. * @return the new query
  52376. */
  52377. createQuery(): WebGLQuery;
  52378. /**
  52379. * Delete and release a webGL query
  52380. * @param query defines the query to delete
  52381. * @return the current engine
  52382. */
  52383. deleteQuery(query: WebGLQuery): Engine;
  52384. /**
  52385. * Check if a given query has resolved and got its value
  52386. * @param query defines the query to check
  52387. * @returns true if the query got its value
  52388. */
  52389. isQueryResultAvailable(query: WebGLQuery): boolean;
  52390. /**
  52391. * Gets the value of a given query
  52392. * @param query defines the query to check
  52393. * @returns the value of the query
  52394. */
  52395. getQueryResult(query: WebGLQuery): number;
  52396. /**
  52397. * Initiates an occlusion query
  52398. * @param algorithmType defines the algorithm to use
  52399. * @param query defines the query to use
  52400. * @returns the current engine
  52401. * @see https://doc.babylonjs.com/features/occlusionquery
  52402. */
  52403. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52404. /**
  52405. * Ends an occlusion query
  52406. * @see https://doc.babylonjs.com/features/occlusionquery
  52407. * @param algorithmType defines the algorithm to use
  52408. * @returns the current engine
  52409. */
  52410. endOcclusionQuery(algorithmType: number): Engine;
  52411. /**
  52412. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52413. * Please note that only one query can be issued at a time
  52414. * @returns a time token used to track the time span
  52415. */
  52416. startTimeQuery(): Nullable<_TimeToken>;
  52417. /**
  52418. * Ends a time query
  52419. * @param token defines the token used to measure the time span
  52420. * @returns the time spent (in ns)
  52421. */
  52422. endTimeQuery(token: _TimeToken): int;
  52423. /** @hidden */
  52424. _currentNonTimestampToken: Nullable<_TimeToken>;
  52425. /** @hidden */
  52426. _createTimeQuery(): WebGLQuery;
  52427. /** @hidden */
  52428. _deleteTimeQuery(query: WebGLQuery): void;
  52429. /** @hidden */
  52430. _getGlAlgorithmType(algorithmType: number): number;
  52431. /** @hidden */
  52432. _getTimeQueryResult(query: WebGLQuery): any;
  52433. /** @hidden */
  52434. _getTimeQueryAvailability(query: WebGLQuery): any;
  52435. }
  52436. interface AbstractMesh {
  52437. /**
  52438. * Backing filed
  52439. * @hidden
  52440. */
  52441. __occlusionDataStorage: _OcclusionDataStorage;
  52442. /**
  52443. * Access property
  52444. * @hidden
  52445. */
  52446. _occlusionDataStorage: _OcclusionDataStorage;
  52447. /**
  52448. * 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.
  52449. * The default value is -1 which means don't break the query and wait till the result
  52450. * @see https://doc.babylonjs.com/features/occlusionquery
  52451. */
  52452. occlusionRetryCount: number;
  52453. /**
  52454. * 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:
  52455. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52456. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52457. * * 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.
  52458. * @see https://doc.babylonjs.com/features/occlusionquery
  52459. */
  52460. occlusionType: number;
  52461. /**
  52462. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52463. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52464. * * 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.
  52465. * @see https://doc.babylonjs.com/features/occlusionquery
  52466. */
  52467. occlusionQueryAlgorithmType: number;
  52468. /**
  52469. * 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
  52470. * @see https://doc.babylonjs.com/features/occlusionquery
  52471. */
  52472. isOccluded: boolean;
  52473. /**
  52474. * Flag to check the progress status of the query
  52475. * @see https://doc.babylonjs.com/features/occlusionquery
  52476. */
  52477. isOcclusionQueryInProgress: boolean;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /** @hidden */
  52482. export var _forceTransformFeedbackToBundle: boolean;
  52483. interface Engine {
  52484. /**
  52485. * Creates a webGL transform feedback object
  52486. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52487. * @returns the webGL transform feedback object
  52488. */
  52489. createTransformFeedback(): WebGLTransformFeedback;
  52490. /**
  52491. * Delete a webGL transform feedback object
  52492. * @param value defines the webGL transform feedback object to delete
  52493. */
  52494. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52495. /**
  52496. * Bind a webGL transform feedback object to the webgl context
  52497. * @param value defines the webGL transform feedback object to bind
  52498. */
  52499. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52500. /**
  52501. * Begins a transform feedback operation
  52502. * @param usePoints defines if points or triangles must be used
  52503. */
  52504. beginTransformFeedback(usePoints: boolean): void;
  52505. /**
  52506. * Ends a transform feedback operation
  52507. */
  52508. endTransformFeedback(): void;
  52509. /**
  52510. * Specify the varyings to use with transform feedback
  52511. * @param program defines the associated webGL program
  52512. * @param value defines the list of strings representing the varying names
  52513. */
  52514. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52515. /**
  52516. * Bind a webGL buffer for a transform feedback operation
  52517. * @param value defines the webGL buffer to bind
  52518. */
  52519. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52520. }
  52521. }
  52522. declare module BABYLON {
  52523. /**
  52524. * Class used to define an additional view for the engine
  52525. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52526. */
  52527. export class EngineView {
  52528. /** Defines the canvas where to render the view */
  52529. target: HTMLCanvasElement;
  52530. /** Defines an optional camera used to render the view (will use active camera else) */
  52531. camera?: Camera;
  52532. }
  52533. interface Engine {
  52534. /**
  52535. * Gets or sets the HTML element to use for attaching events
  52536. */
  52537. inputElement: Nullable<HTMLElement>;
  52538. /**
  52539. * Gets the current engine view
  52540. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52541. */
  52542. activeView: Nullable<EngineView>;
  52543. /** Gets or sets the list of views */
  52544. views: EngineView[];
  52545. /**
  52546. * Register a new child canvas
  52547. * @param canvas defines the canvas to register
  52548. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52549. * @returns the associated view
  52550. */
  52551. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52552. /**
  52553. * Remove a registered child canvas
  52554. * @param canvas defines the canvas to remove
  52555. * @returns the current engine
  52556. */
  52557. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. interface Engine {
  52562. /** @hidden */
  52563. _excludedCompressedTextures: string[];
  52564. /** @hidden */
  52565. _textureFormatInUse: string;
  52566. /**
  52567. * Gets the list of texture formats supported
  52568. */
  52569. readonly texturesSupported: Array<string>;
  52570. /**
  52571. * Gets the texture format in use
  52572. */
  52573. readonly textureFormatInUse: Nullable<string>;
  52574. /**
  52575. * Set the compressed texture extensions or file names to skip.
  52576. *
  52577. * @param skippedFiles defines the list of those texture files you want to skip
  52578. * Example: [".dds", ".env", "myfile.png"]
  52579. */
  52580. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52581. /**
  52582. * Set the compressed texture format to use, based on the formats you have, and the formats
  52583. * supported by the hardware / browser.
  52584. *
  52585. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52586. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52587. * to API arguments needed to compressed textures. This puts the burden on the container
  52588. * generator to house the arcane code for determining these for current & future formats.
  52589. *
  52590. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52591. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52592. *
  52593. * Note: The result of this call is not taken into account when a texture is base64.
  52594. *
  52595. * @param formatsAvailable defines the list of those format families you have created
  52596. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52597. *
  52598. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52599. * @returns The extension selected.
  52600. */
  52601. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52602. }
  52603. }
  52604. declare module BABYLON {
  52605. /**
  52606. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52607. */
  52608. export interface CubeMapInfo {
  52609. /**
  52610. * The pixel array for the front face.
  52611. * This is stored in format, left to right, up to down format.
  52612. */
  52613. front: Nullable<ArrayBufferView>;
  52614. /**
  52615. * The pixel array for the back face.
  52616. * This is stored in format, left to right, up to down format.
  52617. */
  52618. back: Nullable<ArrayBufferView>;
  52619. /**
  52620. * The pixel array for the left face.
  52621. * This is stored in format, left to right, up to down format.
  52622. */
  52623. left: Nullable<ArrayBufferView>;
  52624. /**
  52625. * The pixel array for the right face.
  52626. * This is stored in format, left to right, up to down format.
  52627. */
  52628. right: Nullable<ArrayBufferView>;
  52629. /**
  52630. * The pixel array for the up face.
  52631. * This is stored in format, left to right, up to down format.
  52632. */
  52633. up: Nullable<ArrayBufferView>;
  52634. /**
  52635. * The pixel array for the down face.
  52636. * This is stored in format, left to right, up to down format.
  52637. */
  52638. down: Nullable<ArrayBufferView>;
  52639. /**
  52640. * The size of the cubemap stored.
  52641. *
  52642. * Each faces will be size * size pixels.
  52643. */
  52644. size: number;
  52645. /**
  52646. * The format of the texture.
  52647. *
  52648. * RGBA, RGB.
  52649. */
  52650. format: number;
  52651. /**
  52652. * The type of the texture data.
  52653. *
  52654. * UNSIGNED_INT, FLOAT.
  52655. */
  52656. type: number;
  52657. /**
  52658. * Specifies whether the texture is in gamma space.
  52659. */
  52660. gammaSpace: boolean;
  52661. }
  52662. /**
  52663. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52664. */
  52665. export class PanoramaToCubeMapTools {
  52666. private static FACE_LEFT;
  52667. private static FACE_RIGHT;
  52668. private static FACE_FRONT;
  52669. private static FACE_BACK;
  52670. private static FACE_DOWN;
  52671. private static FACE_UP;
  52672. /**
  52673. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52674. *
  52675. * @param float32Array The source data.
  52676. * @param inputWidth The width of the input panorama.
  52677. * @param inputHeight The height of the input panorama.
  52678. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52679. * @return The cubemap data
  52680. */
  52681. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52682. private static CreateCubemapTexture;
  52683. private static CalcProjectionSpherical;
  52684. }
  52685. }
  52686. declare module BABYLON {
  52687. /**
  52688. * Helper class dealing with the extraction of spherical polynomial dataArray
  52689. * from a cube map.
  52690. */
  52691. export class CubeMapToSphericalPolynomialTools {
  52692. private static FileFaces;
  52693. /**
  52694. * Converts a texture to the according Spherical Polynomial data.
  52695. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52696. *
  52697. * @param texture The texture to extract the information from.
  52698. * @return The Spherical Polynomial data.
  52699. */
  52700. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52701. /**
  52702. * Converts a cubemap to the according Spherical Polynomial data.
  52703. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52704. *
  52705. * @param cubeInfo The Cube map to extract the information from.
  52706. * @return The Spherical Polynomial data.
  52707. */
  52708. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52709. }
  52710. }
  52711. declare module BABYLON {
  52712. interface BaseTexture {
  52713. /**
  52714. * Get the polynomial representation of the texture data.
  52715. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52716. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52717. */
  52718. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52719. }
  52720. }
  52721. declare module BABYLON {
  52722. /** @hidden */
  52723. export var rgbdEncodePixelShader: {
  52724. name: string;
  52725. shader: string;
  52726. };
  52727. }
  52728. declare module BABYLON {
  52729. /** @hidden */
  52730. export var rgbdDecodePixelShader: {
  52731. name: string;
  52732. shader: string;
  52733. };
  52734. }
  52735. declare module BABYLON {
  52736. /**
  52737. * Raw texture data and descriptor sufficient for WebGL texture upload
  52738. */
  52739. export interface EnvironmentTextureInfo {
  52740. /**
  52741. * Version of the environment map
  52742. */
  52743. version: number;
  52744. /**
  52745. * Width of image
  52746. */
  52747. width: number;
  52748. /**
  52749. * Irradiance information stored in the file.
  52750. */
  52751. irradiance: any;
  52752. /**
  52753. * Specular information stored in the file.
  52754. */
  52755. specular: any;
  52756. }
  52757. /**
  52758. * Defines One Image in the file. It requires only the position in the file
  52759. * as well as the length.
  52760. */
  52761. interface BufferImageData {
  52762. /**
  52763. * Length of the image data.
  52764. */
  52765. length: number;
  52766. /**
  52767. * Position of the data from the null terminator delimiting the end of the JSON.
  52768. */
  52769. position: number;
  52770. }
  52771. /**
  52772. * Defines the specular data enclosed in the file.
  52773. * This corresponds to the version 1 of the data.
  52774. */
  52775. export interface EnvironmentTextureSpecularInfoV1 {
  52776. /**
  52777. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52778. */
  52779. specularDataPosition?: number;
  52780. /**
  52781. * This contains all the images data needed to reconstruct the cubemap.
  52782. */
  52783. mipmaps: Array<BufferImageData>;
  52784. /**
  52785. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52786. */
  52787. lodGenerationScale: number;
  52788. }
  52789. /**
  52790. * Sets of helpers addressing the serialization and deserialization of environment texture
  52791. * stored in a BabylonJS env file.
  52792. * Those files are usually stored as .env files.
  52793. */
  52794. export class EnvironmentTextureTools {
  52795. /**
  52796. * Magic number identifying the env file.
  52797. */
  52798. private static _MagicBytes;
  52799. /**
  52800. * Gets the environment info from an env file.
  52801. * @param data The array buffer containing the .env bytes.
  52802. * @returns the environment file info (the json header) if successfully parsed.
  52803. */
  52804. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52805. /**
  52806. * Creates an environment texture from a loaded cube texture.
  52807. * @param texture defines the cube texture to convert in env file
  52808. * @return a promise containing the environment data if succesfull.
  52809. */
  52810. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52811. /**
  52812. * Creates a JSON representation of the spherical data.
  52813. * @param texture defines the texture containing the polynomials
  52814. * @return the JSON representation of the spherical info
  52815. */
  52816. private static _CreateEnvTextureIrradiance;
  52817. /**
  52818. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52819. * @param data the image data
  52820. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52821. * @return the views described by info providing access to the underlying buffer
  52822. */
  52823. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52824. /**
  52825. * Uploads the texture info contained in the env file to the GPU.
  52826. * @param texture defines the internal texture to upload to
  52827. * @param data defines the data to load
  52828. * @param info defines the texture info retrieved through the GetEnvInfo method
  52829. * @returns a promise
  52830. */
  52831. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52832. private static _OnImageReadyAsync;
  52833. /**
  52834. * Uploads the levels of image data to the GPU.
  52835. * @param texture defines the internal texture to upload to
  52836. * @param imageData defines the array buffer views of image data [mipmap][face]
  52837. * @returns a promise
  52838. */
  52839. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52840. /**
  52841. * Uploads spherical polynomials information to the texture.
  52842. * @param texture defines the texture we are trying to upload the information to
  52843. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52844. */
  52845. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52846. /** @hidden */
  52847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52848. }
  52849. }
  52850. declare module BABYLON {
  52851. /**
  52852. * Class used to inline functions in shader code
  52853. */
  52854. export class ShaderCodeInliner {
  52855. private static readonly _RegexpFindFunctionNameAndType;
  52856. private _sourceCode;
  52857. private _functionDescr;
  52858. private _numMaxIterations;
  52859. /** Gets or sets the token used to mark the functions to inline */
  52860. inlineToken: string;
  52861. /** Gets or sets the debug mode */
  52862. debug: boolean;
  52863. /** Gets the code after the inlining process */
  52864. get code(): string;
  52865. /**
  52866. * Initializes the inliner
  52867. * @param sourceCode shader code source to inline
  52868. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52869. */
  52870. constructor(sourceCode: string, numMaxIterations?: number);
  52871. /**
  52872. * Start the processing of the shader code
  52873. */
  52874. processCode(): void;
  52875. private _collectFunctions;
  52876. private _processInlining;
  52877. private _extractBetweenMarkers;
  52878. private _skipWhitespaces;
  52879. private _removeComments;
  52880. private _replaceFunctionCallsByCode;
  52881. private _findBackward;
  52882. private _escapeRegExp;
  52883. private _replaceNames;
  52884. }
  52885. }
  52886. declare module BABYLON {
  52887. /**
  52888. * Container for accessors for natively-stored mesh data buffers.
  52889. */
  52890. class NativeDataBuffer extends DataBuffer {
  52891. /**
  52892. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52893. */
  52894. nativeIndexBuffer?: any;
  52895. /**
  52896. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52897. */
  52898. nativeVertexBuffer?: any;
  52899. }
  52900. /** @hidden */
  52901. class NativeTexture extends InternalTexture {
  52902. getInternalTexture(): InternalTexture;
  52903. getViewCount(): number;
  52904. }
  52905. /** @hidden */
  52906. export class NativeEngine extends Engine {
  52907. private readonly _native;
  52908. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52909. private readonly INVALID_HANDLE;
  52910. private _boundBuffersVertexArray;
  52911. private _currentDepthTest;
  52912. getHardwareScalingLevel(): number;
  52913. constructor();
  52914. dispose(): void;
  52915. /**
  52916. * Can be used to override the current requestAnimationFrame requester.
  52917. * @hidden
  52918. */
  52919. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52920. /**
  52921. * Override default engine behavior.
  52922. * @param color
  52923. * @param backBuffer
  52924. * @param depth
  52925. * @param stencil
  52926. */
  52927. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52928. /**
  52929. * Gets host document
  52930. * @returns the host document object
  52931. */
  52932. getHostDocument(): Nullable<Document>;
  52933. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52934. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52935. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52936. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52937. [key: string]: VertexBuffer;
  52938. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52939. bindBuffers(vertexBuffers: {
  52940. [key: string]: VertexBuffer;
  52941. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52942. recordVertexArrayObject(vertexBuffers: {
  52943. [key: string]: VertexBuffer;
  52944. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52945. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52946. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52948. /**
  52949. * Draw a list of indexed primitives
  52950. * @param fillMode defines the primitive to use
  52951. * @param indexStart defines the starting index
  52952. * @param indexCount defines the number of index to draw
  52953. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52954. */
  52955. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52956. /**
  52957. * Draw a list of unindexed primitives
  52958. * @param fillMode defines the primitive to use
  52959. * @param verticesStart defines the index of first vertex to draw
  52960. * @param verticesCount defines the count of vertices to draw
  52961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52962. */
  52963. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52964. createPipelineContext(): IPipelineContext;
  52965. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52966. /** @hidden */
  52967. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52968. /** @hidden */
  52969. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52970. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52971. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52972. protected _setProgram(program: WebGLProgram): void;
  52973. _releaseEffect(effect: Effect): void;
  52974. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52975. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52976. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52977. bindSamplers(effect: Effect): void;
  52978. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52979. getRenderWidth(useScreen?: boolean): number;
  52980. getRenderHeight(useScreen?: boolean): number;
  52981. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52982. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52983. /**
  52984. * Set the z offset to apply to current rendering
  52985. * @param value defines the offset to apply
  52986. */
  52987. setZOffset(value: number): void;
  52988. /**
  52989. * Gets the current value of the zOffset
  52990. * @returns the current zOffset state
  52991. */
  52992. getZOffset(): number;
  52993. /**
  52994. * Enable or disable depth buffering
  52995. * @param enable defines the state to set
  52996. */
  52997. setDepthBuffer(enable: boolean): void;
  52998. /**
  52999. * Gets a boolean indicating if depth writing is enabled
  53000. * @returns the current depth writing state
  53001. */
  53002. getDepthWrite(): boolean;
  53003. setDepthFunctionToGreater(): void;
  53004. setDepthFunctionToGreaterOrEqual(): void;
  53005. setDepthFunctionToLess(): void;
  53006. setDepthFunctionToLessOrEqual(): void;
  53007. /**
  53008. * Enable or disable depth writing
  53009. * @param enable defines the state to set
  53010. */
  53011. setDepthWrite(enable: boolean): void;
  53012. /**
  53013. * Enable or disable color writing
  53014. * @param enable defines the state to set
  53015. */
  53016. setColorWrite(enable: boolean): void;
  53017. /**
  53018. * Gets a boolean indicating if color writing is enabled
  53019. * @returns the current color writing state
  53020. */
  53021. getColorWrite(): boolean;
  53022. /**
  53023. * Sets alpha constants used by some alpha blending modes
  53024. * @param r defines the red component
  53025. * @param g defines the green component
  53026. * @param b defines the blue component
  53027. * @param a defines the alpha component
  53028. */
  53029. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53030. /**
  53031. * Sets the current alpha mode
  53032. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53033. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53034. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53035. */
  53036. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53037. /**
  53038. * Gets the current alpha mode
  53039. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53040. * @returns the current alpha mode
  53041. */
  53042. getAlphaMode(): number;
  53043. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53044. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53045. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53046. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53047. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53048. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53049. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53050. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53051. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53052. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53053. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53054. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53055. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53056. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53057. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53058. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53059. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53060. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53061. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53062. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53063. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53064. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53065. wipeCaches(bruteForce?: boolean): void;
  53066. _createTexture(): WebGLTexture;
  53067. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53068. /**
  53069. * Usually called from Texture.ts.
  53070. * Passed information to create a WebGLTexture
  53071. * @param url defines a value which contains one of the following:
  53072. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53073. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53074. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53076. * @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)
  53077. * @param scene needed for loading to the correct scene
  53078. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53079. * @param onLoad optional callback to be called upon successful completion
  53080. * @param onError optional callback to be called upon failure
  53081. * @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
  53082. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53083. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53084. * @param forcedExtension defines the extension to use to pick the right loader
  53085. * @param mimeType defines an optional mime type
  53086. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53087. */
  53088. 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;
  53089. /**
  53090. * Creates a cube texture
  53091. * @param rootUrl defines the url where the files to load is located
  53092. * @param scene defines the current scene
  53093. * @param files defines the list of files to load (1 per face)
  53094. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53095. * @param onLoad defines an optional callback raised when the texture is loaded
  53096. * @param onError defines an optional callback raised if there is an issue to load the texture
  53097. * @param format defines the format of the data
  53098. * @param forcedExtension defines the extension to use to pick the right loader
  53099. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53100. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53101. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53102. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53103. * @returns the cube texture as an InternalTexture
  53104. */
  53105. 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;
  53106. private _getSamplingFilter;
  53107. private static _GetNativeTextureFormat;
  53108. createRenderTargetTexture(size: number | {
  53109. width: number;
  53110. height: number;
  53111. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53112. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53113. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53114. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53115. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53116. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53117. /**
  53118. * Updates a dynamic vertex buffer.
  53119. * @param vertexBuffer the vertex buffer to update
  53120. * @param data the data used to update the vertex buffer
  53121. * @param byteOffset the byte offset of the data (optional)
  53122. * @param byteLength the byte length of the data (optional)
  53123. */
  53124. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53125. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53126. private _updateAnisotropicLevel;
  53127. private _getAddressMode;
  53128. /** @hidden */
  53129. _bindTexture(channel: number, texture: InternalTexture): void;
  53130. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53131. releaseEffects(): void;
  53132. /** @hidden */
  53133. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53134. /** @hidden */
  53135. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53136. /** @hidden */
  53137. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53138. /** @hidden */
  53139. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53140. }
  53141. }
  53142. declare module BABYLON {
  53143. /**
  53144. * Gather the list of clipboard event types as constants.
  53145. */
  53146. export class ClipboardEventTypes {
  53147. /**
  53148. * The clipboard event is fired when a copy command is active (pressed).
  53149. */
  53150. static readonly COPY: number;
  53151. /**
  53152. * The clipboard event is fired when a cut command is active (pressed).
  53153. */
  53154. static readonly CUT: number;
  53155. /**
  53156. * The clipboard event is fired when a paste command is active (pressed).
  53157. */
  53158. static readonly PASTE: number;
  53159. }
  53160. /**
  53161. * This class is used to store clipboard related info for the onClipboardObservable event.
  53162. */
  53163. export class ClipboardInfo {
  53164. /**
  53165. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53166. */
  53167. type: number;
  53168. /**
  53169. * Defines the related dom event
  53170. */
  53171. event: ClipboardEvent;
  53172. /**
  53173. *Creates an instance of ClipboardInfo.
  53174. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53175. * @param event Defines the related dom event
  53176. */
  53177. constructor(
  53178. /**
  53179. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53180. */
  53181. type: number,
  53182. /**
  53183. * Defines the related dom event
  53184. */
  53185. event: ClipboardEvent);
  53186. /**
  53187. * Get the clipboard event's type from the keycode.
  53188. * @param keyCode Defines the keyCode for the current keyboard event.
  53189. * @return {number}
  53190. */
  53191. static GetTypeFromCharacter(keyCode: number): number;
  53192. }
  53193. }
  53194. declare module BABYLON {
  53195. /**
  53196. * Google Daydream controller
  53197. */
  53198. export class DaydreamController extends WebVRController {
  53199. /**
  53200. * Base Url for the controller model.
  53201. */
  53202. static MODEL_BASE_URL: string;
  53203. /**
  53204. * File name for the controller model.
  53205. */
  53206. static MODEL_FILENAME: string;
  53207. /**
  53208. * Gamepad Id prefix used to identify Daydream Controller.
  53209. */
  53210. static readonly GAMEPAD_ID_PREFIX: string;
  53211. /**
  53212. * Creates a new DaydreamController from a gamepad
  53213. * @param vrGamepad the gamepad that the controller should be created from
  53214. */
  53215. constructor(vrGamepad: any);
  53216. /**
  53217. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53218. * @param scene scene in which to add meshes
  53219. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53220. */
  53221. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53222. /**
  53223. * Called once for each button that changed state since the last frame
  53224. * @param buttonIdx Which button index changed
  53225. * @param state New state of the button
  53226. * @param changes Which properties on the state changed since last frame
  53227. */
  53228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53229. }
  53230. }
  53231. declare module BABYLON {
  53232. /**
  53233. * Gear VR Controller
  53234. */
  53235. export class GearVRController extends WebVRController {
  53236. /**
  53237. * Base Url for the controller model.
  53238. */
  53239. static MODEL_BASE_URL: string;
  53240. /**
  53241. * File name for the controller model.
  53242. */
  53243. static MODEL_FILENAME: string;
  53244. /**
  53245. * Gamepad Id prefix used to identify this controller.
  53246. */
  53247. static readonly GAMEPAD_ID_PREFIX: string;
  53248. private readonly _buttonIndexToObservableNameMap;
  53249. /**
  53250. * Creates a new GearVRController from a gamepad
  53251. * @param vrGamepad the gamepad that the controller should be created from
  53252. */
  53253. constructor(vrGamepad: any);
  53254. /**
  53255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53256. * @param scene scene in which to add meshes
  53257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53258. */
  53259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53260. /**
  53261. * Called once for each button that changed state since the last frame
  53262. * @param buttonIdx Which button index changed
  53263. * @param state New state of the button
  53264. * @param changes Which properties on the state changed since last frame
  53265. */
  53266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53267. }
  53268. }
  53269. declare module BABYLON {
  53270. /**
  53271. * Generic Controller
  53272. */
  53273. export class GenericController extends WebVRController {
  53274. /**
  53275. * Base Url for the controller model.
  53276. */
  53277. static readonly MODEL_BASE_URL: string;
  53278. /**
  53279. * File name for the controller model.
  53280. */
  53281. static readonly MODEL_FILENAME: string;
  53282. /**
  53283. * Creates a new GenericController from a gamepad
  53284. * @param vrGamepad the gamepad that the controller should be created from
  53285. */
  53286. constructor(vrGamepad: any);
  53287. /**
  53288. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53289. * @param scene scene in which to add meshes
  53290. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53291. */
  53292. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53293. /**
  53294. * Called once for each button that changed state since the last frame
  53295. * @param buttonIdx Which button index changed
  53296. * @param state New state of the button
  53297. * @param changes Which properties on the state changed since last frame
  53298. */
  53299. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Oculus Touch Controller
  53305. */
  53306. export class OculusTouchController extends WebVRController {
  53307. /**
  53308. * Base Url for the controller model.
  53309. */
  53310. static MODEL_BASE_URL: string;
  53311. /**
  53312. * File name for the left controller model.
  53313. */
  53314. static MODEL_LEFT_FILENAME: string;
  53315. /**
  53316. * File name for the right controller model.
  53317. */
  53318. static MODEL_RIGHT_FILENAME: string;
  53319. /**
  53320. * Base Url for the Quest controller model.
  53321. */
  53322. static QUEST_MODEL_BASE_URL: string;
  53323. /**
  53324. * @hidden
  53325. * If the controllers are running on a device that needs the updated Quest controller models
  53326. */
  53327. static _IsQuest: boolean;
  53328. /**
  53329. * Fired when the secondary trigger on this controller is modified
  53330. */
  53331. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53332. /**
  53333. * Fired when the thumb rest on this controller is modified
  53334. */
  53335. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53336. /**
  53337. * Creates a new OculusTouchController from a gamepad
  53338. * @param vrGamepad the gamepad that the controller should be created from
  53339. */
  53340. constructor(vrGamepad: any);
  53341. /**
  53342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53343. * @param scene scene in which to add meshes
  53344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53345. */
  53346. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53347. /**
  53348. * Fired when the A button on this controller is modified
  53349. */
  53350. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53351. /**
  53352. * Fired when the B button on this controller is modified
  53353. */
  53354. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53355. /**
  53356. * Fired when the X button on this controller is modified
  53357. */
  53358. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53359. /**
  53360. * Fired when the Y button on this controller is modified
  53361. */
  53362. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53363. /**
  53364. * Called once for each button that changed state since the last frame
  53365. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53366. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53367. * 2) secondary trigger (same)
  53368. * 3) A (right) X (left), touch, pressed = value
  53369. * 4) B / Y
  53370. * 5) thumb rest
  53371. * @param buttonIdx Which button index changed
  53372. * @param state New state of the button
  53373. * @param changes Which properties on the state changed since last frame
  53374. */
  53375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53376. }
  53377. }
  53378. declare module BABYLON {
  53379. /**
  53380. * Vive Controller
  53381. */
  53382. export class ViveController extends WebVRController {
  53383. /**
  53384. * Base Url for the controller model.
  53385. */
  53386. static MODEL_BASE_URL: string;
  53387. /**
  53388. * File name for the controller model.
  53389. */
  53390. static MODEL_FILENAME: string;
  53391. /**
  53392. * Creates a new ViveController from a gamepad
  53393. * @param vrGamepad the gamepad that the controller should be created from
  53394. */
  53395. constructor(vrGamepad: any);
  53396. /**
  53397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53398. * @param scene scene in which to add meshes
  53399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53400. */
  53401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53402. /**
  53403. * Fired when the left button on this controller is modified
  53404. */
  53405. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53406. /**
  53407. * Fired when the right button on this controller is modified
  53408. */
  53409. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53410. /**
  53411. * Fired when the menu button on this controller is modified
  53412. */
  53413. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53414. /**
  53415. * Called once for each button that changed state since the last frame
  53416. * Vive mapping:
  53417. * 0: touchpad
  53418. * 1: trigger
  53419. * 2: left AND right buttons
  53420. * 3: menu button
  53421. * @param buttonIdx Which button index changed
  53422. * @param state New state of the button
  53423. * @param changes Which properties on the state changed since last frame
  53424. */
  53425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53426. }
  53427. }
  53428. declare module BABYLON {
  53429. /**
  53430. * Defines the WindowsMotionController object that the state of the windows motion controller
  53431. */
  53432. export class WindowsMotionController extends WebVRController {
  53433. /**
  53434. * The base url used to load the left and right controller models
  53435. */
  53436. static MODEL_BASE_URL: string;
  53437. /**
  53438. * The name of the left controller model file
  53439. */
  53440. static MODEL_LEFT_FILENAME: string;
  53441. /**
  53442. * The name of the right controller model file
  53443. */
  53444. static MODEL_RIGHT_FILENAME: string;
  53445. /**
  53446. * The controller name prefix for this controller type
  53447. */
  53448. static readonly GAMEPAD_ID_PREFIX: string;
  53449. /**
  53450. * The controller id pattern for this controller type
  53451. */
  53452. private static readonly GAMEPAD_ID_PATTERN;
  53453. private _loadedMeshInfo;
  53454. protected readonly _mapping: {
  53455. buttons: string[];
  53456. buttonMeshNames: {
  53457. trigger: string;
  53458. menu: string;
  53459. grip: string;
  53460. thumbstick: string;
  53461. trackpad: string;
  53462. };
  53463. buttonObservableNames: {
  53464. trigger: string;
  53465. menu: string;
  53466. grip: string;
  53467. thumbstick: string;
  53468. trackpad: string;
  53469. };
  53470. axisMeshNames: string[];
  53471. pointingPoseMeshName: string;
  53472. };
  53473. /**
  53474. * Fired when the trackpad on this controller is clicked
  53475. */
  53476. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53477. /**
  53478. * Fired when the trackpad on this controller is modified
  53479. */
  53480. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53481. /**
  53482. * The current x and y values of this controller's trackpad
  53483. */
  53484. trackpad: StickValues;
  53485. /**
  53486. * Creates a new WindowsMotionController from a gamepad
  53487. * @param vrGamepad the gamepad that the controller should be created from
  53488. */
  53489. constructor(vrGamepad: any);
  53490. /**
  53491. * Fired when the trigger on this controller is modified
  53492. */
  53493. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53494. /**
  53495. * Fired when the menu button on this controller is modified
  53496. */
  53497. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53498. /**
  53499. * Fired when the grip button on this controller is modified
  53500. */
  53501. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53502. /**
  53503. * Fired when the thumbstick button on this controller is modified
  53504. */
  53505. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53506. /**
  53507. * Fired when the touchpad button on this controller is modified
  53508. */
  53509. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53510. /**
  53511. * Fired when the touchpad values on this controller are modified
  53512. */
  53513. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53514. protected _updateTrackpad(): void;
  53515. /**
  53516. * Called once per frame by the engine.
  53517. */
  53518. update(): void;
  53519. /**
  53520. * Called once for each button that changed state since the last frame
  53521. * @param buttonIdx Which button index changed
  53522. * @param state New state of the button
  53523. * @param changes Which properties on the state changed since last frame
  53524. */
  53525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53526. /**
  53527. * Moves the buttons on the controller mesh based on their current state
  53528. * @param buttonName the name of the button to move
  53529. * @param buttonValue the value of the button which determines the buttons new position
  53530. */
  53531. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53532. /**
  53533. * Moves the axis on the controller mesh based on its current state
  53534. * @param axis the index of the axis
  53535. * @param axisValue the value of the axis which determines the meshes new position
  53536. * @hidden
  53537. */
  53538. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53539. /**
  53540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53541. * @param scene scene in which to add meshes
  53542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53543. */
  53544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53545. /**
  53546. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53547. * can be transformed by button presses and axes values, based on this._mapping.
  53548. *
  53549. * @param scene scene in which the meshes exist
  53550. * @param meshes list of meshes that make up the controller model to process
  53551. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53552. */
  53553. private processModel;
  53554. private createMeshInfo;
  53555. /**
  53556. * Gets the ray of the controller in the direction the controller is pointing
  53557. * @param length the length the resulting ray should be
  53558. * @returns a ray in the direction the controller is pointing
  53559. */
  53560. getForwardRay(length?: number): Ray;
  53561. /**
  53562. * Disposes of the controller
  53563. */
  53564. dispose(): void;
  53565. }
  53566. /**
  53567. * This class represents a new windows motion controller in XR.
  53568. */
  53569. export class XRWindowsMotionController extends WindowsMotionController {
  53570. /**
  53571. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53572. */
  53573. protected readonly _mapping: {
  53574. buttons: string[];
  53575. buttonMeshNames: {
  53576. trigger: string;
  53577. menu: string;
  53578. grip: string;
  53579. thumbstick: string;
  53580. trackpad: string;
  53581. };
  53582. buttonObservableNames: {
  53583. trigger: string;
  53584. menu: string;
  53585. grip: string;
  53586. thumbstick: string;
  53587. trackpad: string;
  53588. };
  53589. axisMeshNames: string[];
  53590. pointingPoseMeshName: string;
  53591. };
  53592. /**
  53593. * Construct a new XR-Based windows motion controller
  53594. *
  53595. * @param gamepadInfo the gamepad object from the browser
  53596. */
  53597. constructor(gamepadInfo: any);
  53598. /**
  53599. * holds the thumbstick values (X,Y)
  53600. */
  53601. thumbstickValues: StickValues;
  53602. /**
  53603. * Fired when the thumbstick on this controller is clicked
  53604. */
  53605. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53606. /**
  53607. * Fired when the thumbstick on this controller is modified
  53608. */
  53609. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53610. /**
  53611. * Fired when the touchpad button on this controller is modified
  53612. */
  53613. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53614. /**
  53615. * Fired when the touchpad values on this controller are modified
  53616. */
  53617. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53618. /**
  53619. * Fired when the thumbstick button on this controller is modified
  53620. * here to prevent breaking changes
  53621. */
  53622. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53623. /**
  53624. * updating the thumbstick(!) and not the trackpad.
  53625. * This is named this way due to the difference between WebVR and XR and to avoid
  53626. * changing the parent class.
  53627. */
  53628. protected _updateTrackpad(): void;
  53629. /**
  53630. * Disposes the class with joy
  53631. */
  53632. dispose(): void;
  53633. }
  53634. }
  53635. declare module BABYLON {
  53636. /**
  53637. * Class containing static functions to help procedurally build meshes
  53638. */
  53639. export class PolyhedronBuilder {
  53640. /**
  53641. * Creates a polyhedron mesh
  53642. * * 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
  53643. * * The parameter `size` (positive float, default 1) sets the polygon size
  53644. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53645. * * 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`
  53646. * * 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
  53647. * * 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)`)
  53648. * * 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
  53649. * * 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
  53650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53651. * * 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
  53652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53653. * @param name defines the name of the mesh
  53654. * @param options defines the options used to create the mesh
  53655. * @param scene defines the hosting scene
  53656. * @returns the polyhedron mesh
  53657. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53658. */
  53659. static CreatePolyhedron(name: string, options: {
  53660. type?: number;
  53661. size?: number;
  53662. sizeX?: number;
  53663. sizeY?: number;
  53664. sizeZ?: number;
  53665. custom?: any;
  53666. faceUV?: Vector4[];
  53667. faceColors?: Color4[];
  53668. flat?: boolean;
  53669. updatable?: boolean;
  53670. sideOrientation?: number;
  53671. frontUVs?: Vector4;
  53672. backUVs?: Vector4;
  53673. }, scene?: Nullable<Scene>): Mesh;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Gizmo that enables scaling a mesh along 3 axis
  53679. */
  53680. export class ScaleGizmo extends Gizmo {
  53681. /**
  53682. * Internal gizmo used for interactions on the x axis
  53683. */
  53684. xGizmo: AxisScaleGizmo;
  53685. /**
  53686. * Internal gizmo used for interactions on the y axis
  53687. */
  53688. yGizmo: AxisScaleGizmo;
  53689. /**
  53690. * Internal gizmo used for interactions on the z axis
  53691. */
  53692. zGizmo: AxisScaleGizmo;
  53693. /**
  53694. * Internal gizmo used to scale all axis equally
  53695. */
  53696. uniformScaleGizmo: AxisScaleGizmo;
  53697. private _meshAttached;
  53698. private _nodeAttached;
  53699. private _snapDistance;
  53700. private _uniformScalingMesh;
  53701. private _octahedron;
  53702. private _sensitivity;
  53703. /** Fires an event when any of it's sub gizmos are dragged */
  53704. onDragStartObservable: Observable<unknown>;
  53705. /** Fires an event when any of it's sub gizmos are released from dragging */
  53706. onDragEndObservable: Observable<unknown>;
  53707. get attachedMesh(): Nullable<AbstractMesh>;
  53708. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53709. get attachedNode(): Nullable<Node>;
  53710. set attachedNode(node: Nullable<Node>);
  53711. /**
  53712. * True when the mouse pointer is hovering a gizmo mesh
  53713. */
  53714. get isHovered(): boolean;
  53715. /**
  53716. * Creates a ScaleGizmo
  53717. * @param gizmoLayer The utility layer the gizmo will be added to
  53718. * @param thickness display gizmo axis thickness
  53719. */
  53720. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53721. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53722. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53723. /**
  53724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53725. */
  53726. set snapDistance(value: number);
  53727. get snapDistance(): number;
  53728. /**
  53729. * Ratio for the scale of the gizmo (Default: 1)
  53730. */
  53731. set scaleRatio(value: number);
  53732. get scaleRatio(): number;
  53733. /**
  53734. * Sensitivity factor for dragging (Default: 1)
  53735. */
  53736. set sensitivity(value: number);
  53737. get sensitivity(): number;
  53738. /**
  53739. * Disposes of the gizmo
  53740. */
  53741. dispose(): void;
  53742. }
  53743. }
  53744. declare module BABYLON {
  53745. /**
  53746. * Single axis scale gizmo
  53747. */
  53748. export class AxisScaleGizmo extends Gizmo {
  53749. /**
  53750. * Drag behavior responsible for the gizmos dragging interactions
  53751. */
  53752. dragBehavior: PointerDragBehavior;
  53753. private _pointerObserver;
  53754. /**
  53755. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53756. */
  53757. snapDistance: number;
  53758. /**
  53759. * Event that fires each time the gizmo snaps to a new location.
  53760. * * snapDistance is the the change in distance
  53761. */
  53762. onSnapObservable: Observable<{
  53763. snapDistance: number;
  53764. }>;
  53765. /**
  53766. * If the scaling operation should be done on all axis (default: false)
  53767. */
  53768. uniformScaling: boolean;
  53769. /**
  53770. * Custom sensitivity value for the drag strength
  53771. */
  53772. sensitivity: number;
  53773. private _isEnabled;
  53774. private _parent;
  53775. private _arrow;
  53776. private _coloredMaterial;
  53777. private _hoverMaterial;
  53778. /**
  53779. * Creates an AxisScaleGizmo
  53780. * @param gizmoLayer The utility layer the gizmo will be added to
  53781. * @param dragAxis The axis which the gizmo will be able to scale on
  53782. * @param color The color of the gizmo
  53783. * @param thickness display gizmo axis thickness
  53784. */
  53785. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53786. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53787. /**
  53788. * If the gizmo is enabled
  53789. */
  53790. set isEnabled(value: boolean);
  53791. get isEnabled(): boolean;
  53792. /**
  53793. * Disposes of the gizmo
  53794. */
  53795. dispose(): void;
  53796. /**
  53797. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53798. * @param mesh The mesh to replace the default mesh of the gizmo
  53799. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53800. */
  53801. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Bounding box gizmo
  53807. */
  53808. export class BoundingBoxGizmo extends Gizmo {
  53809. private _lineBoundingBox;
  53810. private _rotateSpheresParent;
  53811. private _scaleBoxesParent;
  53812. private _boundingDimensions;
  53813. private _renderObserver;
  53814. private _pointerObserver;
  53815. private _scaleDragSpeed;
  53816. private _tmpQuaternion;
  53817. private _tmpVector;
  53818. private _tmpRotationMatrix;
  53819. /**
  53820. * 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)
  53821. */
  53822. ignoreChildren: boolean;
  53823. /**
  53824. * 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)
  53825. */
  53826. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53827. /**
  53828. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53829. */
  53830. rotationSphereSize: number;
  53831. /**
  53832. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53833. */
  53834. scaleBoxSize: number;
  53835. /**
  53836. * 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)
  53837. */
  53838. fixedDragMeshScreenSize: boolean;
  53839. /**
  53840. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53841. */
  53842. fixedDragMeshScreenSizeDistanceFactor: number;
  53843. /**
  53844. * Fired when a rotation sphere or scale box is dragged
  53845. */
  53846. onDragStartObservable: Observable<{}>;
  53847. /**
  53848. * Fired when a scale box is dragged
  53849. */
  53850. onScaleBoxDragObservable: Observable<{}>;
  53851. /**
  53852. * Fired when a scale box drag is ended
  53853. */
  53854. onScaleBoxDragEndObservable: Observable<{}>;
  53855. /**
  53856. * Fired when a rotation sphere is dragged
  53857. */
  53858. onRotationSphereDragObservable: Observable<{}>;
  53859. /**
  53860. * Fired when a rotation sphere drag is ended
  53861. */
  53862. onRotationSphereDragEndObservable: Observable<{}>;
  53863. /**
  53864. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  53865. */
  53866. scalePivot: Nullable<Vector3>;
  53867. /**
  53868. * Mesh used as a pivot to rotate the attached node
  53869. */
  53870. private _anchorMesh;
  53871. private _existingMeshScale;
  53872. private _dragMesh;
  53873. private pointerDragBehavior;
  53874. private coloredMaterial;
  53875. private hoverColoredMaterial;
  53876. /**
  53877. * Sets the color of the bounding box gizmo
  53878. * @param color the color to set
  53879. */
  53880. setColor(color: Color3): void;
  53881. /**
  53882. * Creates an BoundingBoxGizmo
  53883. * @param gizmoLayer The utility layer the gizmo will be added to
  53884. * @param color The color of the gizmo
  53885. */
  53886. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53887. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53888. private _selectNode;
  53889. /**
  53890. * Updates the bounding box information for the Gizmo
  53891. */
  53892. updateBoundingBox(): void;
  53893. private _updateRotationSpheres;
  53894. private _updateScaleBoxes;
  53895. /**
  53896. * Enables rotation on the specified axis and disables rotation on the others
  53897. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53898. */
  53899. setEnabledRotationAxis(axis: string): void;
  53900. /**
  53901. * Enables/disables scaling
  53902. * @param enable if scaling should be enabled
  53903. * @param homogeneousScaling defines if scaling should only be homogeneous
  53904. */
  53905. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53906. private _updateDummy;
  53907. /**
  53908. * Enables a pointer drag behavior on the bounding box of the gizmo
  53909. */
  53910. enableDragBehavior(): void;
  53911. /**
  53912. * Disposes of the gizmo
  53913. */
  53914. dispose(): void;
  53915. /**
  53916. * 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)
  53917. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53918. * @returns the bounding box mesh with the passed in mesh as a child
  53919. */
  53920. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53921. /**
  53922. * CustomMeshes are not supported by this gizmo
  53923. * @param mesh The mesh to replace the default mesh of the gizmo
  53924. */
  53925. setCustomMesh(mesh: Mesh): void;
  53926. }
  53927. }
  53928. declare module BABYLON {
  53929. /**
  53930. * Single plane rotation gizmo
  53931. */
  53932. export class PlaneRotationGizmo extends Gizmo {
  53933. /**
  53934. * Drag behavior responsible for the gizmos dragging interactions
  53935. */
  53936. dragBehavior: PointerDragBehavior;
  53937. private _pointerObserver;
  53938. /**
  53939. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53940. */
  53941. snapDistance: number;
  53942. /**
  53943. * Event that fires each time the gizmo snaps to a new location.
  53944. * * snapDistance is the the change in distance
  53945. */
  53946. onSnapObservable: Observable<{
  53947. snapDistance: number;
  53948. }>;
  53949. private _isEnabled;
  53950. private _parent;
  53951. /**
  53952. * Creates a PlaneRotationGizmo
  53953. * @param gizmoLayer The utility layer the gizmo will be added to
  53954. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53955. * @param color The color of the gizmo
  53956. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53957. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53958. * @param thickness display gizmo axis thickness
  53959. */
  53960. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53961. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53962. /**
  53963. * If the gizmo is enabled
  53964. */
  53965. set isEnabled(value: boolean);
  53966. get isEnabled(): boolean;
  53967. /**
  53968. * Disposes of the gizmo
  53969. */
  53970. dispose(): void;
  53971. }
  53972. }
  53973. declare module BABYLON {
  53974. /**
  53975. * Gizmo that enables rotating a mesh along 3 axis
  53976. */
  53977. export class RotationGizmo extends Gizmo {
  53978. /**
  53979. * Internal gizmo used for interactions on the x axis
  53980. */
  53981. xGizmo: PlaneRotationGizmo;
  53982. /**
  53983. * Internal gizmo used for interactions on the y axis
  53984. */
  53985. yGizmo: PlaneRotationGizmo;
  53986. /**
  53987. * Internal gizmo used for interactions on the z axis
  53988. */
  53989. zGizmo: PlaneRotationGizmo;
  53990. /** Fires an event when any of it's sub gizmos are dragged */
  53991. onDragStartObservable: Observable<unknown>;
  53992. /** Fires an event when any of it's sub gizmos are released from dragging */
  53993. onDragEndObservable: Observable<unknown>;
  53994. private _meshAttached;
  53995. private _nodeAttached;
  53996. get attachedMesh(): Nullable<AbstractMesh>;
  53997. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53998. get attachedNode(): Nullable<Node>;
  53999. set attachedNode(node: Nullable<Node>);
  54000. /**
  54001. * True when the mouse pointer is hovering a gizmo mesh
  54002. */
  54003. get isHovered(): boolean;
  54004. /**
  54005. * Creates a RotationGizmo
  54006. * @param gizmoLayer The utility layer the gizmo will be added to
  54007. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54008. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54009. * @param thickness display gizmo axis thickness
  54010. */
  54011. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  54012. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54013. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54014. /**
  54015. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54016. */
  54017. set snapDistance(value: number);
  54018. get snapDistance(): number;
  54019. /**
  54020. * Ratio for the scale of the gizmo (Default: 1)
  54021. */
  54022. set scaleRatio(value: number);
  54023. get scaleRatio(): number;
  54024. /**
  54025. * Disposes of the gizmo
  54026. */
  54027. dispose(): void;
  54028. /**
  54029. * CustomMeshes are not supported by this gizmo
  54030. * @param mesh The mesh to replace the default mesh of the gizmo
  54031. */
  54032. setCustomMesh(mesh: Mesh): void;
  54033. }
  54034. }
  54035. declare module BABYLON {
  54036. /**
  54037. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54038. */
  54039. export class GizmoManager implements IDisposable {
  54040. private scene;
  54041. /**
  54042. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54043. */
  54044. gizmos: {
  54045. positionGizmo: Nullable<PositionGizmo>;
  54046. rotationGizmo: Nullable<RotationGizmo>;
  54047. scaleGizmo: Nullable<ScaleGizmo>;
  54048. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54049. };
  54050. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54051. clearGizmoOnEmptyPointerEvent: boolean;
  54052. /** Fires an event when the manager is attached to a mesh */
  54053. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54054. /** Fires an event when the manager is attached to a node */
  54055. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54056. private _gizmosEnabled;
  54057. private _pointerObserver;
  54058. private _attachedMesh;
  54059. private _attachedNode;
  54060. private _boundingBoxColor;
  54061. private _defaultUtilityLayer;
  54062. private _defaultKeepDepthUtilityLayer;
  54063. private _thickness;
  54064. /**
  54065. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54066. */
  54067. boundingBoxDragBehavior: SixDofDragBehavior;
  54068. /**
  54069. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54070. */
  54071. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54072. /**
  54073. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54074. */
  54075. attachableNodes: Nullable<Array<Node>>;
  54076. /**
  54077. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54078. */
  54079. usePointerToAttachGizmos: boolean;
  54080. /**
  54081. * Utility layer that the bounding box gizmo belongs to
  54082. */
  54083. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54084. /**
  54085. * Utility layer that all gizmos besides bounding box belong to
  54086. */
  54087. get utilityLayer(): UtilityLayerRenderer;
  54088. /**
  54089. * True when the mouse pointer is hovering a gizmo mesh
  54090. */
  54091. get isHovered(): boolean;
  54092. /**
  54093. * Instatiates a gizmo manager
  54094. * @param scene the scene to overlay the gizmos on top of
  54095. * @param thickness display gizmo axis thickness
  54096. */
  54097. constructor(scene: Scene, thickness?: number);
  54098. /**
  54099. * Attaches a set of gizmos to the specified mesh
  54100. * @param mesh The mesh the gizmo's should be attached to
  54101. */
  54102. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54103. /**
  54104. * Attaches a set of gizmos to the specified node
  54105. * @param node The node the gizmo's should be attached to
  54106. */
  54107. attachToNode(node: Nullable<Node>): void;
  54108. /**
  54109. * If the position gizmo is enabled
  54110. */
  54111. set positionGizmoEnabled(value: boolean);
  54112. get positionGizmoEnabled(): boolean;
  54113. /**
  54114. * If the rotation gizmo is enabled
  54115. */
  54116. set rotationGizmoEnabled(value: boolean);
  54117. get rotationGizmoEnabled(): boolean;
  54118. /**
  54119. * If the scale gizmo is enabled
  54120. */
  54121. set scaleGizmoEnabled(value: boolean);
  54122. get scaleGizmoEnabled(): boolean;
  54123. /**
  54124. * If the boundingBox gizmo is enabled
  54125. */
  54126. set boundingBoxGizmoEnabled(value: boolean);
  54127. get boundingBoxGizmoEnabled(): boolean;
  54128. /**
  54129. * Disposes of the gizmo manager
  54130. */
  54131. dispose(): void;
  54132. }
  54133. }
  54134. declare module BABYLON {
  54135. /**
  54136. * A directional light is defined by a direction (what a surprise!).
  54137. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54138. * 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.
  54139. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54140. */
  54141. export class DirectionalLight extends ShadowLight {
  54142. private _shadowFrustumSize;
  54143. /**
  54144. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54145. */
  54146. get shadowFrustumSize(): number;
  54147. /**
  54148. * Specifies a fix frustum size for the shadow generation.
  54149. */
  54150. set shadowFrustumSize(value: number);
  54151. private _shadowOrthoScale;
  54152. /**
  54153. * Gets the shadow projection scale against the optimal computed one.
  54154. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54155. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54156. */
  54157. get shadowOrthoScale(): number;
  54158. /**
  54159. * Sets the shadow projection scale against the optimal computed one.
  54160. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54161. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54162. */
  54163. set shadowOrthoScale(value: number);
  54164. /**
  54165. * Automatically compute the projection matrix to best fit (including all the casters)
  54166. * on each frame.
  54167. */
  54168. autoUpdateExtends: boolean;
  54169. /**
  54170. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54171. * on each frame. autoUpdateExtends must be set to true for this to work
  54172. */
  54173. autoCalcShadowZBounds: boolean;
  54174. private _orthoLeft;
  54175. private _orthoRight;
  54176. private _orthoTop;
  54177. private _orthoBottom;
  54178. /**
  54179. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54180. * The directional light is emitted from everywhere in the given direction.
  54181. * It can cast shadows.
  54182. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54183. * @param name The friendly name of the light
  54184. * @param direction The direction of the light
  54185. * @param scene The scene the light belongs to
  54186. */
  54187. constructor(name: string, direction: Vector3, scene: Scene);
  54188. /**
  54189. * Returns the string "DirectionalLight".
  54190. * @return The class name
  54191. */
  54192. getClassName(): string;
  54193. /**
  54194. * Returns the integer 1.
  54195. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54196. */
  54197. getTypeID(): number;
  54198. /**
  54199. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54200. * Returns the DirectionalLight Shadow projection matrix.
  54201. */
  54202. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54203. /**
  54204. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54205. * Returns the DirectionalLight Shadow projection matrix.
  54206. */
  54207. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54208. /**
  54209. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54210. * Returns the DirectionalLight Shadow projection matrix.
  54211. */
  54212. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54213. protected _buildUniformLayout(): void;
  54214. /**
  54215. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54216. * @param effect The effect to update
  54217. * @param lightIndex The index of the light in the effect to update
  54218. * @returns The directional light
  54219. */
  54220. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54221. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54222. /**
  54223. * Gets the minZ used for shadow according to both the scene and the light.
  54224. *
  54225. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54226. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54227. * @param activeCamera The camera we are returning the min for
  54228. * @returns the depth min z
  54229. */
  54230. getDepthMinZ(activeCamera: Camera): number;
  54231. /**
  54232. * Gets the maxZ used for shadow according to both the scene and the light.
  54233. *
  54234. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54235. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54236. * @param activeCamera The camera we are returning the max for
  54237. * @returns the depth max z
  54238. */
  54239. getDepthMaxZ(activeCamera: Camera): number;
  54240. /**
  54241. * Prepares the list of defines specific to the light type.
  54242. * @param defines the list of defines
  54243. * @param lightIndex defines the index of the light for the effect
  54244. */
  54245. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54246. }
  54247. }
  54248. declare module BABYLON {
  54249. /**
  54250. * Class containing static functions to help procedurally build meshes
  54251. */
  54252. export class HemisphereBuilder {
  54253. /**
  54254. * Creates a hemisphere mesh
  54255. * @param name defines the name of the mesh
  54256. * @param options defines the options used to create the mesh
  54257. * @param scene defines the hosting scene
  54258. * @returns the hemisphere mesh
  54259. */
  54260. static CreateHemisphere(name: string, options: {
  54261. segments?: number;
  54262. diameter?: number;
  54263. sideOrientation?: number;
  54264. }, scene: any): Mesh;
  54265. }
  54266. }
  54267. declare module BABYLON {
  54268. /**
  54269. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54270. * These values define a cone of light starting from the position, emitting toward the direction.
  54271. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54272. * and the exponent defines the speed of the decay of the light with distance (reach).
  54273. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54274. */
  54275. export class SpotLight extends ShadowLight {
  54276. private _angle;
  54277. private _innerAngle;
  54278. private _cosHalfAngle;
  54279. private _lightAngleScale;
  54280. private _lightAngleOffset;
  54281. /**
  54282. * Gets the cone angle of the spot light in Radians.
  54283. */
  54284. get angle(): number;
  54285. /**
  54286. * Sets the cone angle of the spot light in Radians.
  54287. */
  54288. set angle(value: number);
  54289. /**
  54290. * Only used in gltf falloff mode, this defines the angle where
  54291. * the directional falloff will start before cutting at angle which could be seen
  54292. * as outer angle.
  54293. */
  54294. get innerAngle(): number;
  54295. /**
  54296. * Only used in gltf falloff mode, this defines the angle where
  54297. * the directional falloff will start before cutting at angle which could be seen
  54298. * as outer angle.
  54299. */
  54300. set innerAngle(value: number);
  54301. private _shadowAngleScale;
  54302. /**
  54303. * Allows scaling the angle of the light for shadow generation only.
  54304. */
  54305. get shadowAngleScale(): number;
  54306. /**
  54307. * Allows scaling the angle of the light for shadow generation only.
  54308. */
  54309. set shadowAngleScale(value: number);
  54310. /**
  54311. * The light decay speed with the distance from the emission spot.
  54312. */
  54313. exponent: number;
  54314. private _projectionTextureMatrix;
  54315. /**
  54316. * Allows reading the projecton texture
  54317. */
  54318. get projectionTextureMatrix(): Matrix;
  54319. protected _projectionTextureLightNear: number;
  54320. /**
  54321. * Gets the near clip of the Spotlight for texture projection.
  54322. */
  54323. get projectionTextureLightNear(): number;
  54324. /**
  54325. * Sets the near clip of the Spotlight for texture projection.
  54326. */
  54327. set projectionTextureLightNear(value: number);
  54328. protected _projectionTextureLightFar: number;
  54329. /**
  54330. * Gets the far clip of the Spotlight for texture projection.
  54331. */
  54332. get projectionTextureLightFar(): number;
  54333. /**
  54334. * Sets the far clip of the Spotlight for texture projection.
  54335. */
  54336. set projectionTextureLightFar(value: number);
  54337. protected _projectionTextureUpDirection: Vector3;
  54338. /**
  54339. * Gets the Up vector of the Spotlight for texture projection.
  54340. */
  54341. get projectionTextureUpDirection(): Vector3;
  54342. /**
  54343. * Sets the Up vector of the Spotlight for texture projection.
  54344. */
  54345. set projectionTextureUpDirection(value: Vector3);
  54346. private _projectionTexture;
  54347. /**
  54348. * Gets the projection texture of the light.
  54349. */
  54350. get projectionTexture(): Nullable<BaseTexture>;
  54351. /**
  54352. * Sets the projection texture of the light.
  54353. */
  54354. set projectionTexture(value: Nullable<BaseTexture>);
  54355. private _projectionTextureViewLightDirty;
  54356. private _projectionTextureProjectionLightDirty;
  54357. private _projectionTextureDirty;
  54358. private _projectionTextureViewTargetVector;
  54359. private _projectionTextureViewLightMatrix;
  54360. private _projectionTextureProjectionLightMatrix;
  54361. private _projectionTextureScalingMatrix;
  54362. /**
  54363. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54364. * It can cast shadows.
  54365. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54366. * @param name The light friendly name
  54367. * @param position The position of the spot light in the scene
  54368. * @param direction The direction of the light in the scene
  54369. * @param angle The cone angle of the light in Radians
  54370. * @param exponent The light decay speed with the distance from the emission spot
  54371. * @param scene The scene the lights belongs to
  54372. */
  54373. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54374. /**
  54375. * Returns the string "SpotLight".
  54376. * @returns the class name
  54377. */
  54378. getClassName(): string;
  54379. /**
  54380. * Returns the integer 2.
  54381. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54382. */
  54383. getTypeID(): number;
  54384. /**
  54385. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54386. */
  54387. protected _setDirection(value: Vector3): void;
  54388. /**
  54389. * Overrides the position setter to recompute the projection texture view light Matrix.
  54390. */
  54391. protected _setPosition(value: Vector3): void;
  54392. /**
  54393. * 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.
  54394. * Returns the SpotLight.
  54395. */
  54396. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54397. protected _computeProjectionTextureViewLightMatrix(): void;
  54398. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54399. /**
  54400. * Main function for light texture projection matrix computing.
  54401. */
  54402. protected _computeProjectionTextureMatrix(): void;
  54403. protected _buildUniformLayout(): void;
  54404. private _computeAngleValues;
  54405. /**
  54406. * Sets the passed Effect "effect" with the Light textures.
  54407. * @param effect The effect to update
  54408. * @param lightIndex The index of the light in the effect to update
  54409. * @returns The light
  54410. */
  54411. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54412. /**
  54413. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54414. * @param effect The effect to update
  54415. * @param lightIndex The index of the light in the effect to update
  54416. * @returns The spot light
  54417. */
  54418. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54419. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54420. /**
  54421. * Disposes the light and the associated resources.
  54422. */
  54423. dispose(): void;
  54424. /**
  54425. * Prepares the list of defines specific to the light type.
  54426. * @param defines the list of defines
  54427. * @param lightIndex defines the index of the light for the effect
  54428. */
  54429. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54430. }
  54431. }
  54432. declare module BABYLON {
  54433. /**
  54434. * Gizmo that enables viewing a light
  54435. */
  54436. export class LightGizmo extends Gizmo {
  54437. private _lightMesh;
  54438. private _material;
  54439. private _cachedPosition;
  54440. private _cachedForward;
  54441. private _attachedMeshParent;
  54442. private _pointerObserver;
  54443. /**
  54444. * Event that fires each time the gizmo is clicked
  54445. */
  54446. onClickedObservable: Observable<Light>;
  54447. /**
  54448. * Creates a LightGizmo
  54449. * @param gizmoLayer The utility layer the gizmo will be added to
  54450. */
  54451. constructor(gizmoLayer?: UtilityLayerRenderer);
  54452. private _light;
  54453. /**
  54454. * The light that the gizmo is attached to
  54455. */
  54456. set light(light: Nullable<Light>);
  54457. get light(): Nullable<Light>;
  54458. /**
  54459. * Gets the material used to render the light gizmo
  54460. */
  54461. get material(): StandardMaterial;
  54462. /**
  54463. * @hidden
  54464. * Updates the gizmo to match the attached mesh's position/rotation
  54465. */
  54466. protected _update(): void;
  54467. private static _Scale;
  54468. /**
  54469. * Creates the lines for a light mesh
  54470. */
  54471. private static _CreateLightLines;
  54472. /**
  54473. * Disposes of the light gizmo
  54474. */
  54475. dispose(): void;
  54476. private static _CreateHemisphericLightMesh;
  54477. private static _CreatePointLightMesh;
  54478. private static _CreateSpotLightMesh;
  54479. private static _CreateDirectionalLightMesh;
  54480. }
  54481. }
  54482. declare module BABYLON {
  54483. /**
  54484. * Gizmo that enables viewing a camera
  54485. */
  54486. export class CameraGizmo extends Gizmo {
  54487. private _cameraMesh;
  54488. private _cameraLinesMesh;
  54489. private _material;
  54490. private _pointerObserver;
  54491. /**
  54492. * Event that fires each time the gizmo is clicked
  54493. */
  54494. onClickedObservable: Observable<Camera>;
  54495. /**
  54496. * Creates a CameraGizmo
  54497. * @param gizmoLayer The utility layer the gizmo will be added to
  54498. */
  54499. constructor(gizmoLayer?: UtilityLayerRenderer);
  54500. private _camera;
  54501. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54502. get displayFrustum(): boolean;
  54503. set displayFrustum(value: boolean);
  54504. /**
  54505. * The camera that the gizmo is attached to
  54506. */
  54507. set camera(camera: Nullable<Camera>);
  54508. get camera(): Nullable<Camera>;
  54509. /**
  54510. * Gets the material used to render the camera gizmo
  54511. */
  54512. get material(): StandardMaterial;
  54513. /**
  54514. * @hidden
  54515. * Updates the gizmo to match the attached mesh's position/rotation
  54516. */
  54517. protected _update(): void;
  54518. private static _Scale;
  54519. private _invProjection;
  54520. /**
  54521. * Disposes of the camera gizmo
  54522. */
  54523. dispose(): void;
  54524. private static _CreateCameraMesh;
  54525. private static _CreateCameraFrustum;
  54526. }
  54527. }
  54528. declare module BABYLON {
  54529. /** @hidden */
  54530. export var backgroundFragmentDeclaration: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module BABYLON {
  54536. /** @hidden */
  54537. export var backgroundUboDeclaration: {
  54538. name: string;
  54539. shader: string;
  54540. };
  54541. }
  54542. declare module BABYLON {
  54543. /** @hidden */
  54544. export var backgroundPixelShader: {
  54545. name: string;
  54546. shader: string;
  54547. };
  54548. }
  54549. declare module BABYLON {
  54550. /** @hidden */
  54551. export var backgroundVertexDeclaration: {
  54552. name: string;
  54553. shader: string;
  54554. };
  54555. }
  54556. declare module BABYLON {
  54557. /** @hidden */
  54558. export var backgroundVertexShader: {
  54559. name: string;
  54560. shader: string;
  54561. };
  54562. }
  54563. declare module BABYLON {
  54564. /**
  54565. * Background material used to create an efficient environement around your scene.
  54566. */
  54567. export class BackgroundMaterial extends PushMaterial {
  54568. /**
  54569. * Standard reflectance value at parallel view angle.
  54570. */
  54571. static StandardReflectance0: number;
  54572. /**
  54573. * Standard reflectance value at grazing angle.
  54574. */
  54575. static StandardReflectance90: number;
  54576. protected _primaryColor: Color3;
  54577. /**
  54578. * Key light Color (multiply against the environement texture)
  54579. */
  54580. primaryColor: Color3;
  54581. protected __perceptualColor: Nullable<Color3>;
  54582. /**
  54583. * Experimental Internal Use Only.
  54584. *
  54585. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54586. * This acts as a helper to set the primary color to a more "human friendly" value.
  54587. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54588. * output color as close as possible from the chosen value.
  54589. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54590. * part of lighting setup.)
  54591. */
  54592. get _perceptualColor(): Nullable<Color3>;
  54593. set _perceptualColor(value: Nullable<Color3>);
  54594. protected _primaryColorShadowLevel: float;
  54595. /**
  54596. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54597. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54598. */
  54599. get primaryColorShadowLevel(): float;
  54600. set primaryColorShadowLevel(value: float);
  54601. protected _primaryColorHighlightLevel: float;
  54602. /**
  54603. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54604. * The primary color is used at the level chosen to define what the white area would look.
  54605. */
  54606. get primaryColorHighlightLevel(): float;
  54607. set primaryColorHighlightLevel(value: float);
  54608. protected _reflectionTexture: Nullable<BaseTexture>;
  54609. /**
  54610. * Reflection Texture used in the material.
  54611. * Should be author in a specific way for the best result (refer to the documentation).
  54612. */
  54613. reflectionTexture: Nullable<BaseTexture>;
  54614. protected _reflectionBlur: float;
  54615. /**
  54616. * Reflection Texture level of blur.
  54617. *
  54618. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54619. * texture twice.
  54620. */
  54621. reflectionBlur: float;
  54622. protected _diffuseTexture: Nullable<BaseTexture>;
  54623. /**
  54624. * Diffuse Texture used in the material.
  54625. * Should be author in a specific way for the best result (refer to the documentation).
  54626. */
  54627. diffuseTexture: Nullable<BaseTexture>;
  54628. protected _shadowLights: Nullable<IShadowLight[]>;
  54629. /**
  54630. * Specify the list of lights casting shadow on the material.
  54631. * All scene shadow lights will be included if null.
  54632. */
  54633. shadowLights: Nullable<IShadowLight[]>;
  54634. protected _shadowLevel: float;
  54635. /**
  54636. * Helps adjusting the shadow to a softer level if required.
  54637. * 0 means black shadows and 1 means no shadows.
  54638. */
  54639. shadowLevel: float;
  54640. protected _sceneCenter: Vector3;
  54641. /**
  54642. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54643. * It is usually zero but might be interesting to modify according to your setup.
  54644. */
  54645. sceneCenter: Vector3;
  54646. protected _opacityFresnel: boolean;
  54647. /**
  54648. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54649. * This helps ensuring a nice transition when the camera goes under the ground.
  54650. */
  54651. opacityFresnel: boolean;
  54652. protected _reflectionFresnel: boolean;
  54653. /**
  54654. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54655. * This helps adding a mirror texture on the ground.
  54656. */
  54657. reflectionFresnel: boolean;
  54658. protected _reflectionFalloffDistance: number;
  54659. /**
  54660. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54661. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54662. */
  54663. reflectionFalloffDistance: number;
  54664. protected _reflectionAmount: number;
  54665. /**
  54666. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54667. */
  54668. reflectionAmount: number;
  54669. protected _reflectionReflectance0: number;
  54670. /**
  54671. * This specifies the weight of the reflection at grazing angle.
  54672. */
  54673. reflectionReflectance0: number;
  54674. protected _reflectionReflectance90: number;
  54675. /**
  54676. * This specifies the weight of the reflection at a perpendicular point of view.
  54677. */
  54678. reflectionReflectance90: number;
  54679. /**
  54680. * Sets the reflection reflectance fresnel values according to the default standard
  54681. * empirically know to work well :-)
  54682. */
  54683. set reflectionStandardFresnelWeight(value: number);
  54684. protected _useRGBColor: boolean;
  54685. /**
  54686. * Helps to directly use the maps channels instead of their level.
  54687. */
  54688. useRGBColor: boolean;
  54689. protected _enableNoise: boolean;
  54690. /**
  54691. * This helps reducing the banding effect that could occur on the background.
  54692. */
  54693. enableNoise: boolean;
  54694. /**
  54695. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54696. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54697. * Recommended to be keep at 1.0 except for special cases.
  54698. */
  54699. get fovMultiplier(): number;
  54700. set fovMultiplier(value: number);
  54701. private _fovMultiplier;
  54702. /**
  54703. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54704. */
  54705. useEquirectangularFOV: boolean;
  54706. private _maxSimultaneousLights;
  54707. /**
  54708. * Number of Simultaneous lights allowed on the material.
  54709. */
  54710. maxSimultaneousLights: int;
  54711. private _shadowOnly;
  54712. /**
  54713. * Make the material only render shadows
  54714. */
  54715. shadowOnly: boolean;
  54716. /**
  54717. * Default configuration related to image processing available in the Background Material.
  54718. */
  54719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54720. /**
  54721. * Keep track of the image processing observer to allow dispose and replace.
  54722. */
  54723. private _imageProcessingObserver;
  54724. /**
  54725. * Attaches a new image processing configuration to the PBR Material.
  54726. * @param configuration (if null the scene configuration will be use)
  54727. */
  54728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54729. /**
  54730. * Gets the image processing configuration used either in this material.
  54731. */
  54732. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54733. /**
  54734. * Sets the Default image processing configuration used either in the this material.
  54735. *
  54736. * If sets to null, the scene one is in use.
  54737. */
  54738. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54739. /**
  54740. * Gets wether the color curves effect is enabled.
  54741. */
  54742. get cameraColorCurvesEnabled(): boolean;
  54743. /**
  54744. * Sets wether the color curves effect is enabled.
  54745. */
  54746. set cameraColorCurvesEnabled(value: boolean);
  54747. /**
  54748. * Gets wether the color grading effect is enabled.
  54749. */
  54750. get cameraColorGradingEnabled(): boolean;
  54751. /**
  54752. * Gets wether the color grading effect is enabled.
  54753. */
  54754. set cameraColorGradingEnabled(value: boolean);
  54755. /**
  54756. * Gets wether tonemapping is enabled or not.
  54757. */
  54758. get cameraToneMappingEnabled(): boolean;
  54759. /**
  54760. * Sets wether tonemapping is enabled or not
  54761. */
  54762. set cameraToneMappingEnabled(value: boolean);
  54763. /**
  54764. * The camera exposure used on this material.
  54765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54766. * This corresponds to a photographic exposure.
  54767. */
  54768. get cameraExposure(): float;
  54769. /**
  54770. * The camera exposure used on this material.
  54771. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54772. * This corresponds to a photographic exposure.
  54773. */
  54774. set cameraExposure(value: float);
  54775. /**
  54776. * Gets The camera contrast used on this material.
  54777. */
  54778. get cameraContrast(): float;
  54779. /**
  54780. * Sets The camera contrast used on this material.
  54781. */
  54782. set cameraContrast(value: float);
  54783. /**
  54784. * Gets the Color Grading 2D Lookup Texture.
  54785. */
  54786. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54787. /**
  54788. * Sets the Color Grading 2D Lookup Texture.
  54789. */
  54790. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54791. /**
  54792. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54793. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54794. * 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;
  54795. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54796. */
  54797. get cameraColorCurves(): Nullable<ColorCurves>;
  54798. /**
  54799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54801. * 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;
  54802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54803. */
  54804. set cameraColorCurves(value: Nullable<ColorCurves>);
  54805. /**
  54806. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54807. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54808. */
  54809. switchToBGR: boolean;
  54810. private _renderTargets;
  54811. private _reflectionControls;
  54812. private _white;
  54813. private _primaryShadowColor;
  54814. private _primaryHighlightColor;
  54815. /**
  54816. * Instantiates a Background Material in the given scene
  54817. * @param name The friendly name of the material
  54818. * @param scene The scene to add the material to
  54819. */
  54820. constructor(name: string, scene: Scene);
  54821. /**
  54822. * Gets a boolean indicating that current material needs to register RTT
  54823. */
  54824. get hasRenderTargetTextures(): boolean;
  54825. /**
  54826. * The entire material has been created in order to prevent overdraw.
  54827. * @returns false
  54828. */
  54829. needAlphaTesting(): boolean;
  54830. /**
  54831. * The entire material has been created in order to prevent overdraw.
  54832. * @returns true if blending is enable
  54833. */
  54834. needAlphaBlending(): boolean;
  54835. /**
  54836. * Checks wether the material is ready to be rendered for a given mesh.
  54837. * @param mesh The mesh to render
  54838. * @param subMesh The submesh to check against
  54839. * @param useInstances Specify wether or not the material is used with instances
  54840. * @returns true if all the dependencies are ready (Textures, Effects...)
  54841. */
  54842. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54843. /**
  54844. * Compute the primary color according to the chosen perceptual color.
  54845. */
  54846. private _computePrimaryColorFromPerceptualColor;
  54847. /**
  54848. * Compute the highlights and shadow colors according to their chosen levels.
  54849. */
  54850. private _computePrimaryColors;
  54851. /**
  54852. * Build the uniform buffer used in the material.
  54853. */
  54854. buildUniformLayout(): void;
  54855. /**
  54856. * Unbind the material.
  54857. */
  54858. unbind(): void;
  54859. /**
  54860. * Bind only the world matrix to the material.
  54861. * @param world The world matrix to bind.
  54862. */
  54863. bindOnlyWorldMatrix(world: Matrix): void;
  54864. /**
  54865. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54866. * @param world The world matrix to bind.
  54867. * @param subMesh The submesh to bind for.
  54868. */
  54869. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54870. /**
  54871. * Checks to see if a texture is used in the material.
  54872. * @param texture - Base texture to use.
  54873. * @returns - Boolean specifying if a texture is used in the material.
  54874. */
  54875. hasTexture(texture: BaseTexture): boolean;
  54876. /**
  54877. * Dispose the material.
  54878. * @param forceDisposeEffect Force disposal of the associated effect.
  54879. * @param forceDisposeTextures Force disposal of the associated textures.
  54880. */
  54881. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54882. /**
  54883. * Clones the material.
  54884. * @param name The cloned name.
  54885. * @returns The cloned material.
  54886. */
  54887. clone(name: string): BackgroundMaterial;
  54888. /**
  54889. * Serializes the current material to its JSON representation.
  54890. * @returns The JSON representation.
  54891. */
  54892. serialize(): any;
  54893. /**
  54894. * Gets the class name of the material
  54895. * @returns "BackgroundMaterial"
  54896. */
  54897. getClassName(): string;
  54898. /**
  54899. * Parse a JSON input to create back a background material.
  54900. * @param source The JSON data to parse
  54901. * @param scene The scene to create the parsed material in
  54902. * @param rootUrl The root url of the assets the material depends upon
  54903. * @returns the instantiated BackgroundMaterial.
  54904. */
  54905. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54906. }
  54907. }
  54908. declare module BABYLON {
  54909. /**
  54910. * Represents the different options available during the creation of
  54911. * a Environment helper.
  54912. *
  54913. * This can control the default ground, skybox and image processing setup of your scene.
  54914. */
  54915. export interface IEnvironmentHelperOptions {
  54916. /**
  54917. * Specifies whether or not to create a ground.
  54918. * True by default.
  54919. */
  54920. createGround: boolean;
  54921. /**
  54922. * Specifies the ground size.
  54923. * 15 by default.
  54924. */
  54925. groundSize: number;
  54926. /**
  54927. * The texture used on the ground for the main color.
  54928. * Comes from the BabylonJS CDN by default.
  54929. *
  54930. * Remarks: Can be either a texture or a url.
  54931. */
  54932. groundTexture: string | BaseTexture;
  54933. /**
  54934. * The color mixed in the ground texture by default.
  54935. * BabylonJS clearColor by default.
  54936. */
  54937. groundColor: Color3;
  54938. /**
  54939. * Specifies the ground opacity.
  54940. * 1 by default.
  54941. */
  54942. groundOpacity: number;
  54943. /**
  54944. * Enables the ground to receive shadows.
  54945. * True by default.
  54946. */
  54947. enableGroundShadow: boolean;
  54948. /**
  54949. * Helps preventing the shadow to be fully black on the ground.
  54950. * 0.5 by default.
  54951. */
  54952. groundShadowLevel: number;
  54953. /**
  54954. * Creates a mirror texture attach to the ground.
  54955. * false by default.
  54956. */
  54957. enableGroundMirror: boolean;
  54958. /**
  54959. * Specifies the ground mirror size ratio.
  54960. * 0.3 by default as the default kernel is 64.
  54961. */
  54962. groundMirrorSizeRatio: number;
  54963. /**
  54964. * Specifies the ground mirror blur kernel size.
  54965. * 64 by default.
  54966. */
  54967. groundMirrorBlurKernel: number;
  54968. /**
  54969. * Specifies the ground mirror visibility amount.
  54970. * 1 by default
  54971. */
  54972. groundMirrorAmount: number;
  54973. /**
  54974. * Specifies the ground mirror reflectance weight.
  54975. * This uses the standard weight of the background material to setup the fresnel effect
  54976. * of the mirror.
  54977. * 1 by default.
  54978. */
  54979. groundMirrorFresnelWeight: number;
  54980. /**
  54981. * Specifies the ground mirror Falloff distance.
  54982. * This can helps reducing the size of the reflection.
  54983. * 0 by Default.
  54984. */
  54985. groundMirrorFallOffDistance: number;
  54986. /**
  54987. * Specifies the ground mirror texture type.
  54988. * Unsigned Int by Default.
  54989. */
  54990. groundMirrorTextureType: number;
  54991. /**
  54992. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54993. * the shown objects.
  54994. */
  54995. groundYBias: number;
  54996. /**
  54997. * Specifies whether or not to create a skybox.
  54998. * True by default.
  54999. */
  55000. createSkybox: boolean;
  55001. /**
  55002. * Specifies the skybox size.
  55003. * 20 by default.
  55004. */
  55005. skyboxSize: number;
  55006. /**
  55007. * The texture used on the skybox for the main color.
  55008. * Comes from the BabylonJS CDN by default.
  55009. *
  55010. * Remarks: Can be either a texture or a url.
  55011. */
  55012. skyboxTexture: string | BaseTexture;
  55013. /**
  55014. * The color mixed in the skybox texture by default.
  55015. * BabylonJS clearColor by default.
  55016. */
  55017. skyboxColor: Color3;
  55018. /**
  55019. * The background rotation around the Y axis of the scene.
  55020. * This helps aligning the key lights of your scene with the background.
  55021. * 0 by default.
  55022. */
  55023. backgroundYRotation: number;
  55024. /**
  55025. * Compute automatically the size of the elements to best fit with the scene.
  55026. */
  55027. sizeAuto: boolean;
  55028. /**
  55029. * Default position of the rootMesh if autoSize is not true.
  55030. */
  55031. rootPosition: Vector3;
  55032. /**
  55033. * Sets up the image processing in the scene.
  55034. * true by default.
  55035. */
  55036. setupImageProcessing: boolean;
  55037. /**
  55038. * The texture used as your environment texture in the scene.
  55039. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55040. *
  55041. * Remarks: Can be either a texture or a url.
  55042. */
  55043. environmentTexture: string | BaseTexture;
  55044. /**
  55045. * The value of the exposure to apply to the scene.
  55046. * 0.6 by default if setupImageProcessing is true.
  55047. */
  55048. cameraExposure: number;
  55049. /**
  55050. * The value of the contrast to apply to the scene.
  55051. * 1.6 by default if setupImageProcessing is true.
  55052. */
  55053. cameraContrast: number;
  55054. /**
  55055. * Specifies whether or not tonemapping should be enabled in the scene.
  55056. * true by default if setupImageProcessing is true.
  55057. */
  55058. toneMappingEnabled: boolean;
  55059. }
  55060. /**
  55061. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55062. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55063. * It also helps with the default setup of your imageProcessing configuration.
  55064. */
  55065. export class EnvironmentHelper {
  55066. /**
  55067. * Default ground texture URL.
  55068. */
  55069. private static _groundTextureCDNUrl;
  55070. /**
  55071. * Default skybox texture URL.
  55072. */
  55073. private static _skyboxTextureCDNUrl;
  55074. /**
  55075. * Default environment texture URL.
  55076. */
  55077. private static _environmentTextureCDNUrl;
  55078. /**
  55079. * Creates the default options for the helper.
  55080. */
  55081. private static _getDefaultOptions;
  55082. private _rootMesh;
  55083. /**
  55084. * Gets the root mesh created by the helper.
  55085. */
  55086. get rootMesh(): Mesh;
  55087. private _skybox;
  55088. /**
  55089. * Gets the skybox created by the helper.
  55090. */
  55091. get skybox(): Nullable<Mesh>;
  55092. private _skyboxTexture;
  55093. /**
  55094. * Gets the skybox texture created by the helper.
  55095. */
  55096. get skyboxTexture(): Nullable<BaseTexture>;
  55097. private _skyboxMaterial;
  55098. /**
  55099. * Gets the skybox material created by the helper.
  55100. */
  55101. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55102. private _ground;
  55103. /**
  55104. * Gets the ground mesh created by the helper.
  55105. */
  55106. get ground(): Nullable<Mesh>;
  55107. private _groundTexture;
  55108. /**
  55109. * Gets the ground texture created by the helper.
  55110. */
  55111. get groundTexture(): Nullable<BaseTexture>;
  55112. private _groundMirror;
  55113. /**
  55114. * Gets the ground mirror created by the helper.
  55115. */
  55116. get groundMirror(): Nullable<MirrorTexture>;
  55117. /**
  55118. * Gets the ground mirror render list to helps pushing the meshes
  55119. * you wish in the ground reflection.
  55120. */
  55121. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55122. private _groundMaterial;
  55123. /**
  55124. * Gets the ground material created by the helper.
  55125. */
  55126. get groundMaterial(): Nullable<BackgroundMaterial>;
  55127. /**
  55128. * Stores the creation options.
  55129. */
  55130. private readonly _scene;
  55131. private _options;
  55132. /**
  55133. * This observable will be notified with any error during the creation of the environment,
  55134. * mainly texture creation errors.
  55135. */
  55136. onErrorObservable: Observable<{
  55137. message?: string;
  55138. exception?: any;
  55139. }>;
  55140. /**
  55141. * constructor
  55142. * @param options Defines the options we want to customize the helper
  55143. * @param scene The scene to add the material to
  55144. */
  55145. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55146. /**
  55147. * Updates the background according to the new options
  55148. * @param options
  55149. */
  55150. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55151. /**
  55152. * Sets the primary color of all the available elements.
  55153. * @param color the main color to affect to the ground and the background
  55154. */
  55155. setMainColor(color: Color3): void;
  55156. /**
  55157. * Setup the image processing according to the specified options.
  55158. */
  55159. private _setupImageProcessing;
  55160. /**
  55161. * Setup the environment texture according to the specified options.
  55162. */
  55163. private _setupEnvironmentTexture;
  55164. /**
  55165. * Setup the background according to the specified options.
  55166. */
  55167. private _setupBackground;
  55168. /**
  55169. * Get the scene sizes according to the setup.
  55170. */
  55171. private _getSceneSize;
  55172. /**
  55173. * Setup the ground according to the specified options.
  55174. */
  55175. private _setupGround;
  55176. /**
  55177. * Setup the ground material according to the specified options.
  55178. */
  55179. private _setupGroundMaterial;
  55180. /**
  55181. * Setup the ground diffuse texture according to the specified options.
  55182. */
  55183. private _setupGroundDiffuseTexture;
  55184. /**
  55185. * Setup the ground mirror texture according to the specified options.
  55186. */
  55187. private _setupGroundMirrorTexture;
  55188. /**
  55189. * Setup the ground to receive the mirror texture.
  55190. */
  55191. private _setupMirrorInGroundMaterial;
  55192. /**
  55193. * Setup the skybox according to the specified options.
  55194. */
  55195. private _setupSkybox;
  55196. /**
  55197. * Setup the skybox material according to the specified options.
  55198. */
  55199. private _setupSkyboxMaterial;
  55200. /**
  55201. * Setup the skybox reflection texture according to the specified options.
  55202. */
  55203. private _setupSkyboxReflectionTexture;
  55204. private _errorHandler;
  55205. /**
  55206. * Dispose all the elements created by the Helper.
  55207. */
  55208. dispose(): void;
  55209. }
  55210. }
  55211. declare module BABYLON {
  55212. /**
  55213. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55214. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55215. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55216. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55217. */
  55218. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55219. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55220. /**
  55221. * Define the source as a Monoscopic panoramic 360/180.
  55222. */
  55223. static readonly MODE_MONOSCOPIC: number;
  55224. /**
  55225. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55226. */
  55227. static readonly MODE_TOPBOTTOM: number;
  55228. /**
  55229. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55230. */
  55231. static readonly MODE_SIDEBYSIDE: number;
  55232. private _halfDome;
  55233. protected _useDirectMapping: boolean;
  55234. /**
  55235. * The texture being displayed on the sphere
  55236. */
  55237. protected _texture: T;
  55238. /**
  55239. * Gets the texture being displayed on the sphere
  55240. */
  55241. get texture(): T;
  55242. /**
  55243. * Sets the texture being displayed on the sphere
  55244. */
  55245. set texture(newTexture: T);
  55246. /**
  55247. * The skybox material
  55248. */
  55249. protected _material: BackgroundMaterial;
  55250. /**
  55251. * The surface used for the dome
  55252. */
  55253. protected _mesh: Mesh;
  55254. /**
  55255. * Gets the mesh used for the dome.
  55256. */
  55257. get mesh(): Mesh;
  55258. /**
  55259. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55260. */
  55261. private _halfDomeMask;
  55262. /**
  55263. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55264. * Also see the options.resolution property.
  55265. */
  55266. get fovMultiplier(): number;
  55267. set fovMultiplier(value: number);
  55268. protected _textureMode: number;
  55269. /**
  55270. * Gets or set the current texture mode for the texture. It can be:
  55271. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55272. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55273. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55274. */
  55275. get textureMode(): number;
  55276. /**
  55277. * Sets the current texture mode for the texture. It can be:
  55278. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55279. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55280. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55281. */
  55282. set textureMode(value: number);
  55283. /**
  55284. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55285. */
  55286. get halfDome(): boolean;
  55287. /**
  55288. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55289. */
  55290. set halfDome(enabled: boolean);
  55291. /**
  55292. * Oberserver used in Stereoscopic VR Mode.
  55293. */
  55294. private _onBeforeCameraRenderObserver;
  55295. /**
  55296. * Observable raised when an error occured while loading the 360 image
  55297. */
  55298. onLoadErrorObservable: Observable<string>;
  55299. /**
  55300. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55301. * @param name Element's name, child elements will append suffixes for their own names.
  55302. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55303. * @param options An object containing optional or exposed sub element properties
  55304. */
  55305. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55306. resolution?: number;
  55307. clickToPlay?: boolean;
  55308. autoPlay?: boolean;
  55309. loop?: boolean;
  55310. size?: number;
  55311. poster?: string;
  55312. faceForward?: boolean;
  55313. useDirectMapping?: boolean;
  55314. halfDomeMode?: boolean;
  55315. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55316. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55317. protected _changeTextureMode(value: number): void;
  55318. /**
  55319. * Releases resources associated with this node.
  55320. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55321. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55322. */
  55323. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55324. }
  55325. }
  55326. declare module BABYLON {
  55327. /**
  55328. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55329. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55330. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55331. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55332. */
  55333. export class PhotoDome extends TextureDome<Texture> {
  55334. /**
  55335. * Define the image as a Monoscopic panoramic 360 image.
  55336. */
  55337. static readonly MODE_MONOSCOPIC: number;
  55338. /**
  55339. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55340. */
  55341. static readonly MODE_TOPBOTTOM: number;
  55342. /**
  55343. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55344. */
  55345. static readonly MODE_SIDEBYSIDE: number;
  55346. /**
  55347. * Gets or sets the texture being displayed on the sphere
  55348. */
  55349. get photoTexture(): Texture;
  55350. /**
  55351. * sets the texture being displayed on the sphere
  55352. */
  55353. set photoTexture(value: Texture);
  55354. /**
  55355. * Gets the current video mode for the video. It can be:
  55356. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55357. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55358. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55359. */
  55360. get imageMode(): number;
  55361. /**
  55362. * Sets the current video mode for the video. It can be:
  55363. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55364. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55365. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55366. */
  55367. set imageMode(value: number);
  55368. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55369. }
  55370. }
  55371. declare module BABYLON {
  55372. /**
  55373. * Class used to host RGBD texture specific utilities
  55374. */
  55375. export class RGBDTextureTools {
  55376. /**
  55377. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55378. * @param texture the texture to expand.
  55379. */
  55380. static ExpandRGBDTexture(texture: Texture): void;
  55381. }
  55382. }
  55383. declare module BABYLON {
  55384. /**
  55385. * Class used to host texture specific utilities
  55386. */
  55387. export class BRDFTextureTools {
  55388. /**
  55389. * Prevents texture cache collision
  55390. */
  55391. private static _instanceNumber;
  55392. /**
  55393. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55394. * @param scene defines the hosting scene
  55395. * @returns the environment BRDF texture
  55396. */
  55397. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55398. private static _environmentBRDFBase64Texture;
  55399. }
  55400. }
  55401. declare module BABYLON {
  55402. /**
  55403. * @hidden
  55404. */
  55405. export interface IMaterialClearCoatDefines {
  55406. CLEARCOAT: boolean;
  55407. CLEARCOAT_DEFAULTIOR: boolean;
  55408. CLEARCOAT_TEXTURE: boolean;
  55409. CLEARCOAT_TEXTUREDIRECTUV: number;
  55410. CLEARCOAT_BUMP: boolean;
  55411. CLEARCOAT_BUMPDIRECTUV: number;
  55412. CLEARCOAT_REMAP_F0: boolean;
  55413. CLEARCOAT_TINT: boolean;
  55414. CLEARCOAT_TINT_TEXTURE: boolean;
  55415. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55416. /** @hidden */
  55417. _areTexturesDirty: boolean;
  55418. }
  55419. /**
  55420. * Define the code related to the clear coat parameters of the pbr material.
  55421. */
  55422. export class PBRClearCoatConfiguration {
  55423. /**
  55424. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55425. * The default fits with a polyurethane material.
  55426. */
  55427. private static readonly _DefaultIndexOfRefraction;
  55428. private _isEnabled;
  55429. /**
  55430. * Defines if the clear coat is enabled in the material.
  55431. */
  55432. isEnabled: boolean;
  55433. /**
  55434. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55435. */
  55436. intensity: number;
  55437. /**
  55438. * Defines the clear coat layer roughness.
  55439. */
  55440. roughness: number;
  55441. private _indexOfRefraction;
  55442. /**
  55443. * Defines the index of refraction of the clear coat.
  55444. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55445. * The default fits with a polyurethane material.
  55446. * Changing the default value is more performance intensive.
  55447. */
  55448. indexOfRefraction: number;
  55449. private _texture;
  55450. /**
  55451. * Stores the clear coat values in a texture.
  55452. */
  55453. texture: Nullable<BaseTexture>;
  55454. private _remapF0OnInterfaceChange;
  55455. /**
  55456. * Defines if the F0 value should be remapped to account for the interface change in the material.
  55457. */
  55458. remapF0OnInterfaceChange: boolean;
  55459. private _bumpTexture;
  55460. /**
  55461. * Define the clear coat specific bump texture.
  55462. */
  55463. bumpTexture: Nullable<BaseTexture>;
  55464. private _isTintEnabled;
  55465. /**
  55466. * Defines if the clear coat tint is enabled in the material.
  55467. */
  55468. isTintEnabled: boolean;
  55469. /**
  55470. * Defines the clear coat tint of the material.
  55471. * This is only use if tint is enabled
  55472. */
  55473. tintColor: Color3;
  55474. /**
  55475. * Defines the distance at which the tint color should be found in the
  55476. * clear coat media.
  55477. * This is only use if tint is enabled
  55478. */
  55479. tintColorAtDistance: number;
  55480. /**
  55481. * Defines the clear coat layer thickness.
  55482. * This is only use if tint is enabled
  55483. */
  55484. tintThickness: number;
  55485. private _tintTexture;
  55486. /**
  55487. * Stores the clear tint values in a texture.
  55488. * rgb is tint
  55489. * a is a thickness factor
  55490. */
  55491. tintTexture: Nullable<BaseTexture>;
  55492. /** @hidden */
  55493. private _internalMarkAllSubMeshesAsTexturesDirty;
  55494. /** @hidden */
  55495. _markAllSubMeshesAsTexturesDirty(): void;
  55496. /**
  55497. * Instantiate a new istance of clear coat configuration.
  55498. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55499. */
  55500. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55501. /**
  55502. * Gets wehter the submesh is ready to be used or not.
  55503. * @param defines the list of "defines" to update.
  55504. * @param scene defines the scene the material belongs to.
  55505. * @param engine defines the engine the material belongs to.
  55506. * @param disableBumpMap defines wether the material disables bump or not.
  55507. * @returns - boolean indicating that the submesh is ready or not.
  55508. */
  55509. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55510. /**
  55511. * Checks to see if a texture is used in the material.
  55512. * @param defines the list of "defines" to update.
  55513. * @param scene defines the scene to the material belongs to.
  55514. */
  55515. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55516. /**
  55517. * Binds the material data.
  55518. * @param uniformBuffer defines the Uniform buffer to fill in.
  55519. * @param scene defines the scene the material belongs to.
  55520. * @param engine defines the engine the material belongs to.
  55521. * @param disableBumpMap defines wether the material disables bump or not.
  55522. * @param isFrozen defines wether the material is frozen or not.
  55523. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55524. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55525. */
  55526. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55527. /**
  55528. * Checks to see if a texture is used in the material.
  55529. * @param texture - Base texture to use.
  55530. * @returns - Boolean specifying if a texture is used in the material.
  55531. */
  55532. hasTexture(texture: BaseTexture): boolean;
  55533. /**
  55534. * Returns an array of the actively used textures.
  55535. * @param activeTextures Array of BaseTextures
  55536. */
  55537. getActiveTextures(activeTextures: BaseTexture[]): void;
  55538. /**
  55539. * Returns the animatable textures.
  55540. * @param animatables Array of animatable textures.
  55541. */
  55542. getAnimatables(animatables: IAnimatable[]): void;
  55543. /**
  55544. * Disposes the resources of the material.
  55545. * @param forceDisposeTextures - Forces the disposal of all textures.
  55546. */
  55547. dispose(forceDisposeTextures?: boolean): void;
  55548. /**
  55549. * Get the current class name of the texture useful for serialization or dynamic coding.
  55550. * @returns "PBRClearCoatConfiguration"
  55551. */
  55552. getClassName(): string;
  55553. /**
  55554. * Add fallbacks to the effect fallbacks list.
  55555. * @param defines defines the Base texture to use.
  55556. * @param fallbacks defines the current fallback list.
  55557. * @param currentRank defines the current fallback rank.
  55558. * @returns the new fallback rank.
  55559. */
  55560. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55561. /**
  55562. * Add the required uniforms to the current list.
  55563. * @param uniforms defines the current uniform list.
  55564. */
  55565. static AddUniforms(uniforms: string[]): void;
  55566. /**
  55567. * Add the required samplers to the current list.
  55568. * @param samplers defines the current sampler list.
  55569. */
  55570. static AddSamplers(samplers: string[]): void;
  55571. /**
  55572. * Add the required uniforms to the current buffer.
  55573. * @param uniformBuffer defines the current uniform buffer.
  55574. */
  55575. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55576. /**
  55577. * Makes a duplicate of the current configuration into another one.
  55578. * @param clearCoatConfiguration define the config where to copy the info
  55579. */
  55580. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55581. /**
  55582. * Serializes this clear coat configuration.
  55583. * @returns - An object with the serialized config.
  55584. */
  55585. serialize(): any;
  55586. /**
  55587. * Parses a anisotropy Configuration from a serialized object.
  55588. * @param source - Serialized object.
  55589. * @param scene Defines the scene we are parsing for
  55590. * @param rootUrl Defines the rootUrl to load from
  55591. */
  55592. parse(source: any, scene: Scene, rootUrl: string): void;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /**
  55597. * @hidden
  55598. */
  55599. export interface IMaterialAnisotropicDefines {
  55600. ANISOTROPIC: boolean;
  55601. ANISOTROPIC_TEXTURE: boolean;
  55602. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55603. MAINUV1: boolean;
  55604. _areTexturesDirty: boolean;
  55605. _needUVs: boolean;
  55606. }
  55607. /**
  55608. * Define the code related to the anisotropic parameters of the pbr material.
  55609. */
  55610. export class PBRAnisotropicConfiguration {
  55611. private _isEnabled;
  55612. /**
  55613. * Defines if the anisotropy is enabled in the material.
  55614. */
  55615. isEnabled: boolean;
  55616. /**
  55617. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55618. */
  55619. intensity: number;
  55620. /**
  55621. * Defines if the effect is along the tangents, bitangents or in between.
  55622. * By default, the effect is "strectching" the highlights along the tangents.
  55623. */
  55624. direction: Vector2;
  55625. private _texture;
  55626. /**
  55627. * Stores the anisotropy values in a texture.
  55628. * rg is direction (like normal from -1 to 1)
  55629. * b is a intensity
  55630. */
  55631. texture: Nullable<BaseTexture>;
  55632. /** @hidden */
  55633. private _internalMarkAllSubMeshesAsTexturesDirty;
  55634. /** @hidden */
  55635. _markAllSubMeshesAsTexturesDirty(): void;
  55636. /**
  55637. * Instantiate a new istance of anisotropy configuration.
  55638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55639. */
  55640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55641. /**
  55642. * Specifies that the submesh is ready to be used.
  55643. * @param defines the list of "defines" to update.
  55644. * @param scene defines the scene the material belongs to.
  55645. * @returns - boolean indicating that the submesh is ready or not.
  55646. */
  55647. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55648. /**
  55649. * Checks to see if a texture is used in the material.
  55650. * @param defines the list of "defines" to update.
  55651. * @param mesh the mesh we are preparing the defines for.
  55652. * @param scene defines the scene the material belongs to.
  55653. */
  55654. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55655. /**
  55656. * Binds the material data.
  55657. * @param uniformBuffer defines the Uniform buffer to fill in.
  55658. * @param scene defines the scene the material belongs to.
  55659. * @param isFrozen defines wether the material is frozen or not.
  55660. */
  55661. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55662. /**
  55663. * Checks to see if a texture is used in the material.
  55664. * @param texture - Base texture to use.
  55665. * @returns - Boolean specifying if a texture is used in the material.
  55666. */
  55667. hasTexture(texture: BaseTexture): boolean;
  55668. /**
  55669. * Returns an array of the actively used textures.
  55670. * @param activeTextures Array of BaseTextures
  55671. */
  55672. getActiveTextures(activeTextures: BaseTexture[]): void;
  55673. /**
  55674. * Returns the animatable textures.
  55675. * @param animatables Array of animatable textures.
  55676. */
  55677. getAnimatables(animatables: IAnimatable[]): void;
  55678. /**
  55679. * Disposes the resources of the material.
  55680. * @param forceDisposeTextures - Forces the disposal of all textures.
  55681. */
  55682. dispose(forceDisposeTextures?: boolean): void;
  55683. /**
  55684. * Get the current class name of the texture useful for serialization or dynamic coding.
  55685. * @returns "PBRAnisotropicConfiguration"
  55686. */
  55687. getClassName(): string;
  55688. /**
  55689. * Add fallbacks to the effect fallbacks list.
  55690. * @param defines defines the Base texture to use.
  55691. * @param fallbacks defines the current fallback list.
  55692. * @param currentRank defines the current fallback rank.
  55693. * @returns the new fallback rank.
  55694. */
  55695. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55696. /**
  55697. * Add the required uniforms to the current list.
  55698. * @param uniforms defines the current uniform list.
  55699. */
  55700. static AddUniforms(uniforms: string[]): void;
  55701. /**
  55702. * Add the required uniforms to the current buffer.
  55703. * @param uniformBuffer defines the current uniform buffer.
  55704. */
  55705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55706. /**
  55707. * Add the required samplers to the current list.
  55708. * @param samplers defines the current sampler list.
  55709. */
  55710. static AddSamplers(samplers: string[]): void;
  55711. /**
  55712. * Makes a duplicate of the current configuration into another one.
  55713. * @param anisotropicConfiguration define the config where to copy the info
  55714. */
  55715. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55716. /**
  55717. * Serializes this anisotropy configuration.
  55718. * @returns - An object with the serialized config.
  55719. */
  55720. serialize(): any;
  55721. /**
  55722. * Parses a anisotropy Configuration from a serialized object.
  55723. * @param source - Serialized object.
  55724. * @param scene Defines the scene we are parsing for
  55725. * @param rootUrl Defines the rootUrl to load from
  55726. */
  55727. parse(source: any, scene: Scene, rootUrl: string): void;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * @hidden
  55733. */
  55734. export interface IMaterialBRDFDefines {
  55735. BRDF_V_HEIGHT_CORRELATED: boolean;
  55736. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55737. SPHERICAL_HARMONICS: boolean;
  55738. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55739. /** @hidden */
  55740. _areMiscDirty: boolean;
  55741. }
  55742. /**
  55743. * Define the code related to the BRDF parameters of the pbr material.
  55744. */
  55745. export class PBRBRDFConfiguration {
  55746. /**
  55747. * Default value used for the energy conservation.
  55748. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55749. */
  55750. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55751. /**
  55752. * Default value used for the Smith Visibility Height Correlated mode.
  55753. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55754. */
  55755. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55756. /**
  55757. * Default value used for the IBL diffuse part.
  55758. * This can help switching back to the polynomials mode globally which is a tiny bit
  55759. * less GPU intensive at the drawback of a lower quality.
  55760. */
  55761. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55762. /**
  55763. * Default value used for activating energy conservation for the specular workflow.
  55764. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55765. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55766. */
  55767. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55768. private _useEnergyConservation;
  55769. /**
  55770. * Defines if the material uses energy conservation.
  55771. */
  55772. useEnergyConservation: boolean;
  55773. private _useSmithVisibilityHeightCorrelated;
  55774. /**
  55775. * LEGACY Mode set to false
  55776. * Defines if the material uses height smith correlated visibility term.
  55777. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55778. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55779. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55780. * Not relying on height correlated will also disable energy conservation.
  55781. */
  55782. useSmithVisibilityHeightCorrelated: boolean;
  55783. private _useSphericalHarmonics;
  55784. /**
  55785. * LEGACY Mode set to false
  55786. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55787. * diffuse part of the IBL.
  55788. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55789. * to the ground truth.
  55790. */
  55791. useSphericalHarmonics: boolean;
  55792. private _useSpecularGlossinessInputEnergyConservation;
  55793. /**
  55794. * Defines if the material uses energy conservation, when the specular workflow is active.
  55795. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55796. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55797. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55798. */
  55799. useSpecularGlossinessInputEnergyConservation: boolean;
  55800. /** @hidden */
  55801. private _internalMarkAllSubMeshesAsMiscDirty;
  55802. /** @hidden */
  55803. _markAllSubMeshesAsMiscDirty(): void;
  55804. /**
  55805. * Instantiate a new istance of clear coat configuration.
  55806. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55807. */
  55808. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55809. /**
  55810. * Checks to see if a texture is used in the material.
  55811. * @param defines the list of "defines" to update.
  55812. */
  55813. prepareDefines(defines: IMaterialBRDFDefines): void;
  55814. /**
  55815. * Get the current class name of the texture useful for serialization or dynamic coding.
  55816. * @returns "PBRClearCoatConfiguration"
  55817. */
  55818. getClassName(): string;
  55819. /**
  55820. * Makes a duplicate of the current configuration into another one.
  55821. * @param brdfConfiguration define the config where to copy the info
  55822. */
  55823. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55824. /**
  55825. * Serializes this BRDF configuration.
  55826. * @returns - An object with the serialized config.
  55827. */
  55828. serialize(): any;
  55829. /**
  55830. * Parses a anisotropy Configuration from a serialized object.
  55831. * @param source - Serialized object.
  55832. * @param scene Defines the scene we are parsing for
  55833. * @param rootUrl Defines the rootUrl to load from
  55834. */
  55835. parse(source: any, scene: Scene, rootUrl: string): void;
  55836. }
  55837. }
  55838. declare module BABYLON {
  55839. /**
  55840. * @hidden
  55841. */
  55842. export interface IMaterialSheenDefines {
  55843. SHEEN: boolean;
  55844. SHEEN_TEXTURE: boolean;
  55845. SHEEN_TEXTUREDIRECTUV: number;
  55846. SHEEN_LINKWITHALBEDO: boolean;
  55847. SHEEN_ROUGHNESS: boolean;
  55848. SHEEN_ALBEDOSCALING: boolean;
  55849. /** @hidden */
  55850. _areTexturesDirty: boolean;
  55851. }
  55852. /**
  55853. * Define the code related to the Sheen parameters of the pbr material.
  55854. */
  55855. export class PBRSheenConfiguration {
  55856. private _isEnabled;
  55857. /**
  55858. * Defines if the material uses sheen.
  55859. */
  55860. isEnabled: boolean;
  55861. private _linkSheenWithAlbedo;
  55862. /**
  55863. * Defines if the sheen is linked to the sheen color.
  55864. */
  55865. linkSheenWithAlbedo: boolean;
  55866. /**
  55867. * Defines the sheen intensity.
  55868. */
  55869. intensity: number;
  55870. /**
  55871. * Defines the sheen color.
  55872. */
  55873. color: Color3;
  55874. private _texture;
  55875. /**
  55876. * Stores the sheen tint values in a texture.
  55877. * rgb is tint
  55878. * a is a intensity or roughness if roughness has been defined
  55879. */
  55880. texture: Nullable<BaseTexture>;
  55881. private _roughness;
  55882. /**
  55883. * Defines the sheen roughness.
  55884. * It is not taken into account if linkSheenWithAlbedo is true.
  55885. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55886. */
  55887. roughness: Nullable<number>;
  55888. private _albedoScaling;
  55889. /**
  55890. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55891. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55892. * making it easier to setup and tweak the effect
  55893. */
  55894. albedoScaling: boolean;
  55895. /** @hidden */
  55896. private _internalMarkAllSubMeshesAsTexturesDirty;
  55897. /** @hidden */
  55898. _markAllSubMeshesAsTexturesDirty(): void;
  55899. /**
  55900. * Instantiate a new istance of clear coat configuration.
  55901. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55902. */
  55903. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55904. /**
  55905. * Specifies that the submesh is ready to be used.
  55906. * @param defines the list of "defines" to update.
  55907. * @param scene defines the scene the material belongs to.
  55908. * @returns - boolean indicating that the submesh is ready or not.
  55909. */
  55910. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55911. /**
  55912. * Checks to see if a texture is used in the material.
  55913. * @param defines the list of "defines" to update.
  55914. * @param scene defines the scene the material belongs to.
  55915. */
  55916. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55917. /**
  55918. * Binds the material data.
  55919. * @param uniformBuffer defines the Uniform buffer to fill in.
  55920. * @param scene defines the scene the material belongs to.
  55921. * @param isFrozen defines wether the material is frozen or not.
  55922. */
  55923. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55924. /**
  55925. * Checks to see if a texture is used in the material.
  55926. * @param texture - Base texture to use.
  55927. * @returns - Boolean specifying if a texture is used in the material.
  55928. */
  55929. hasTexture(texture: BaseTexture): boolean;
  55930. /**
  55931. * Returns an array of the actively used textures.
  55932. * @param activeTextures Array of BaseTextures
  55933. */
  55934. getActiveTextures(activeTextures: BaseTexture[]): void;
  55935. /**
  55936. * Returns the animatable textures.
  55937. * @param animatables Array of animatable textures.
  55938. */
  55939. getAnimatables(animatables: IAnimatable[]): void;
  55940. /**
  55941. * Disposes the resources of the material.
  55942. * @param forceDisposeTextures - Forces the disposal of all textures.
  55943. */
  55944. dispose(forceDisposeTextures?: boolean): void;
  55945. /**
  55946. * Get the current class name of the texture useful for serialization or dynamic coding.
  55947. * @returns "PBRSheenConfiguration"
  55948. */
  55949. getClassName(): string;
  55950. /**
  55951. * Add fallbacks to the effect fallbacks list.
  55952. * @param defines defines the Base texture to use.
  55953. * @param fallbacks defines the current fallback list.
  55954. * @param currentRank defines the current fallback rank.
  55955. * @returns the new fallback rank.
  55956. */
  55957. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55958. /**
  55959. * Add the required uniforms to the current list.
  55960. * @param uniforms defines the current uniform list.
  55961. */
  55962. static AddUniforms(uniforms: string[]): void;
  55963. /**
  55964. * Add the required uniforms to the current buffer.
  55965. * @param uniformBuffer defines the current uniform buffer.
  55966. */
  55967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55968. /**
  55969. * Add the required samplers to the current list.
  55970. * @param samplers defines the current sampler list.
  55971. */
  55972. static AddSamplers(samplers: string[]): void;
  55973. /**
  55974. * Makes a duplicate of the current configuration into another one.
  55975. * @param sheenConfiguration define the config where to copy the info
  55976. */
  55977. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55978. /**
  55979. * Serializes this BRDF configuration.
  55980. * @returns - An object with the serialized config.
  55981. */
  55982. serialize(): any;
  55983. /**
  55984. * Parses a anisotropy Configuration from a serialized object.
  55985. * @param source - Serialized object.
  55986. * @param scene Defines the scene we are parsing for
  55987. * @param rootUrl Defines the rootUrl to load from
  55988. */
  55989. parse(source: any, scene: Scene, rootUrl: string): void;
  55990. }
  55991. }
  55992. declare module BABYLON {
  55993. /**
  55994. * @hidden
  55995. */
  55996. export interface IMaterialSubSurfaceDefines {
  55997. SUBSURFACE: boolean;
  55998. SS_REFRACTION: boolean;
  55999. SS_TRANSLUCENCY: boolean;
  56000. SS_SCATTERING: boolean;
  56001. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56002. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56003. SS_REFRACTIONMAP_3D: boolean;
  56004. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56005. SS_LODINREFRACTIONALPHA: boolean;
  56006. SS_GAMMAREFRACTION: boolean;
  56007. SS_RGBDREFRACTION: boolean;
  56008. SS_LINEARSPECULARREFRACTION: boolean;
  56009. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56010. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56011. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56012. /** @hidden */
  56013. _areTexturesDirty: boolean;
  56014. }
  56015. /**
  56016. * Define the code related to the sub surface parameters of the pbr material.
  56017. */
  56018. export class PBRSubSurfaceConfiguration {
  56019. private _isRefractionEnabled;
  56020. /**
  56021. * Defines if the refraction is enabled in the material.
  56022. */
  56023. isRefractionEnabled: boolean;
  56024. private _isTranslucencyEnabled;
  56025. /**
  56026. * Defines if the translucency is enabled in the material.
  56027. */
  56028. isTranslucencyEnabled: boolean;
  56029. private _isScatteringEnabled;
  56030. /**
  56031. * Defines if the sub surface scattering is enabled in the material.
  56032. */
  56033. isScatteringEnabled: boolean;
  56034. private _scatteringDiffusionProfileIndex;
  56035. /**
  56036. * Diffusion profile for subsurface scattering.
  56037. * Useful for better scattering in the skins or foliages.
  56038. */
  56039. get scatteringDiffusionProfile(): Nullable<Color3>;
  56040. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56041. /**
  56042. * Defines the refraction intensity of the material.
  56043. * The refraction when enabled replaces the Diffuse part of the material.
  56044. * The intensity helps transitionning between diffuse and refraction.
  56045. */
  56046. refractionIntensity: number;
  56047. /**
  56048. * Defines the translucency intensity of the material.
  56049. * When translucency has been enabled, this defines how much of the "translucency"
  56050. * is addded to the diffuse part of the material.
  56051. */
  56052. translucencyIntensity: number;
  56053. /**
  56054. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56055. */
  56056. useAlbedoToTintRefraction: boolean;
  56057. private _thicknessTexture;
  56058. /**
  56059. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56060. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56061. * 0 would mean minimumThickness
  56062. * 1 would mean maximumThickness
  56063. * The other channels might be use as a mask to vary the different effects intensity.
  56064. */
  56065. thicknessTexture: Nullable<BaseTexture>;
  56066. private _refractionTexture;
  56067. /**
  56068. * Defines the texture to use for refraction.
  56069. */
  56070. refractionTexture: Nullable<BaseTexture>;
  56071. private _indexOfRefraction;
  56072. /**
  56073. * Index of refraction of the material base layer.
  56074. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56075. *
  56076. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56077. *
  56078. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56079. */
  56080. indexOfRefraction: number;
  56081. private _volumeIndexOfRefraction;
  56082. /**
  56083. * Index of refraction of the material's volume.
  56084. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56085. *
  56086. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56087. * the volume will use the same IOR as the surface.
  56088. */
  56089. get volumeIndexOfRefraction(): number;
  56090. set volumeIndexOfRefraction(value: number);
  56091. private _invertRefractionY;
  56092. /**
  56093. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56094. */
  56095. invertRefractionY: boolean;
  56096. private _linkRefractionWithTransparency;
  56097. /**
  56098. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56099. * Materials half opaque for instance using refraction could benefit from this control.
  56100. */
  56101. linkRefractionWithTransparency: boolean;
  56102. /**
  56103. * Defines the minimum thickness stored in the thickness map.
  56104. * If no thickness map is defined, this value will be used to simulate thickness.
  56105. */
  56106. minimumThickness: number;
  56107. /**
  56108. * Defines the maximum thickness stored in the thickness map.
  56109. */
  56110. maximumThickness: number;
  56111. /**
  56112. * Defines the volume tint of the material.
  56113. * This is used for both translucency and scattering.
  56114. */
  56115. tintColor: Color3;
  56116. /**
  56117. * Defines the distance at which the tint color should be found in the media.
  56118. * This is used for refraction only.
  56119. */
  56120. tintColorAtDistance: number;
  56121. /**
  56122. * Defines how far each channel transmit through the media.
  56123. * It is defined as a color to simplify it selection.
  56124. */
  56125. diffusionDistance: Color3;
  56126. private _useMaskFromThicknessTexture;
  56127. /**
  56128. * Stores the intensity of the different subsurface effects in the thickness texture.
  56129. * * the green channel is the translucency intensity.
  56130. * * the blue channel is the scattering intensity.
  56131. * * the alpha channel is the refraction intensity.
  56132. */
  56133. useMaskFromThicknessTexture: boolean;
  56134. private _scene;
  56135. /** @hidden */
  56136. private _internalMarkAllSubMeshesAsTexturesDirty;
  56137. private _internalMarkScenePrePassDirty;
  56138. /** @hidden */
  56139. _markAllSubMeshesAsTexturesDirty(): void;
  56140. /** @hidden */
  56141. _markScenePrePassDirty(): void;
  56142. /**
  56143. * Instantiate a new istance of sub surface configuration.
  56144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56145. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56146. * @param scene The scene
  56147. */
  56148. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56149. /**
  56150. * Gets wehter the submesh is ready to be used or not.
  56151. * @param defines the list of "defines" to update.
  56152. * @param scene defines the scene the material belongs to.
  56153. * @returns - boolean indicating that the submesh is ready or not.
  56154. */
  56155. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56156. /**
  56157. * Checks to see if a texture is used in the material.
  56158. * @param defines the list of "defines" to update.
  56159. * @param scene defines the scene to the material belongs to.
  56160. */
  56161. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56162. /**
  56163. * Binds the material data.
  56164. * @param uniformBuffer defines the Uniform buffer to fill in.
  56165. * @param scene defines the scene the material belongs to.
  56166. * @param engine defines the engine the material belongs to.
  56167. * @param isFrozen defines whether the material is frozen or not.
  56168. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56169. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56170. */
  56171. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56172. /**
  56173. * Unbinds the material from the mesh.
  56174. * @param activeEffect defines the effect that should be unbound from.
  56175. * @returns true if unbound, otherwise false
  56176. */
  56177. unbind(activeEffect: Effect): boolean;
  56178. /**
  56179. * Returns the texture used for refraction or null if none is used.
  56180. * @param scene defines the scene the material belongs to.
  56181. * @returns - Refraction texture if present. If no refraction texture and refraction
  56182. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56183. */
  56184. private _getRefractionTexture;
  56185. /**
  56186. * Returns true if alpha blending should be disabled.
  56187. */
  56188. get disableAlphaBlending(): boolean;
  56189. /**
  56190. * Fills the list of render target textures.
  56191. * @param renderTargets the list of render targets to update
  56192. */
  56193. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56194. /**
  56195. * Checks to see if a texture is used in the material.
  56196. * @param texture - Base texture to use.
  56197. * @returns - Boolean specifying if a texture is used in the material.
  56198. */
  56199. hasTexture(texture: BaseTexture): boolean;
  56200. /**
  56201. * Gets a boolean indicating that current material needs to register RTT
  56202. * @returns true if this uses a render target otherwise false.
  56203. */
  56204. hasRenderTargetTextures(): boolean;
  56205. /**
  56206. * Returns an array of the actively used textures.
  56207. * @param activeTextures Array of BaseTextures
  56208. */
  56209. getActiveTextures(activeTextures: BaseTexture[]): void;
  56210. /**
  56211. * Returns the animatable textures.
  56212. * @param animatables Array of animatable textures.
  56213. */
  56214. getAnimatables(animatables: IAnimatable[]): void;
  56215. /**
  56216. * Disposes the resources of the material.
  56217. * @param forceDisposeTextures - Forces the disposal of all textures.
  56218. */
  56219. dispose(forceDisposeTextures?: boolean): void;
  56220. /**
  56221. * Get the current class name of the texture useful for serialization or dynamic coding.
  56222. * @returns "PBRSubSurfaceConfiguration"
  56223. */
  56224. getClassName(): string;
  56225. /**
  56226. * Add fallbacks to the effect fallbacks list.
  56227. * @param defines defines the Base texture to use.
  56228. * @param fallbacks defines the current fallback list.
  56229. * @param currentRank defines the current fallback rank.
  56230. * @returns the new fallback rank.
  56231. */
  56232. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56233. /**
  56234. * Add the required uniforms to the current list.
  56235. * @param uniforms defines the current uniform list.
  56236. */
  56237. static AddUniforms(uniforms: string[]): void;
  56238. /**
  56239. * Add the required samplers to the current list.
  56240. * @param samplers defines the current sampler list.
  56241. */
  56242. static AddSamplers(samplers: string[]): void;
  56243. /**
  56244. * Add the required uniforms to the current buffer.
  56245. * @param uniformBuffer defines the current uniform buffer.
  56246. */
  56247. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56248. /**
  56249. * Makes a duplicate of the current configuration into another one.
  56250. * @param configuration define the config where to copy the info
  56251. */
  56252. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56253. /**
  56254. * Serializes this Sub Surface configuration.
  56255. * @returns - An object with the serialized config.
  56256. */
  56257. serialize(): any;
  56258. /**
  56259. * Parses a anisotropy Configuration from a serialized object.
  56260. * @param source - Serialized object.
  56261. * @param scene Defines the scene we are parsing for
  56262. * @param rootUrl Defines the rootUrl to load from
  56263. */
  56264. parse(source: any, scene: Scene, rootUrl: string): void;
  56265. }
  56266. }
  56267. declare module BABYLON {
  56268. /** @hidden */
  56269. export var pbrFragmentDeclaration: {
  56270. name: string;
  56271. shader: string;
  56272. };
  56273. }
  56274. declare module BABYLON {
  56275. /** @hidden */
  56276. export var pbrUboDeclaration: {
  56277. name: string;
  56278. shader: string;
  56279. };
  56280. }
  56281. declare module BABYLON {
  56282. /** @hidden */
  56283. export var pbrFragmentExtraDeclaration: {
  56284. name: string;
  56285. shader: string;
  56286. };
  56287. }
  56288. declare module BABYLON {
  56289. /** @hidden */
  56290. export var pbrFragmentSamplersDeclaration: {
  56291. name: string;
  56292. shader: string;
  56293. };
  56294. }
  56295. declare module BABYLON {
  56296. /** @hidden */
  56297. export var subSurfaceScatteringFunctions: {
  56298. name: string;
  56299. shader: string;
  56300. };
  56301. }
  56302. declare module BABYLON {
  56303. /** @hidden */
  56304. export var importanceSampling: {
  56305. name: string;
  56306. shader: string;
  56307. };
  56308. }
  56309. declare module BABYLON {
  56310. /** @hidden */
  56311. export var pbrHelperFunctions: {
  56312. name: string;
  56313. shader: string;
  56314. };
  56315. }
  56316. declare module BABYLON {
  56317. /** @hidden */
  56318. export var harmonicsFunctions: {
  56319. name: string;
  56320. shader: string;
  56321. };
  56322. }
  56323. declare module BABYLON {
  56324. /** @hidden */
  56325. export var pbrDirectLightingSetupFunctions: {
  56326. name: string;
  56327. shader: string;
  56328. };
  56329. }
  56330. declare module BABYLON {
  56331. /** @hidden */
  56332. export var pbrDirectLightingFalloffFunctions: {
  56333. name: string;
  56334. shader: string;
  56335. };
  56336. }
  56337. declare module BABYLON {
  56338. /** @hidden */
  56339. export var pbrBRDFFunctions: {
  56340. name: string;
  56341. shader: string;
  56342. };
  56343. }
  56344. declare module BABYLON {
  56345. /** @hidden */
  56346. export var hdrFilteringFunctions: {
  56347. name: string;
  56348. shader: string;
  56349. };
  56350. }
  56351. declare module BABYLON {
  56352. /** @hidden */
  56353. export var pbrDirectLightingFunctions: {
  56354. name: string;
  56355. shader: string;
  56356. };
  56357. }
  56358. declare module BABYLON {
  56359. /** @hidden */
  56360. export var pbrIBLFunctions: {
  56361. name: string;
  56362. shader: string;
  56363. };
  56364. }
  56365. declare module BABYLON {
  56366. /** @hidden */
  56367. export var pbrBlockAlbedoOpacity: {
  56368. name: string;
  56369. shader: string;
  56370. };
  56371. }
  56372. declare module BABYLON {
  56373. /** @hidden */
  56374. export var pbrBlockReflectivity: {
  56375. name: string;
  56376. shader: string;
  56377. };
  56378. }
  56379. declare module BABYLON {
  56380. /** @hidden */
  56381. export var pbrBlockAmbientOcclusion: {
  56382. name: string;
  56383. shader: string;
  56384. };
  56385. }
  56386. declare module BABYLON {
  56387. /** @hidden */
  56388. export var pbrBlockAlphaFresnel: {
  56389. name: string;
  56390. shader: string;
  56391. };
  56392. }
  56393. declare module BABYLON {
  56394. /** @hidden */
  56395. export var pbrBlockAnisotropic: {
  56396. name: string;
  56397. shader: string;
  56398. };
  56399. }
  56400. declare module BABYLON {
  56401. /** @hidden */
  56402. export var pbrBlockReflection: {
  56403. name: string;
  56404. shader: string;
  56405. };
  56406. }
  56407. declare module BABYLON {
  56408. /** @hidden */
  56409. export var pbrBlockSheen: {
  56410. name: string;
  56411. shader: string;
  56412. };
  56413. }
  56414. declare module BABYLON {
  56415. /** @hidden */
  56416. export var pbrBlockClearcoat: {
  56417. name: string;
  56418. shader: string;
  56419. };
  56420. }
  56421. declare module BABYLON {
  56422. /** @hidden */
  56423. export var pbrBlockSubSurface: {
  56424. name: string;
  56425. shader: string;
  56426. };
  56427. }
  56428. declare module BABYLON {
  56429. /** @hidden */
  56430. export var pbrBlockNormalGeometric: {
  56431. name: string;
  56432. shader: string;
  56433. };
  56434. }
  56435. declare module BABYLON {
  56436. /** @hidden */
  56437. export var pbrBlockNormalFinal: {
  56438. name: string;
  56439. shader: string;
  56440. };
  56441. }
  56442. declare module BABYLON {
  56443. /** @hidden */
  56444. export var pbrBlockLightmapInit: {
  56445. name: string;
  56446. shader: string;
  56447. };
  56448. }
  56449. declare module BABYLON {
  56450. /** @hidden */
  56451. export var pbrBlockGeometryInfo: {
  56452. name: string;
  56453. shader: string;
  56454. };
  56455. }
  56456. declare module BABYLON {
  56457. /** @hidden */
  56458. export var pbrBlockReflectance0: {
  56459. name: string;
  56460. shader: string;
  56461. };
  56462. }
  56463. declare module BABYLON {
  56464. /** @hidden */
  56465. export var pbrBlockReflectance: {
  56466. name: string;
  56467. shader: string;
  56468. };
  56469. }
  56470. declare module BABYLON {
  56471. /** @hidden */
  56472. export var pbrBlockDirectLighting: {
  56473. name: string;
  56474. shader: string;
  56475. };
  56476. }
  56477. declare module BABYLON {
  56478. /** @hidden */
  56479. export var pbrBlockFinalLitComponents: {
  56480. name: string;
  56481. shader: string;
  56482. };
  56483. }
  56484. declare module BABYLON {
  56485. /** @hidden */
  56486. export var pbrBlockFinalUnlitComponents: {
  56487. name: string;
  56488. shader: string;
  56489. };
  56490. }
  56491. declare module BABYLON {
  56492. /** @hidden */
  56493. export var pbrBlockFinalColorComposition: {
  56494. name: string;
  56495. shader: string;
  56496. };
  56497. }
  56498. declare module BABYLON {
  56499. /** @hidden */
  56500. export var pbrBlockImageProcessing: {
  56501. name: string;
  56502. shader: string;
  56503. };
  56504. }
  56505. declare module BABYLON {
  56506. /** @hidden */
  56507. export var pbrDebug: {
  56508. name: string;
  56509. shader: string;
  56510. };
  56511. }
  56512. declare module BABYLON {
  56513. /** @hidden */
  56514. export var pbrPixelShader: {
  56515. name: string;
  56516. shader: string;
  56517. };
  56518. }
  56519. declare module BABYLON {
  56520. /** @hidden */
  56521. export var pbrVertexDeclaration: {
  56522. name: string;
  56523. shader: string;
  56524. };
  56525. }
  56526. declare module BABYLON {
  56527. /** @hidden */
  56528. export var pbrVertexShader: {
  56529. name: string;
  56530. shader: string;
  56531. };
  56532. }
  56533. declare module BABYLON {
  56534. /**
  56535. * Manages the defines for the PBR Material.
  56536. * @hidden
  56537. */
  56538. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56539. PBR: boolean;
  56540. NUM_SAMPLES: string;
  56541. REALTIME_FILTERING: boolean;
  56542. MAINUV1: boolean;
  56543. MAINUV2: boolean;
  56544. UV1: boolean;
  56545. UV2: boolean;
  56546. ALBEDO: boolean;
  56547. GAMMAALBEDO: boolean;
  56548. ALBEDODIRECTUV: number;
  56549. VERTEXCOLOR: boolean;
  56550. DETAIL: boolean;
  56551. DETAILDIRECTUV: number;
  56552. DETAIL_NORMALBLENDMETHOD: number;
  56553. AMBIENT: boolean;
  56554. AMBIENTDIRECTUV: number;
  56555. AMBIENTINGRAYSCALE: boolean;
  56556. OPACITY: boolean;
  56557. VERTEXALPHA: boolean;
  56558. OPACITYDIRECTUV: number;
  56559. OPACITYRGB: boolean;
  56560. ALPHATEST: boolean;
  56561. DEPTHPREPASS: boolean;
  56562. ALPHABLEND: boolean;
  56563. ALPHAFROMALBEDO: boolean;
  56564. ALPHATESTVALUE: string;
  56565. SPECULAROVERALPHA: boolean;
  56566. RADIANCEOVERALPHA: boolean;
  56567. ALPHAFRESNEL: boolean;
  56568. LINEARALPHAFRESNEL: boolean;
  56569. PREMULTIPLYALPHA: boolean;
  56570. EMISSIVE: boolean;
  56571. EMISSIVEDIRECTUV: number;
  56572. REFLECTIVITY: boolean;
  56573. REFLECTIVITYDIRECTUV: number;
  56574. SPECULARTERM: boolean;
  56575. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56576. MICROSURFACEAUTOMATIC: boolean;
  56577. LODBASEDMICROSFURACE: boolean;
  56578. MICROSURFACEMAP: boolean;
  56579. MICROSURFACEMAPDIRECTUV: number;
  56580. METALLICWORKFLOW: boolean;
  56581. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56582. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56583. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56584. AOSTOREINMETALMAPRED: boolean;
  56585. METALLIC_REFLECTANCE: boolean;
  56586. METALLIC_REFLECTANCEDIRECTUV: number;
  56587. ENVIRONMENTBRDF: boolean;
  56588. ENVIRONMENTBRDF_RGBD: boolean;
  56589. NORMAL: boolean;
  56590. TANGENT: boolean;
  56591. BUMP: boolean;
  56592. BUMPDIRECTUV: number;
  56593. OBJECTSPACE_NORMALMAP: boolean;
  56594. PARALLAX: boolean;
  56595. PARALLAXOCCLUSION: boolean;
  56596. NORMALXYSCALE: boolean;
  56597. LIGHTMAP: boolean;
  56598. LIGHTMAPDIRECTUV: number;
  56599. USELIGHTMAPASSHADOWMAP: boolean;
  56600. GAMMALIGHTMAP: boolean;
  56601. RGBDLIGHTMAP: boolean;
  56602. REFLECTION: boolean;
  56603. REFLECTIONMAP_3D: boolean;
  56604. REFLECTIONMAP_SPHERICAL: boolean;
  56605. REFLECTIONMAP_PLANAR: boolean;
  56606. REFLECTIONMAP_CUBIC: boolean;
  56607. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56608. REFLECTIONMAP_PROJECTION: boolean;
  56609. REFLECTIONMAP_SKYBOX: boolean;
  56610. REFLECTIONMAP_EXPLICIT: boolean;
  56611. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56612. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56613. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56614. INVERTCUBICMAP: boolean;
  56615. USESPHERICALFROMREFLECTIONMAP: boolean;
  56616. USEIRRADIANCEMAP: boolean;
  56617. SPHERICAL_HARMONICS: boolean;
  56618. USESPHERICALINVERTEX: boolean;
  56619. REFLECTIONMAP_OPPOSITEZ: boolean;
  56620. LODINREFLECTIONALPHA: boolean;
  56621. GAMMAREFLECTION: boolean;
  56622. RGBDREFLECTION: boolean;
  56623. LINEARSPECULARREFLECTION: boolean;
  56624. RADIANCEOCCLUSION: boolean;
  56625. HORIZONOCCLUSION: boolean;
  56626. INSTANCES: boolean;
  56627. THIN_INSTANCES: boolean;
  56628. PREPASS: boolean;
  56629. PREPASS_IRRADIANCE: boolean;
  56630. PREPASS_IRRADIANCE_INDEX: number;
  56631. PREPASS_ALBEDO: boolean;
  56632. PREPASS_ALBEDO_INDEX: number;
  56633. PREPASS_DEPTHNORMAL: boolean;
  56634. PREPASS_DEPTHNORMAL_INDEX: number;
  56635. SCENE_MRT_COUNT: number;
  56636. NUM_BONE_INFLUENCERS: number;
  56637. BonesPerMesh: number;
  56638. BONETEXTURE: boolean;
  56639. NONUNIFORMSCALING: boolean;
  56640. MORPHTARGETS: boolean;
  56641. MORPHTARGETS_NORMAL: boolean;
  56642. MORPHTARGETS_TANGENT: boolean;
  56643. MORPHTARGETS_UV: boolean;
  56644. NUM_MORPH_INFLUENCERS: number;
  56645. IMAGEPROCESSING: boolean;
  56646. VIGNETTE: boolean;
  56647. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56648. VIGNETTEBLENDMODEOPAQUE: boolean;
  56649. TONEMAPPING: boolean;
  56650. TONEMAPPING_ACES: boolean;
  56651. CONTRAST: boolean;
  56652. COLORCURVES: boolean;
  56653. COLORGRADING: boolean;
  56654. COLORGRADING3D: boolean;
  56655. SAMPLER3DGREENDEPTH: boolean;
  56656. SAMPLER3DBGRMAP: boolean;
  56657. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56658. EXPOSURE: boolean;
  56659. MULTIVIEW: boolean;
  56660. USEPHYSICALLIGHTFALLOFF: boolean;
  56661. USEGLTFLIGHTFALLOFF: boolean;
  56662. TWOSIDEDLIGHTING: boolean;
  56663. SHADOWFLOAT: boolean;
  56664. CLIPPLANE: boolean;
  56665. CLIPPLANE2: boolean;
  56666. CLIPPLANE3: boolean;
  56667. CLIPPLANE4: boolean;
  56668. CLIPPLANE5: boolean;
  56669. CLIPPLANE6: boolean;
  56670. POINTSIZE: boolean;
  56671. FOG: boolean;
  56672. LOGARITHMICDEPTH: boolean;
  56673. FORCENORMALFORWARD: boolean;
  56674. SPECULARAA: boolean;
  56675. CLEARCOAT: boolean;
  56676. CLEARCOAT_DEFAULTIOR: boolean;
  56677. CLEARCOAT_TEXTURE: boolean;
  56678. CLEARCOAT_TEXTUREDIRECTUV: number;
  56679. CLEARCOAT_BUMP: boolean;
  56680. CLEARCOAT_BUMPDIRECTUV: number;
  56681. CLEARCOAT_REMAP_F0: boolean;
  56682. CLEARCOAT_TINT: boolean;
  56683. CLEARCOAT_TINT_TEXTURE: boolean;
  56684. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56685. ANISOTROPIC: boolean;
  56686. ANISOTROPIC_TEXTURE: boolean;
  56687. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56688. BRDF_V_HEIGHT_CORRELATED: boolean;
  56689. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56690. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56691. SHEEN: boolean;
  56692. SHEEN_TEXTURE: boolean;
  56693. SHEEN_TEXTUREDIRECTUV: number;
  56694. SHEEN_LINKWITHALBEDO: boolean;
  56695. SHEEN_ROUGHNESS: boolean;
  56696. SHEEN_ALBEDOSCALING: boolean;
  56697. SUBSURFACE: boolean;
  56698. SS_REFRACTION: boolean;
  56699. SS_TRANSLUCENCY: boolean;
  56700. SS_SCATTERING: boolean;
  56701. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56702. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56703. SS_REFRACTIONMAP_3D: boolean;
  56704. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56705. SS_LODINREFRACTIONALPHA: boolean;
  56706. SS_GAMMAREFRACTION: boolean;
  56707. SS_RGBDREFRACTION: boolean;
  56708. SS_LINEARSPECULARREFRACTION: boolean;
  56709. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56710. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56711. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56712. UNLIT: boolean;
  56713. DEBUGMODE: number;
  56714. /**
  56715. * Initializes the PBR Material defines.
  56716. */
  56717. constructor();
  56718. /**
  56719. * Resets the PBR Material defines.
  56720. */
  56721. reset(): void;
  56722. }
  56723. /**
  56724. * The Physically based material base class of BJS.
  56725. *
  56726. * This offers the main features of a standard PBR material.
  56727. * For more information, please refer to the documentation :
  56728. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56729. */
  56730. export abstract class PBRBaseMaterial extends PushMaterial {
  56731. /**
  56732. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56733. */
  56734. static readonly PBRMATERIAL_OPAQUE: number;
  56735. /**
  56736. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56737. */
  56738. static readonly PBRMATERIAL_ALPHATEST: number;
  56739. /**
  56740. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56741. */
  56742. static readonly PBRMATERIAL_ALPHABLEND: number;
  56743. /**
  56744. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56745. * They are also discarded below the alpha cutoff threshold to improve performances.
  56746. */
  56747. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56748. /**
  56749. * Defines the default value of how much AO map is occluding the analytical lights
  56750. * (point spot...).
  56751. */
  56752. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56753. /**
  56754. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56755. */
  56756. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56757. /**
  56758. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56759. * to enhance interoperability with other engines.
  56760. */
  56761. static readonly LIGHTFALLOFF_GLTF: number;
  56762. /**
  56763. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56764. * to enhance interoperability with other materials.
  56765. */
  56766. static readonly LIGHTFALLOFF_STANDARD: number;
  56767. /**
  56768. * Intensity of the direct lights e.g. the four lights available in your scene.
  56769. * This impacts both the direct diffuse and specular highlights.
  56770. */
  56771. protected _directIntensity: number;
  56772. /**
  56773. * Intensity of the emissive part of the material.
  56774. * This helps controlling the emissive effect without modifying the emissive color.
  56775. */
  56776. protected _emissiveIntensity: number;
  56777. /**
  56778. * Intensity of the environment e.g. how much the environment will light the object
  56779. * either through harmonics for rough material or through the refelction for shiny ones.
  56780. */
  56781. protected _environmentIntensity: number;
  56782. /**
  56783. * This is a special control allowing the reduction of the specular highlights coming from the
  56784. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56785. */
  56786. protected _specularIntensity: number;
  56787. /**
  56788. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56789. */
  56790. private _lightingInfos;
  56791. /**
  56792. * Debug Control allowing disabling the bump map on this material.
  56793. */
  56794. protected _disableBumpMap: boolean;
  56795. /**
  56796. * AKA Diffuse Texture in standard nomenclature.
  56797. */
  56798. protected _albedoTexture: Nullable<BaseTexture>;
  56799. /**
  56800. * AKA Occlusion Texture in other nomenclature.
  56801. */
  56802. protected _ambientTexture: Nullable<BaseTexture>;
  56803. /**
  56804. * AKA Occlusion Texture Intensity in other nomenclature.
  56805. */
  56806. protected _ambientTextureStrength: number;
  56807. /**
  56808. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56809. * 1 means it completely occludes it
  56810. * 0 mean it has no impact
  56811. */
  56812. protected _ambientTextureImpactOnAnalyticalLights: number;
  56813. /**
  56814. * Stores the alpha values in a texture.
  56815. */
  56816. protected _opacityTexture: Nullable<BaseTexture>;
  56817. /**
  56818. * Stores the reflection values in a texture.
  56819. */
  56820. protected _reflectionTexture: Nullable<BaseTexture>;
  56821. /**
  56822. * Stores the emissive values in a texture.
  56823. */
  56824. protected _emissiveTexture: Nullable<BaseTexture>;
  56825. /**
  56826. * AKA Specular texture in other nomenclature.
  56827. */
  56828. protected _reflectivityTexture: Nullable<BaseTexture>;
  56829. /**
  56830. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56831. */
  56832. protected _metallicTexture: Nullable<BaseTexture>;
  56833. /**
  56834. * Specifies the metallic scalar of the metallic/roughness workflow.
  56835. * Can also be used to scale the metalness values of the metallic texture.
  56836. */
  56837. protected _metallic: Nullable<number>;
  56838. /**
  56839. * Specifies the roughness scalar of the metallic/roughness workflow.
  56840. * Can also be used to scale the roughness values of the metallic texture.
  56841. */
  56842. protected _roughness: Nullable<number>;
  56843. /**
  56844. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56845. * By default the indexOfrefraction is used to compute F0;
  56846. *
  56847. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56848. *
  56849. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56850. * F90 = metallicReflectanceColor;
  56851. */
  56852. protected _metallicF0Factor: number;
  56853. /**
  56854. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56855. * By default the F90 is always 1;
  56856. *
  56857. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56858. *
  56859. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56860. * F90 = metallicReflectanceColor;
  56861. */
  56862. protected _metallicReflectanceColor: Color3;
  56863. /**
  56864. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56865. * This is multiply against the scalar values defined in the material.
  56866. */
  56867. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56868. /**
  56869. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56870. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56871. */
  56872. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56873. /**
  56874. * Stores surface normal data used to displace a mesh in a texture.
  56875. */
  56876. protected _bumpTexture: Nullable<BaseTexture>;
  56877. /**
  56878. * Stores the pre-calculated light information of a mesh in a texture.
  56879. */
  56880. protected _lightmapTexture: Nullable<BaseTexture>;
  56881. /**
  56882. * The color of a material in ambient lighting.
  56883. */
  56884. protected _ambientColor: Color3;
  56885. /**
  56886. * AKA Diffuse Color in other nomenclature.
  56887. */
  56888. protected _albedoColor: Color3;
  56889. /**
  56890. * AKA Specular Color in other nomenclature.
  56891. */
  56892. protected _reflectivityColor: Color3;
  56893. /**
  56894. * The color applied when light is reflected from a material.
  56895. */
  56896. protected _reflectionColor: Color3;
  56897. /**
  56898. * The color applied when light is emitted from a material.
  56899. */
  56900. protected _emissiveColor: Color3;
  56901. /**
  56902. * AKA Glossiness in other nomenclature.
  56903. */
  56904. protected _microSurface: number;
  56905. /**
  56906. * Specifies that the material will use the light map as a show map.
  56907. */
  56908. protected _useLightmapAsShadowmap: boolean;
  56909. /**
  56910. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56911. * makes the reflect vector face the model (under horizon).
  56912. */
  56913. protected _useHorizonOcclusion: boolean;
  56914. /**
  56915. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56916. * too much the area relying on ambient texture to define their ambient occlusion.
  56917. */
  56918. protected _useRadianceOcclusion: boolean;
  56919. /**
  56920. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56921. */
  56922. protected _useAlphaFromAlbedoTexture: boolean;
  56923. /**
  56924. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56926. */
  56927. protected _useSpecularOverAlpha: boolean;
  56928. /**
  56929. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56930. */
  56931. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56932. /**
  56933. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56934. */
  56935. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56936. /**
  56937. * Specifies if the metallic texture contains the roughness information in its green channel.
  56938. */
  56939. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56940. /**
  56941. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56942. */
  56943. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56944. /**
  56945. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56946. */
  56947. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56948. /**
  56949. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56950. */
  56951. protected _useAmbientInGrayScale: boolean;
  56952. /**
  56953. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56954. * The material will try to infer what glossiness each pixel should be.
  56955. */
  56956. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56957. /**
  56958. * Defines the falloff type used in this material.
  56959. * It by default is Physical.
  56960. */
  56961. protected _lightFalloff: number;
  56962. /**
  56963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56965. */
  56966. protected _useRadianceOverAlpha: boolean;
  56967. /**
  56968. * Allows using an object space normal map (instead of tangent space).
  56969. */
  56970. protected _useObjectSpaceNormalMap: boolean;
  56971. /**
  56972. * Allows using the bump map in parallax mode.
  56973. */
  56974. protected _useParallax: boolean;
  56975. /**
  56976. * Allows using the bump map in parallax occlusion mode.
  56977. */
  56978. protected _useParallaxOcclusion: boolean;
  56979. /**
  56980. * Controls the scale bias of the parallax mode.
  56981. */
  56982. protected _parallaxScaleBias: number;
  56983. /**
  56984. * If sets to true, disables all the lights affecting the material.
  56985. */
  56986. protected _disableLighting: boolean;
  56987. /**
  56988. * Number of Simultaneous lights allowed on the material.
  56989. */
  56990. protected _maxSimultaneousLights: number;
  56991. /**
  56992. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56993. */
  56994. protected _invertNormalMapX: boolean;
  56995. /**
  56996. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56997. */
  56998. protected _invertNormalMapY: boolean;
  56999. /**
  57000. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57001. */
  57002. protected _twoSidedLighting: boolean;
  57003. /**
  57004. * Defines the alpha limits in alpha test mode.
  57005. */
  57006. protected _alphaCutOff: number;
  57007. /**
  57008. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57009. */
  57010. protected _forceAlphaTest: boolean;
  57011. /**
  57012. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57013. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57014. */
  57015. protected _useAlphaFresnel: boolean;
  57016. /**
  57017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57018. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57019. */
  57020. protected _useLinearAlphaFresnel: boolean;
  57021. /**
  57022. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57023. * from cos thetav and roughness:
  57024. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57025. */
  57026. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57027. /**
  57028. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57029. */
  57030. protected _forceIrradianceInFragment: boolean;
  57031. private _realTimeFiltering;
  57032. /**
  57033. * Enables realtime filtering on the texture.
  57034. */
  57035. get realTimeFiltering(): boolean;
  57036. set realTimeFiltering(b: boolean);
  57037. private _realTimeFilteringQuality;
  57038. /**
  57039. * Quality switch for realtime filtering
  57040. */
  57041. get realTimeFilteringQuality(): number;
  57042. set realTimeFilteringQuality(n: number);
  57043. /**
  57044. * Can this material render to several textures at once
  57045. */
  57046. get canRenderToMRT(): boolean;
  57047. /**
  57048. * Force normal to face away from face.
  57049. */
  57050. protected _forceNormalForward: boolean;
  57051. /**
  57052. * Enables specular anti aliasing in the PBR shader.
  57053. * It will both interacts on the Geometry for analytical and IBL lighting.
  57054. * It also prefilter the roughness map based on the bump values.
  57055. */
  57056. protected _enableSpecularAntiAliasing: boolean;
  57057. /**
  57058. * Default configuration related to image processing available in the PBR Material.
  57059. */
  57060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57061. /**
  57062. * Keep track of the image processing observer to allow dispose and replace.
  57063. */
  57064. private _imageProcessingObserver;
  57065. /**
  57066. * Attaches a new image processing configuration to the PBR Material.
  57067. * @param configuration
  57068. */
  57069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57070. /**
  57071. * Stores the available render targets.
  57072. */
  57073. private _renderTargets;
  57074. /**
  57075. * Sets the global ambient color for the material used in lighting calculations.
  57076. */
  57077. private _globalAmbientColor;
  57078. /**
  57079. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57080. */
  57081. private _useLogarithmicDepth;
  57082. /**
  57083. * If set to true, no lighting calculations will be applied.
  57084. */
  57085. private _unlit;
  57086. private _debugMode;
  57087. /**
  57088. * @hidden
  57089. * This is reserved for the inspector.
  57090. * Defines the material debug mode.
  57091. * It helps seeing only some components of the material while troubleshooting.
  57092. */
  57093. debugMode: number;
  57094. /**
  57095. * @hidden
  57096. * This is reserved for the inspector.
  57097. * Specify from where on screen the debug mode should start.
  57098. * The value goes from -1 (full screen) to 1 (not visible)
  57099. * It helps with side by side comparison against the final render
  57100. * This defaults to -1
  57101. */
  57102. private debugLimit;
  57103. /**
  57104. * @hidden
  57105. * This is reserved for the inspector.
  57106. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57107. * You can use the factor to better multiply the final value.
  57108. */
  57109. private debugFactor;
  57110. /**
  57111. * Defines the clear coat layer parameters for the material.
  57112. */
  57113. readonly clearCoat: PBRClearCoatConfiguration;
  57114. /**
  57115. * Defines the anisotropic parameters for the material.
  57116. */
  57117. readonly anisotropy: PBRAnisotropicConfiguration;
  57118. /**
  57119. * Defines the BRDF parameters for the material.
  57120. */
  57121. readonly brdf: PBRBRDFConfiguration;
  57122. /**
  57123. * Defines the Sheen parameters for the material.
  57124. */
  57125. readonly sheen: PBRSheenConfiguration;
  57126. /**
  57127. * Defines the SubSurface parameters for the material.
  57128. */
  57129. readonly subSurface: PBRSubSurfaceConfiguration;
  57130. /**
  57131. * Defines the detail map parameters for the material.
  57132. */
  57133. readonly detailMap: DetailMapConfiguration;
  57134. protected _rebuildInParallel: boolean;
  57135. /**
  57136. * Instantiates a new PBRMaterial instance.
  57137. *
  57138. * @param name The material name
  57139. * @param scene The scene the material will be use in.
  57140. */
  57141. constructor(name: string, scene: Scene);
  57142. /**
  57143. * Gets a boolean indicating that current material needs to register RTT
  57144. */
  57145. get hasRenderTargetTextures(): boolean;
  57146. /**
  57147. * Gets the name of the material class.
  57148. */
  57149. getClassName(): string;
  57150. /**
  57151. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57152. */
  57153. get useLogarithmicDepth(): boolean;
  57154. /**
  57155. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57156. */
  57157. set useLogarithmicDepth(value: boolean);
  57158. /**
  57159. * Returns true if alpha blending should be disabled.
  57160. */
  57161. protected get _disableAlphaBlending(): boolean;
  57162. /**
  57163. * Specifies whether or not this material should be rendered in alpha blend mode.
  57164. */
  57165. needAlphaBlending(): boolean;
  57166. /**
  57167. * Specifies whether or not this material should be rendered in alpha test mode.
  57168. */
  57169. needAlphaTesting(): boolean;
  57170. /**
  57171. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57172. */
  57173. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57174. /**
  57175. * Gets the texture used for the alpha test.
  57176. */
  57177. getAlphaTestTexture(): Nullable<BaseTexture>;
  57178. /**
  57179. * Specifies that the submesh is ready to be used.
  57180. * @param mesh - BJS mesh.
  57181. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57182. * @param useInstances - Specifies that instances should be used.
  57183. * @returns - boolean indicating that the submesh is ready or not.
  57184. */
  57185. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57186. /**
  57187. * Specifies if the material uses metallic roughness workflow.
  57188. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57189. */
  57190. isMetallicWorkflow(): boolean;
  57191. private _prepareEffect;
  57192. private _prepareDefines;
  57193. /**
  57194. * Force shader compilation
  57195. */
  57196. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57197. /**
  57198. * Initializes the uniform buffer layout for the shader.
  57199. */
  57200. buildUniformLayout(): void;
  57201. /**
  57202. * Unbinds the material from the mesh
  57203. */
  57204. unbind(): void;
  57205. /**
  57206. * Binds the submesh data.
  57207. * @param world - The world matrix.
  57208. * @param mesh - The BJS mesh.
  57209. * @param subMesh - A submesh of the BJS mesh.
  57210. */
  57211. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57212. /**
  57213. * Returns the animatable textures.
  57214. * @returns - Array of animatable textures.
  57215. */
  57216. getAnimatables(): IAnimatable[];
  57217. /**
  57218. * Returns the texture used for reflections.
  57219. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57220. */
  57221. private _getReflectionTexture;
  57222. /**
  57223. * Returns an array of the actively used textures.
  57224. * @returns - Array of BaseTextures
  57225. */
  57226. getActiveTextures(): BaseTexture[];
  57227. /**
  57228. * Checks to see if a texture is used in the material.
  57229. * @param texture - Base texture to use.
  57230. * @returns - Boolean specifying if a texture is used in the material.
  57231. */
  57232. hasTexture(texture: BaseTexture): boolean;
  57233. /**
  57234. * Sets the required values to the prepass renderer.
  57235. * @param prePassRenderer defines the prepass renderer to setup
  57236. */
  57237. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57238. /**
  57239. * Disposes the resources of the material.
  57240. * @param forceDisposeEffect - Forces the disposal of effects.
  57241. * @param forceDisposeTextures - Forces the disposal of all textures.
  57242. */
  57243. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57244. }
  57245. }
  57246. declare module BABYLON {
  57247. /**
  57248. * The Physically based material of BJS.
  57249. *
  57250. * This offers the main features of a standard PBR material.
  57251. * For more information, please refer to the documentation :
  57252. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57253. */
  57254. export class PBRMaterial extends PBRBaseMaterial {
  57255. /**
  57256. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57257. */
  57258. static readonly PBRMATERIAL_OPAQUE: number;
  57259. /**
  57260. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57261. */
  57262. static readonly PBRMATERIAL_ALPHATEST: number;
  57263. /**
  57264. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57265. */
  57266. static readonly PBRMATERIAL_ALPHABLEND: number;
  57267. /**
  57268. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57269. * They are also discarded below the alpha cutoff threshold to improve performances.
  57270. */
  57271. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57272. /**
  57273. * Defines the default value of how much AO map is occluding the analytical lights
  57274. * (point spot...).
  57275. */
  57276. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57277. /**
  57278. * Intensity of the direct lights e.g. the four lights available in your scene.
  57279. * This impacts both the direct diffuse and specular highlights.
  57280. */
  57281. directIntensity: number;
  57282. /**
  57283. * Intensity of the emissive part of the material.
  57284. * This helps controlling the emissive effect without modifying the emissive color.
  57285. */
  57286. emissiveIntensity: number;
  57287. /**
  57288. * Intensity of the environment e.g. how much the environment will light the object
  57289. * either through harmonics for rough material or through the refelction for shiny ones.
  57290. */
  57291. environmentIntensity: number;
  57292. /**
  57293. * This is a special control allowing the reduction of the specular highlights coming from the
  57294. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57295. */
  57296. specularIntensity: number;
  57297. /**
  57298. * Debug Control allowing disabling the bump map on this material.
  57299. */
  57300. disableBumpMap: boolean;
  57301. /**
  57302. * AKA Diffuse Texture in standard nomenclature.
  57303. */
  57304. albedoTexture: BaseTexture;
  57305. /**
  57306. * AKA Occlusion Texture in other nomenclature.
  57307. */
  57308. ambientTexture: BaseTexture;
  57309. /**
  57310. * AKA Occlusion Texture Intensity in other nomenclature.
  57311. */
  57312. ambientTextureStrength: number;
  57313. /**
  57314. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57315. * 1 means it completely occludes it
  57316. * 0 mean it has no impact
  57317. */
  57318. ambientTextureImpactOnAnalyticalLights: number;
  57319. /**
  57320. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57321. */
  57322. opacityTexture: BaseTexture;
  57323. /**
  57324. * Stores the reflection values in a texture.
  57325. */
  57326. reflectionTexture: Nullable<BaseTexture>;
  57327. /**
  57328. * Stores the emissive values in a texture.
  57329. */
  57330. emissiveTexture: BaseTexture;
  57331. /**
  57332. * AKA Specular texture in other nomenclature.
  57333. */
  57334. reflectivityTexture: BaseTexture;
  57335. /**
  57336. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57337. */
  57338. metallicTexture: BaseTexture;
  57339. /**
  57340. * Specifies the metallic scalar of the metallic/roughness workflow.
  57341. * Can also be used to scale the metalness values of the metallic texture.
  57342. */
  57343. metallic: Nullable<number>;
  57344. /**
  57345. * Specifies the roughness scalar of the metallic/roughness workflow.
  57346. * Can also be used to scale the roughness values of the metallic texture.
  57347. */
  57348. roughness: Nullable<number>;
  57349. /**
  57350. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57351. * By default the indexOfrefraction is used to compute F0;
  57352. *
  57353. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57354. *
  57355. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57356. * F90 = metallicReflectanceColor;
  57357. */
  57358. metallicF0Factor: number;
  57359. /**
  57360. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57361. * By default the F90 is always 1;
  57362. *
  57363. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57364. *
  57365. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57366. * F90 = metallicReflectanceColor;
  57367. */
  57368. metallicReflectanceColor: Color3;
  57369. /**
  57370. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57371. * This is multiply against the scalar values defined in the material.
  57372. */
  57373. metallicReflectanceTexture: Nullable<BaseTexture>;
  57374. /**
  57375. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57376. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57377. */
  57378. microSurfaceTexture: BaseTexture;
  57379. /**
  57380. * Stores surface normal data used to displace a mesh in a texture.
  57381. */
  57382. bumpTexture: BaseTexture;
  57383. /**
  57384. * Stores the pre-calculated light information of a mesh in a texture.
  57385. */
  57386. lightmapTexture: BaseTexture;
  57387. /**
  57388. * Stores the refracted light information in a texture.
  57389. */
  57390. get refractionTexture(): Nullable<BaseTexture>;
  57391. set refractionTexture(value: Nullable<BaseTexture>);
  57392. /**
  57393. * The color of a material in ambient lighting.
  57394. */
  57395. ambientColor: Color3;
  57396. /**
  57397. * AKA Diffuse Color in other nomenclature.
  57398. */
  57399. albedoColor: Color3;
  57400. /**
  57401. * AKA Specular Color in other nomenclature.
  57402. */
  57403. reflectivityColor: Color3;
  57404. /**
  57405. * The color reflected from the material.
  57406. */
  57407. reflectionColor: Color3;
  57408. /**
  57409. * The color emitted from the material.
  57410. */
  57411. emissiveColor: Color3;
  57412. /**
  57413. * AKA Glossiness in other nomenclature.
  57414. */
  57415. microSurface: number;
  57416. /**
  57417. * Index of refraction of the material base layer.
  57418. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57419. *
  57420. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57421. *
  57422. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57423. */
  57424. get indexOfRefraction(): number;
  57425. set indexOfRefraction(value: number);
  57426. /**
  57427. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57428. */
  57429. get invertRefractionY(): boolean;
  57430. set invertRefractionY(value: boolean);
  57431. /**
  57432. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57433. * Materials half opaque for instance using refraction could benefit from this control.
  57434. */
  57435. get linkRefractionWithTransparency(): boolean;
  57436. set linkRefractionWithTransparency(value: boolean);
  57437. /**
  57438. * If true, the light map contains occlusion information instead of lighting info.
  57439. */
  57440. useLightmapAsShadowmap: boolean;
  57441. /**
  57442. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57443. */
  57444. useAlphaFromAlbedoTexture: boolean;
  57445. /**
  57446. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57447. */
  57448. forceAlphaTest: boolean;
  57449. /**
  57450. * Defines the alpha limits in alpha test mode.
  57451. */
  57452. alphaCutOff: number;
  57453. /**
  57454. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57455. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57456. */
  57457. useSpecularOverAlpha: boolean;
  57458. /**
  57459. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57460. */
  57461. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57462. /**
  57463. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57464. */
  57465. useRoughnessFromMetallicTextureAlpha: boolean;
  57466. /**
  57467. * Specifies if the metallic texture contains the roughness information in its green channel.
  57468. */
  57469. useRoughnessFromMetallicTextureGreen: boolean;
  57470. /**
  57471. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57472. */
  57473. useMetallnessFromMetallicTextureBlue: boolean;
  57474. /**
  57475. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57476. */
  57477. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57478. /**
  57479. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57480. */
  57481. useAmbientInGrayScale: boolean;
  57482. /**
  57483. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57484. * The material will try to infer what glossiness each pixel should be.
  57485. */
  57486. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57487. /**
  57488. * BJS is using an harcoded light falloff based on a manually sets up range.
  57489. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57490. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57491. */
  57492. get usePhysicalLightFalloff(): boolean;
  57493. /**
  57494. * BJS is using an harcoded light falloff based on a manually sets up range.
  57495. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57496. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57497. */
  57498. set usePhysicalLightFalloff(value: boolean);
  57499. /**
  57500. * In order to support the falloff compatibility with gltf, a special mode has been added
  57501. * to reproduce the gltf light falloff.
  57502. */
  57503. get useGLTFLightFalloff(): boolean;
  57504. /**
  57505. * In order to support the falloff compatibility with gltf, a special mode has been added
  57506. * to reproduce the gltf light falloff.
  57507. */
  57508. set useGLTFLightFalloff(value: boolean);
  57509. /**
  57510. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57511. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57512. */
  57513. useRadianceOverAlpha: boolean;
  57514. /**
  57515. * Allows using an object space normal map (instead of tangent space).
  57516. */
  57517. useObjectSpaceNormalMap: boolean;
  57518. /**
  57519. * Allows using the bump map in parallax mode.
  57520. */
  57521. useParallax: boolean;
  57522. /**
  57523. * Allows using the bump map in parallax occlusion mode.
  57524. */
  57525. useParallaxOcclusion: boolean;
  57526. /**
  57527. * Controls the scale bias of the parallax mode.
  57528. */
  57529. parallaxScaleBias: number;
  57530. /**
  57531. * If sets to true, disables all the lights affecting the material.
  57532. */
  57533. disableLighting: boolean;
  57534. /**
  57535. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57536. */
  57537. forceIrradianceInFragment: boolean;
  57538. /**
  57539. * Number of Simultaneous lights allowed on the material.
  57540. */
  57541. maxSimultaneousLights: number;
  57542. /**
  57543. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57544. */
  57545. invertNormalMapX: boolean;
  57546. /**
  57547. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57548. */
  57549. invertNormalMapY: boolean;
  57550. /**
  57551. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57552. */
  57553. twoSidedLighting: boolean;
  57554. /**
  57555. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57556. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57557. */
  57558. useAlphaFresnel: boolean;
  57559. /**
  57560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57561. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57562. */
  57563. useLinearAlphaFresnel: boolean;
  57564. /**
  57565. * Let user defines the brdf lookup texture used for IBL.
  57566. * A default 8bit version is embedded but you could point at :
  57567. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57568. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57569. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57570. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57571. */
  57572. environmentBRDFTexture: Nullable<BaseTexture>;
  57573. /**
  57574. * Force normal to face away from face.
  57575. */
  57576. forceNormalForward: boolean;
  57577. /**
  57578. * Enables specular anti aliasing in the PBR shader.
  57579. * It will both interacts on the Geometry for analytical and IBL lighting.
  57580. * It also prefilter the roughness map based on the bump values.
  57581. */
  57582. enableSpecularAntiAliasing: boolean;
  57583. /**
  57584. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57585. * makes the reflect vector face the model (under horizon).
  57586. */
  57587. useHorizonOcclusion: boolean;
  57588. /**
  57589. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57590. * too much the area relying on ambient texture to define their ambient occlusion.
  57591. */
  57592. useRadianceOcclusion: boolean;
  57593. /**
  57594. * If set to true, no lighting calculations will be applied.
  57595. */
  57596. unlit: boolean;
  57597. /**
  57598. * Gets the image processing configuration used either in this material.
  57599. */
  57600. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57601. /**
  57602. * Sets the Default image processing configuration used either in the this material.
  57603. *
  57604. * If sets to null, the scene one is in use.
  57605. */
  57606. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57607. /**
  57608. * Gets wether the color curves effect is enabled.
  57609. */
  57610. get cameraColorCurvesEnabled(): boolean;
  57611. /**
  57612. * Sets wether the color curves effect is enabled.
  57613. */
  57614. set cameraColorCurvesEnabled(value: boolean);
  57615. /**
  57616. * Gets wether the color grading effect is enabled.
  57617. */
  57618. get cameraColorGradingEnabled(): boolean;
  57619. /**
  57620. * Gets wether the color grading effect is enabled.
  57621. */
  57622. set cameraColorGradingEnabled(value: boolean);
  57623. /**
  57624. * Gets wether tonemapping is enabled or not.
  57625. */
  57626. get cameraToneMappingEnabled(): boolean;
  57627. /**
  57628. * Sets wether tonemapping is enabled or not
  57629. */
  57630. set cameraToneMappingEnabled(value: boolean);
  57631. /**
  57632. * The camera exposure used on this material.
  57633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57634. * This corresponds to a photographic exposure.
  57635. */
  57636. get cameraExposure(): number;
  57637. /**
  57638. * The camera exposure used on this material.
  57639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57640. * This corresponds to a photographic exposure.
  57641. */
  57642. set cameraExposure(value: number);
  57643. /**
  57644. * Gets The camera contrast used on this material.
  57645. */
  57646. get cameraContrast(): number;
  57647. /**
  57648. * Sets The camera contrast used on this material.
  57649. */
  57650. set cameraContrast(value: number);
  57651. /**
  57652. * Gets the Color Grading 2D Lookup Texture.
  57653. */
  57654. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57655. /**
  57656. * Sets the Color Grading 2D Lookup Texture.
  57657. */
  57658. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57659. /**
  57660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57662. * 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;
  57663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57664. */
  57665. get cameraColorCurves(): Nullable<ColorCurves>;
  57666. /**
  57667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57669. * 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;
  57670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57671. */
  57672. set cameraColorCurves(value: Nullable<ColorCurves>);
  57673. /**
  57674. * Instantiates a new PBRMaterial instance.
  57675. *
  57676. * @param name The material name
  57677. * @param scene The scene the material will be use in.
  57678. */
  57679. constructor(name: string, scene: Scene);
  57680. /**
  57681. * Returns the name of this material class.
  57682. */
  57683. getClassName(): string;
  57684. /**
  57685. * Makes a duplicate of the current material.
  57686. * @param name - name to use for the new material.
  57687. */
  57688. clone(name: string): PBRMaterial;
  57689. /**
  57690. * Serializes this PBR Material.
  57691. * @returns - An object with the serialized material.
  57692. */
  57693. serialize(): any;
  57694. /**
  57695. * Parses a PBR Material from a serialized object.
  57696. * @param source - Serialized object.
  57697. * @param scene - BJS scene instance.
  57698. * @param rootUrl - url for the scene object
  57699. * @returns - PBRMaterial
  57700. */
  57701. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57702. }
  57703. }
  57704. declare module BABYLON {
  57705. /**
  57706. * Direct draw surface info
  57707. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57708. */
  57709. export interface DDSInfo {
  57710. /**
  57711. * Width of the texture
  57712. */
  57713. width: number;
  57714. /**
  57715. * Width of the texture
  57716. */
  57717. height: number;
  57718. /**
  57719. * Number of Mipmaps for the texture
  57720. * @see https://en.wikipedia.org/wiki/Mipmap
  57721. */
  57722. mipmapCount: number;
  57723. /**
  57724. * If the textures format is a known fourCC format
  57725. * @see https://www.fourcc.org/
  57726. */
  57727. isFourCC: boolean;
  57728. /**
  57729. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57730. */
  57731. isRGB: boolean;
  57732. /**
  57733. * If the texture is a lumincance format
  57734. */
  57735. isLuminance: boolean;
  57736. /**
  57737. * If this is a cube texture
  57738. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57739. */
  57740. isCube: boolean;
  57741. /**
  57742. * If the texture is a compressed format eg. FOURCC_DXT1
  57743. */
  57744. isCompressed: boolean;
  57745. /**
  57746. * The dxgiFormat of the texture
  57747. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57748. */
  57749. dxgiFormat: number;
  57750. /**
  57751. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57752. */
  57753. textureType: number;
  57754. /**
  57755. * Sphericle polynomial created for the dds texture
  57756. */
  57757. sphericalPolynomial?: SphericalPolynomial;
  57758. }
  57759. /**
  57760. * Class used to provide DDS decompression tools
  57761. */
  57762. export class DDSTools {
  57763. /**
  57764. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57765. */
  57766. static StoreLODInAlphaChannel: boolean;
  57767. /**
  57768. * Gets DDS information from an array buffer
  57769. * @param data defines the array buffer view to read data from
  57770. * @returns the DDS information
  57771. */
  57772. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57773. private static _FloatView;
  57774. private static _Int32View;
  57775. private static _ToHalfFloat;
  57776. private static _FromHalfFloat;
  57777. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57778. private static _GetHalfFloatRGBAArrayBuffer;
  57779. private static _GetFloatRGBAArrayBuffer;
  57780. private static _GetFloatAsUIntRGBAArrayBuffer;
  57781. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57782. private static _GetRGBAArrayBuffer;
  57783. private static _ExtractLongWordOrder;
  57784. private static _GetRGBArrayBuffer;
  57785. private static _GetLuminanceArrayBuffer;
  57786. /**
  57787. * Uploads DDS Levels to a Babylon Texture
  57788. * @hidden
  57789. */
  57790. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57791. }
  57792. interface ThinEngine {
  57793. /**
  57794. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57795. * @param rootUrl defines the url where the file to load is located
  57796. * @param scene defines the current scene
  57797. * @param lodScale defines scale to apply to the mip map selection
  57798. * @param lodOffset defines offset to apply to the mip map selection
  57799. * @param onLoad defines an optional callback raised when the texture is loaded
  57800. * @param onError defines an optional callback raised if there is an issue to load the texture
  57801. * @param format defines the format of the data
  57802. * @param forcedExtension defines the extension to use to pick the right loader
  57803. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57804. * @returns the cube texture as an InternalTexture
  57805. */
  57806. 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;
  57807. }
  57808. }
  57809. declare module BABYLON {
  57810. /**
  57811. * Implementation of the DDS Texture Loader.
  57812. * @hidden
  57813. */
  57814. export class _DDSTextureLoader implements IInternalTextureLoader {
  57815. /**
  57816. * Defines wether the loader supports cascade loading the different faces.
  57817. */
  57818. readonly supportCascades: boolean;
  57819. /**
  57820. * This returns if the loader support the current file information.
  57821. * @param extension defines the file extension of the file being loaded
  57822. * @returns true if the loader can load the specified file
  57823. */
  57824. canLoad(extension: string): boolean;
  57825. /**
  57826. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57827. * @param data contains the texture data
  57828. * @param texture defines the BabylonJS internal texture
  57829. * @param createPolynomials will be true if polynomials have been requested
  57830. * @param onLoad defines the callback to trigger once the texture is ready
  57831. * @param onError defines the callback to trigger in case of error
  57832. */
  57833. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57834. /**
  57835. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57836. * @param data contains the texture data
  57837. * @param texture defines the BabylonJS internal texture
  57838. * @param callback defines the method to call once ready to upload
  57839. */
  57840. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57841. }
  57842. }
  57843. declare module BABYLON {
  57844. /**
  57845. * Implementation of the ENV Texture Loader.
  57846. * @hidden
  57847. */
  57848. export class _ENVTextureLoader implements IInternalTextureLoader {
  57849. /**
  57850. * Defines wether the loader supports cascade loading the different faces.
  57851. */
  57852. readonly supportCascades: boolean;
  57853. /**
  57854. * This returns if the loader support the current file information.
  57855. * @param extension defines the file extension of the file being loaded
  57856. * @returns true if the loader can load the specified file
  57857. */
  57858. canLoad(extension: string): boolean;
  57859. /**
  57860. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57861. * @param data contains the texture data
  57862. * @param texture defines the BabylonJS internal texture
  57863. * @param createPolynomials will be true if polynomials have been requested
  57864. * @param onLoad defines the callback to trigger once the texture is ready
  57865. * @param onError defines the callback to trigger in case of error
  57866. */
  57867. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57868. /**
  57869. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57870. * @param data contains the texture data
  57871. * @param texture defines the BabylonJS internal texture
  57872. * @param callback defines the method to call once ready to upload
  57873. */
  57874. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57875. }
  57876. }
  57877. declare module BABYLON {
  57878. /**
  57879. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57880. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57881. */
  57882. export class KhronosTextureContainer {
  57883. /** contents of the KTX container file */
  57884. data: ArrayBufferView;
  57885. private static HEADER_LEN;
  57886. private static COMPRESSED_2D;
  57887. private static COMPRESSED_3D;
  57888. private static TEX_2D;
  57889. private static TEX_3D;
  57890. /**
  57891. * Gets the openGL type
  57892. */
  57893. glType: number;
  57894. /**
  57895. * Gets the openGL type size
  57896. */
  57897. glTypeSize: number;
  57898. /**
  57899. * Gets the openGL format
  57900. */
  57901. glFormat: number;
  57902. /**
  57903. * Gets the openGL internal format
  57904. */
  57905. glInternalFormat: number;
  57906. /**
  57907. * Gets the base internal format
  57908. */
  57909. glBaseInternalFormat: number;
  57910. /**
  57911. * Gets image width in pixel
  57912. */
  57913. pixelWidth: number;
  57914. /**
  57915. * Gets image height in pixel
  57916. */
  57917. pixelHeight: number;
  57918. /**
  57919. * Gets image depth in pixels
  57920. */
  57921. pixelDepth: number;
  57922. /**
  57923. * Gets the number of array elements
  57924. */
  57925. numberOfArrayElements: number;
  57926. /**
  57927. * Gets the number of faces
  57928. */
  57929. numberOfFaces: number;
  57930. /**
  57931. * Gets the number of mipmap levels
  57932. */
  57933. numberOfMipmapLevels: number;
  57934. /**
  57935. * Gets the bytes of key value data
  57936. */
  57937. bytesOfKeyValueData: number;
  57938. /**
  57939. * Gets the load type
  57940. */
  57941. loadType: number;
  57942. /**
  57943. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57944. */
  57945. isInvalid: boolean;
  57946. /**
  57947. * Creates a new KhronosTextureContainer
  57948. * @param data contents of the KTX container file
  57949. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57950. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57951. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57952. */
  57953. constructor(
  57954. /** contents of the KTX container file */
  57955. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57956. /**
  57957. * Uploads KTX content to a Babylon Texture.
  57958. * It is assumed that the texture has already been created & is currently bound
  57959. * @hidden
  57960. */
  57961. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57962. private _upload2DCompressedLevels;
  57963. /**
  57964. * Checks if the given data starts with a KTX file identifier.
  57965. * @param data the data to check
  57966. * @returns true if the data is a KTX file or false otherwise
  57967. */
  57968. static IsValid(data: ArrayBufferView): boolean;
  57969. }
  57970. }
  57971. declare module BABYLON {
  57972. /**
  57973. * Helper class to push actions to a pool of workers.
  57974. */
  57975. export class WorkerPool implements IDisposable {
  57976. private _workerInfos;
  57977. private _pendingActions;
  57978. /**
  57979. * Constructor
  57980. * @param workers Array of workers to use for actions
  57981. */
  57982. constructor(workers: Array<Worker>);
  57983. /**
  57984. * Terminates all workers and clears any pending actions.
  57985. */
  57986. dispose(): void;
  57987. /**
  57988. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57989. * pended until a worker has completed its action.
  57990. * @param action The action to perform. Call onComplete when the action is complete.
  57991. */
  57992. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57993. private _execute;
  57994. }
  57995. }
  57996. declare module BABYLON {
  57997. /**
  57998. * Class for loading KTX2 files
  57999. */
  58000. export class KhronosTextureContainer2 {
  58001. private static _WorkerPoolPromise?;
  58002. private static _Initialized;
  58003. private static _Ktx2Decoder;
  58004. /**
  58005. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58006. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58007. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58008. * Urls you can change:
  58009. * URLConfig.jsDecoderModule
  58010. * URLConfig.wasmUASTCToASTC
  58011. * URLConfig.wasmUASTCToBC7
  58012. * URLConfig.jsMSCTranscoder
  58013. * URLConfig.wasmMSCTranscoder
  58014. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58015. */
  58016. static URLConfig: {
  58017. jsDecoderModule: string;
  58018. wasmUASTCToASTC: null;
  58019. wasmUASTCToBC7: null;
  58020. jsMSCTranscoder: null;
  58021. wasmMSCTranscoder: null;
  58022. };
  58023. /**
  58024. * Default number of workers used to handle data decoding
  58025. */
  58026. static DefaultNumWorkers: number;
  58027. private static GetDefaultNumWorkers;
  58028. private _engine;
  58029. private static _CreateWorkerPool;
  58030. /**
  58031. * Constructor
  58032. * @param engine The engine to use
  58033. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58034. */
  58035. constructor(engine: ThinEngine, numWorkers?: number);
  58036. /** @hidden */
  58037. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58038. /**
  58039. * Stop all async operations and release resources.
  58040. */
  58041. dispose(): void;
  58042. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58043. /**
  58044. * Checks if the given data starts with a KTX2 file identifier.
  58045. * @param data the data to check
  58046. * @returns true if the data is a KTX2 file or false otherwise
  58047. */
  58048. static IsValid(data: ArrayBufferView): boolean;
  58049. }
  58050. }
  58051. declare module BABYLON {
  58052. /**
  58053. * Implementation of the KTX Texture Loader.
  58054. * @hidden
  58055. */
  58056. export class _KTXTextureLoader implements IInternalTextureLoader {
  58057. /**
  58058. * Defines wether the loader supports cascade loading the different faces.
  58059. */
  58060. readonly supportCascades: boolean;
  58061. /**
  58062. * This returns if the loader support the current file information.
  58063. * @param extension defines the file extension of the file being loaded
  58064. * @param mimeType defines the optional mime type of the file being loaded
  58065. * @returns true if the loader can load the specified file
  58066. */
  58067. canLoad(extension: string, mimeType?: string): boolean;
  58068. /**
  58069. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58070. * @param data contains the texture data
  58071. * @param texture defines the BabylonJS internal texture
  58072. * @param createPolynomials will be true if polynomials have been requested
  58073. * @param onLoad defines the callback to trigger once the texture is ready
  58074. * @param onError defines the callback to trigger in case of error
  58075. */
  58076. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58077. /**
  58078. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58079. * @param data contains the texture data
  58080. * @param texture defines the BabylonJS internal texture
  58081. * @param callback defines the method to call once ready to upload
  58082. */
  58083. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58084. }
  58085. }
  58086. declare module BABYLON {
  58087. /** @hidden */
  58088. export var _forceSceneHelpersToBundle: boolean;
  58089. interface Scene {
  58090. /**
  58091. * Creates a default light for the scene.
  58092. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58093. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58094. */
  58095. createDefaultLight(replace?: boolean): void;
  58096. /**
  58097. * Creates a default camera for the scene.
  58098. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58099. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58100. * @param replace has default false, when true replaces the active camera in the scene
  58101. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58102. */
  58103. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58104. /**
  58105. * Creates a default camera and a default light.
  58106. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58107. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58108. * @param replace has the default false, when true replaces the active camera/light in the scene
  58109. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58110. */
  58111. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58112. /**
  58113. * Creates a new sky box
  58114. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58115. * @param environmentTexture defines the texture to use as environment texture
  58116. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58117. * @param scale defines the overall scale of the skybox
  58118. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58119. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58120. * @returns a new mesh holding the sky box
  58121. */
  58122. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58123. /**
  58124. * Creates a new environment
  58125. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58126. * @param options defines the options you can use to configure the environment
  58127. * @returns the new EnvironmentHelper
  58128. */
  58129. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58130. /**
  58131. * Creates a new VREXperienceHelper
  58132. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58133. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58134. * @returns a new VREXperienceHelper
  58135. */
  58136. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58137. /**
  58138. * Creates a new WebXRDefaultExperience
  58139. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58140. * @param options experience options
  58141. * @returns a promise for a new WebXRDefaultExperience
  58142. */
  58143. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58144. }
  58145. }
  58146. declare module BABYLON {
  58147. /**
  58148. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58149. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58150. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58151. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58152. */
  58153. export class VideoDome extends TextureDome<VideoTexture> {
  58154. /**
  58155. * Define the video source as a Monoscopic panoramic 360 video.
  58156. */
  58157. static readonly MODE_MONOSCOPIC: number;
  58158. /**
  58159. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58160. */
  58161. static readonly MODE_TOPBOTTOM: number;
  58162. /**
  58163. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58164. */
  58165. static readonly MODE_SIDEBYSIDE: number;
  58166. /**
  58167. * Get the video texture associated with this video dome
  58168. */
  58169. get videoTexture(): VideoTexture;
  58170. /**
  58171. * Get the video mode of this dome
  58172. */
  58173. get videoMode(): number;
  58174. /**
  58175. * Set the video mode of this dome.
  58176. * @see textureMode
  58177. */
  58178. set videoMode(value: number);
  58179. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58180. }
  58181. }
  58182. declare module BABYLON {
  58183. /**
  58184. * This class can be used to get instrumentation data from a Babylon engine
  58185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58186. */
  58187. export class EngineInstrumentation implements IDisposable {
  58188. /**
  58189. * Define the instrumented engine.
  58190. */
  58191. engine: Engine;
  58192. private _captureGPUFrameTime;
  58193. private _gpuFrameTimeToken;
  58194. private _gpuFrameTime;
  58195. private _captureShaderCompilationTime;
  58196. private _shaderCompilationTime;
  58197. private _onBeginFrameObserver;
  58198. private _onEndFrameObserver;
  58199. private _onBeforeShaderCompilationObserver;
  58200. private _onAfterShaderCompilationObserver;
  58201. /**
  58202. * Gets the perf counter used for GPU frame time
  58203. */
  58204. get gpuFrameTimeCounter(): PerfCounter;
  58205. /**
  58206. * Gets the GPU frame time capture status
  58207. */
  58208. get captureGPUFrameTime(): boolean;
  58209. /**
  58210. * Enable or disable the GPU frame time capture
  58211. */
  58212. set captureGPUFrameTime(value: boolean);
  58213. /**
  58214. * Gets the perf counter used for shader compilation time
  58215. */
  58216. get shaderCompilationTimeCounter(): PerfCounter;
  58217. /**
  58218. * Gets the shader compilation time capture status
  58219. */
  58220. get captureShaderCompilationTime(): boolean;
  58221. /**
  58222. * Enable or disable the shader compilation time capture
  58223. */
  58224. set captureShaderCompilationTime(value: boolean);
  58225. /**
  58226. * Instantiates a new engine instrumentation.
  58227. * This class can be used to get instrumentation data from a Babylon engine
  58228. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58229. * @param engine Defines the engine to instrument
  58230. */
  58231. constructor(
  58232. /**
  58233. * Define the instrumented engine.
  58234. */
  58235. engine: Engine);
  58236. /**
  58237. * Dispose and release associated resources.
  58238. */
  58239. dispose(): void;
  58240. }
  58241. }
  58242. declare module BABYLON {
  58243. /**
  58244. * This class can be used to get instrumentation data from a Babylon engine
  58245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58246. */
  58247. export class SceneInstrumentation implements IDisposable {
  58248. /**
  58249. * Defines the scene to instrument
  58250. */
  58251. scene: Scene;
  58252. private _captureActiveMeshesEvaluationTime;
  58253. private _activeMeshesEvaluationTime;
  58254. private _captureRenderTargetsRenderTime;
  58255. private _renderTargetsRenderTime;
  58256. private _captureFrameTime;
  58257. private _frameTime;
  58258. private _captureRenderTime;
  58259. private _renderTime;
  58260. private _captureInterFrameTime;
  58261. private _interFrameTime;
  58262. private _captureParticlesRenderTime;
  58263. private _particlesRenderTime;
  58264. private _captureSpritesRenderTime;
  58265. private _spritesRenderTime;
  58266. private _capturePhysicsTime;
  58267. private _physicsTime;
  58268. private _captureAnimationsTime;
  58269. private _animationsTime;
  58270. private _captureCameraRenderTime;
  58271. private _cameraRenderTime;
  58272. private _onBeforeActiveMeshesEvaluationObserver;
  58273. private _onAfterActiveMeshesEvaluationObserver;
  58274. private _onBeforeRenderTargetsRenderObserver;
  58275. private _onAfterRenderTargetsRenderObserver;
  58276. private _onAfterRenderObserver;
  58277. private _onBeforeDrawPhaseObserver;
  58278. private _onAfterDrawPhaseObserver;
  58279. private _onBeforeAnimationsObserver;
  58280. private _onBeforeParticlesRenderingObserver;
  58281. private _onAfterParticlesRenderingObserver;
  58282. private _onBeforeSpritesRenderingObserver;
  58283. private _onAfterSpritesRenderingObserver;
  58284. private _onBeforePhysicsObserver;
  58285. private _onAfterPhysicsObserver;
  58286. private _onAfterAnimationsObserver;
  58287. private _onBeforeCameraRenderObserver;
  58288. private _onAfterCameraRenderObserver;
  58289. /**
  58290. * Gets the perf counter used for active meshes evaluation time
  58291. */
  58292. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58293. /**
  58294. * Gets the active meshes evaluation time capture status
  58295. */
  58296. get captureActiveMeshesEvaluationTime(): boolean;
  58297. /**
  58298. * Enable or disable the active meshes evaluation time capture
  58299. */
  58300. set captureActiveMeshesEvaluationTime(value: boolean);
  58301. /**
  58302. * Gets the perf counter used for render targets render time
  58303. */
  58304. get renderTargetsRenderTimeCounter(): PerfCounter;
  58305. /**
  58306. * Gets the render targets render time capture status
  58307. */
  58308. get captureRenderTargetsRenderTime(): boolean;
  58309. /**
  58310. * Enable or disable the render targets render time capture
  58311. */
  58312. set captureRenderTargetsRenderTime(value: boolean);
  58313. /**
  58314. * Gets the perf counter used for particles render time
  58315. */
  58316. get particlesRenderTimeCounter(): PerfCounter;
  58317. /**
  58318. * Gets the particles render time capture status
  58319. */
  58320. get captureParticlesRenderTime(): boolean;
  58321. /**
  58322. * Enable or disable the particles render time capture
  58323. */
  58324. set captureParticlesRenderTime(value: boolean);
  58325. /**
  58326. * Gets the perf counter used for sprites render time
  58327. */
  58328. get spritesRenderTimeCounter(): PerfCounter;
  58329. /**
  58330. * Gets the sprites render time capture status
  58331. */
  58332. get captureSpritesRenderTime(): boolean;
  58333. /**
  58334. * Enable or disable the sprites render time capture
  58335. */
  58336. set captureSpritesRenderTime(value: boolean);
  58337. /**
  58338. * Gets the perf counter used for physics time
  58339. */
  58340. get physicsTimeCounter(): PerfCounter;
  58341. /**
  58342. * Gets the physics time capture status
  58343. */
  58344. get capturePhysicsTime(): boolean;
  58345. /**
  58346. * Enable or disable the physics time capture
  58347. */
  58348. set capturePhysicsTime(value: boolean);
  58349. /**
  58350. * Gets the perf counter used for animations time
  58351. */
  58352. get animationsTimeCounter(): PerfCounter;
  58353. /**
  58354. * Gets the animations time capture status
  58355. */
  58356. get captureAnimationsTime(): boolean;
  58357. /**
  58358. * Enable or disable the animations time capture
  58359. */
  58360. set captureAnimationsTime(value: boolean);
  58361. /**
  58362. * Gets the perf counter used for frame time capture
  58363. */
  58364. get frameTimeCounter(): PerfCounter;
  58365. /**
  58366. * Gets the frame time capture status
  58367. */
  58368. get captureFrameTime(): boolean;
  58369. /**
  58370. * Enable or disable the frame time capture
  58371. */
  58372. set captureFrameTime(value: boolean);
  58373. /**
  58374. * Gets the perf counter used for inter-frames time capture
  58375. */
  58376. get interFrameTimeCounter(): PerfCounter;
  58377. /**
  58378. * Gets the inter-frames time capture status
  58379. */
  58380. get captureInterFrameTime(): boolean;
  58381. /**
  58382. * Enable or disable the inter-frames time capture
  58383. */
  58384. set captureInterFrameTime(value: boolean);
  58385. /**
  58386. * Gets the perf counter used for render time capture
  58387. */
  58388. get renderTimeCounter(): PerfCounter;
  58389. /**
  58390. * Gets the render time capture status
  58391. */
  58392. get captureRenderTime(): boolean;
  58393. /**
  58394. * Enable or disable the render time capture
  58395. */
  58396. set captureRenderTime(value: boolean);
  58397. /**
  58398. * Gets the perf counter used for camera render time capture
  58399. */
  58400. get cameraRenderTimeCounter(): PerfCounter;
  58401. /**
  58402. * Gets the camera render time capture status
  58403. */
  58404. get captureCameraRenderTime(): boolean;
  58405. /**
  58406. * Enable or disable the camera render time capture
  58407. */
  58408. set captureCameraRenderTime(value: boolean);
  58409. /**
  58410. * Gets the perf counter used for draw calls
  58411. */
  58412. get drawCallsCounter(): PerfCounter;
  58413. /**
  58414. * Instantiates a new scene instrumentation.
  58415. * This class can be used to get instrumentation data from a Babylon engine
  58416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58417. * @param scene Defines the scene to instrument
  58418. */
  58419. constructor(
  58420. /**
  58421. * Defines the scene to instrument
  58422. */
  58423. scene: Scene);
  58424. /**
  58425. * Dispose and release associated resources.
  58426. */
  58427. dispose(): void;
  58428. }
  58429. }
  58430. declare module BABYLON {
  58431. /** @hidden */
  58432. export var glowMapGenerationPixelShader: {
  58433. name: string;
  58434. shader: string;
  58435. };
  58436. }
  58437. declare module BABYLON {
  58438. /** @hidden */
  58439. export var glowMapGenerationVertexShader: {
  58440. name: string;
  58441. shader: string;
  58442. };
  58443. }
  58444. declare module BABYLON {
  58445. /**
  58446. * Effect layer options. This helps customizing the behaviour
  58447. * of the effect layer.
  58448. */
  58449. export interface IEffectLayerOptions {
  58450. /**
  58451. * Multiplication factor apply to the canvas size to compute the render target size
  58452. * used to generated the objects (the smaller the faster).
  58453. */
  58454. mainTextureRatio: number;
  58455. /**
  58456. * Enforces a fixed size texture to ensure effect stability across devices.
  58457. */
  58458. mainTextureFixedSize?: number;
  58459. /**
  58460. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58461. */
  58462. alphaBlendingMode: number;
  58463. /**
  58464. * The camera attached to the layer.
  58465. */
  58466. camera: Nullable<Camera>;
  58467. /**
  58468. * The rendering group to draw the layer in.
  58469. */
  58470. renderingGroupId: number;
  58471. }
  58472. /**
  58473. * The effect layer Helps adding post process effect blended with the main pass.
  58474. *
  58475. * This can be for instance use to generate glow or higlight effects on the scene.
  58476. *
  58477. * The effect layer class can not be used directly and is intented to inherited from to be
  58478. * customized per effects.
  58479. */
  58480. export abstract class EffectLayer {
  58481. private _vertexBuffers;
  58482. private _indexBuffer;
  58483. private _cachedDefines;
  58484. private _effectLayerMapGenerationEffect;
  58485. private _effectLayerOptions;
  58486. private _mergeEffect;
  58487. protected _scene: Scene;
  58488. protected _engine: Engine;
  58489. protected _maxSize: number;
  58490. protected _mainTextureDesiredSize: ISize;
  58491. protected _mainTexture: RenderTargetTexture;
  58492. protected _shouldRender: boolean;
  58493. protected _postProcesses: PostProcess[];
  58494. protected _textures: BaseTexture[];
  58495. protected _emissiveTextureAndColor: {
  58496. texture: Nullable<BaseTexture>;
  58497. color: Color4;
  58498. };
  58499. /**
  58500. * The name of the layer
  58501. */
  58502. name: string;
  58503. /**
  58504. * The clear color of the texture used to generate the glow map.
  58505. */
  58506. neutralColor: Color4;
  58507. /**
  58508. * Specifies whether the highlight layer is enabled or not.
  58509. */
  58510. isEnabled: boolean;
  58511. /**
  58512. * Gets the camera attached to the layer.
  58513. */
  58514. get camera(): Nullable<Camera>;
  58515. /**
  58516. * Gets the rendering group id the layer should render in.
  58517. */
  58518. get renderingGroupId(): number;
  58519. set renderingGroupId(renderingGroupId: number);
  58520. /**
  58521. * An event triggered when the effect layer has been disposed.
  58522. */
  58523. onDisposeObservable: Observable<EffectLayer>;
  58524. /**
  58525. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58526. */
  58527. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58528. /**
  58529. * An event triggered when the generated texture is being merged in the scene.
  58530. */
  58531. onBeforeComposeObservable: Observable<EffectLayer>;
  58532. /**
  58533. * An event triggered when the mesh is rendered into the effect render target.
  58534. */
  58535. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58536. /**
  58537. * An event triggered after the mesh has been rendered into the effect render target.
  58538. */
  58539. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58540. /**
  58541. * An event triggered when the generated texture has been merged in the scene.
  58542. */
  58543. onAfterComposeObservable: Observable<EffectLayer>;
  58544. /**
  58545. * An event triggered when the efffect layer changes its size.
  58546. */
  58547. onSizeChangedObservable: Observable<EffectLayer>;
  58548. /** @hidden */
  58549. static _SceneComponentInitialization: (scene: Scene) => void;
  58550. /**
  58551. * Instantiates a new effect Layer and references it in the scene.
  58552. * @param name The name of the layer
  58553. * @param scene The scene to use the layer in
  58554. */
  58555. constructor(
  58556. /** The Friendly of the effect in the scene */
  58557. name: string, scene: Scene);
  58558. /**
  58559. * Get the effect name of the layer.
  58560. * @return The effect name
  58561. */
  58562. abstract getEffectName(): string;
  58563. /**
  58564. * Checks for the readiness of the element composing the layer.
  58565. * @param subMesh the mesh to check for
  58566. * @param useInstances specify whether or not to use instances to render the mesh
  58567. * @return true if ready otherwise, false
  58568. */
  58569. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58570. /**
  58571. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58572. * @returns true if the effect requires stencil during the main canvas render pass.
  58573. */
  58574. abstract needStencil(): boolean;
  58575. /**
  58576. * Create the merge effect. This is the shader use to blit the information back
  58577. * to the main canvas at the end of the scene rendering.
  58578. * @returns The effect containing the shader used to merge the effect on the main canvas
  58579. */
  58580. protected abstract _createMergeEffect(): Effect;
  58581. /**
  58582. * Creates the render target textures and post processes used in the effect layer.
  58583. */
  58584. protected abstract _createTextureAndPostProcesses(): void;
  58585. /**
  58586. * Implementation specific of rendering the generating effect on the main canvas.
  58587. * @param effect The effect used to render through
  58588. */
  58589. protected abstract _internalRender(effect: Effect): void;
  58590. /**
  58591. * Sets the required values for both the emissive texture and and the main color.
  58592. */
  58593. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58594. /**
  58595. * Free any resources and references associated to a mesh.
  58596. * Internal use
  58597. * @param mesh The mesh to free.
  58598. */
  58599. abstract _disposeMesh(mesh: Mesh): void;
  58600. /**
  58601. * Serializes this layer (Glow or Highlight for example)
  58602. * @returns a serialized layer object
  58603. */
  58604. abstract serialize?(): any;
  58605. /**
  58606. * Initializes the effect layer with the required options.
  58607. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58608. */
  58609. protected _init(options: Partial<IEffectLayerOptions>): void;
  58610. /**
  58611. * Generates the index buffer of the full screen quad blending to the main canvas.
  58612. */
  58613. private _generateIndexBuffer;
  58614. /**
  58615. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58616. */
  58617. private _generateVertexBuffer;
  58618. /**
  58619. * Sets the main texture desired size which is the closest power of two
  58620. * of the engine canvas size.
  58621. */
  58622. private _setMainTextureSize;
  58623. /**
  58624. * Creates the main texture for the effect layer.
  58625. */
  58626. protected _createMainTexture(): void;
  58627. /**
  58628. * Adds specific effects defines.
  58629. * @param defines The defines to add specifics to.
  58630. */
  58631. protected _addCustomEffectDefines(defines: string[]): void;
  58632. /**
  58633. * Checks for the readiness of the element composing the layer.
  58634. * @param subMesh the mesh to check for
  58635. * @param useInstances specify whether or not to use instances to render the mesh
  58636. * @param emissiveTexture the associated emissive texture used to generate the glow
  58637. * @return true if ready otherwise, false
  58638. */
  58639. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58640. /**
  58641. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58642. */
  58643. render(): void;
  58644. /**
  58645. * Determine if a given mesh will be used in the current effect.
  58646. * @param mesh mesh to test
  58647. * @returns true if the mesh will be used
  58648. */
  58649. hasMesh(mesh: AbstractMesh): boolean;
  58650. /**
  58651. * Returns true if the layer contains information to display, otherwise false.
  58652. * @returns true if the glow layer should be rendered
  58653. */
  58654. shouldRender(): boolean;
  58655. /**
  58656. * Returns true if the mesh should render, otherwise false.
  58657. * @param mesh The mesh to render
  58658. * @returns true if it should render otherwise false
  58659. */
  58660. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58661. /**
  58662. * Returns true if the mesh can be rendered, otherwise false.
  58663. * @param mesh The mesh to render
  58664. * @param material The material used on the mesh
  58665. * @returns true if it can be rendered otherwise false
  58666. */
  58667. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58668. /**
  58669. * Returns true if the mesh should render, otherwise false.
  58670. * @param mesh The mesh to render
  58671. * @returns true if it should render otherwise false
  58672. */
  58673. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58674. /**
  58675. * Renders the submesh passed in parameter to the generation map.
  58676. */
  58677. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58678. /**
  58679. * Defines whether the current material of the mesh should be use to render the effect.
  58680. * @param mesh defines the current mesh to render
  58681. */
  58682. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58683. /**
  58684. * Rebuild the required buffers.
  58685. * @hidden Internal use only.
  58686. */
  58687. _rebuild(): void;
  58688. /**
  58689. * Dispose only the render target textures and post process.
  58690. */
  58691. private _disposeTextureAndPostProcesses;
  58692. /**
  58693. * Dispose the highlight layer and free resources.
  58694. */
  58695. dispose(): void;
  58696. /**
  58697. * Gets the class name of the effect layer
  58698. * @returns the string with the class name of the effect layer
  58699. */
  58700. getClassName(): string;
  58701. /**
  58702. * Creates an effect layer from parsed effect layer data
  58703. * @param parsedEffectLayer defines effect layer data
  58704. * @param scene defines the current scene
  58705. * @param rootUrl defines the root URL containing the effect layer information
  58706. * @returns a parsed effect Layer
  58707. */
  58708. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58709. }
  58710. }
  58711. declare module BABYLON {
  58712. interface AbstractScene {
  58713. /**
  58714. * The list of effect layers (highlights/glow) added to the scene
  58715. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58716. * @see https://doc.babylonjs.com/how_to/glow_layer
  58717. */
  58718. effectLayers: Array<EffectLayer>;
  58719. /**
  58720. * Removes the given effect layer from this scene.
  58721. * @param toRemove defines the effect layer to remove
  58722. * @returns the index of the removed effect layer
  58723. */
  58724. removeEffectLayer(toRemove: EffectLayer): number;
  58725. /**
  58726. * Adds the given effect layer to this scene
  58727. * @param newEffectLayer defines the effect layer to add
  58728. */
  58729. addEffectLayer(newEffectLayer: EffectLayer): void;
  58730. }
  58731. /**
  58732. * Defines the layer scene component responsible to manage any effect layers
  58733. * in a given scene.
  58734. */
  58735. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58736. /**
  58737. * The component name helpfull to identify the component in the list of scene components.
  58738. */
  58739. readonly name: string;
  58740. /**
  58741. * The scene the component belongs to.
  58742. */
  58743. scene: Scene;
  58744. private _engine;
  58745. private _renderEffects;
  58746. private _needStencil;
  58747. private _previousStencilState;
  58748. /**
  58749. * Creates a new instance of the component for the given scene
  58750. * @param scene Defines the scene to register the component in
  58751. */
  58752. constructor(scene: Scene);
  58753. /**
  58754. * Registers the component in a given scene
  58755. */
  58756. register(): void;
  58757. /**
  58758. * Rebuilds the elements related to this component in case of
  58759. * context lost for instance.
  58760. */
  58761. rebuild(): void;
  58762. /**
  58763. * Serializes the component data to the specified json object
  58764. * @param serializationObject The object to serialize to
  58765. */
  58766. serialize(serializationObject: any): void;
  58767. /**
  58768. * Adds all the elements from the container to the scene
  58769. * @param container the container holding the elements
  58770. */
  58771. addFromContainer(container: AbstractScene): void;
  58772. /**
  58773. * Removes all the elements in the container from the scene
  58774. * @param container contains the elements to remove
  58775. * @param dispose if the removed element should be disposed (default: false)
  58776. */
  58777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58778. /**
  58779. * Disposes the component and the associated ressources.
  58780. */
  58781. dispose(): void;
  58782. private _isReadyForMesh;
  58783. private _renderMainTexture;
  58784. private _setStencil;
  58785. private _setStencilBack;
  58786. private _draw;
  58787. private _drawCamera;
  58788. private _drawRenderingGroup;
  58789. }
  58790. }
  58791. declare module BABYLON {
  58792. /** @hidden */
  58793. export var glowMapMergePixelShader: {
  58794. name: string;
  58795. shader: string;
  58796. };
  58797. }
  58798. declare module BABYLON {
  58799. /** @hidden */
  58800. export var glowMapMergeVertexShader: {
  58801. name: string;
  58802. shader: string;
  58803. };
  58804. }
  58805. declare module BABYLON {
  58806. interface AbstractScene {
  58807. /**
  58808. * Return a the first highlight layer of the scene with a given name.
  58809. * @param name The name of the highlight layer to look for.
  58810. * @return The highlight layer if found otherwise null.
  58811. */
  58812. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58813. }
  58814. /**
  58815. * Glow layer options. This helps customizing the behaviour
  58816. * of the glow layer.
  58817. */
  58818. export interface IGlowLayerOptions {
  58819. /**
  58820. * Multiplication factor apply to the canvas size to compute the render target size
  58821. * used to generated the glowing objects (the smaller the faster).
  58822. */
  58823. mainTextureRatio: number;
  58824. /**
  58825. * Enforces a fixed size texture to ensure resize independant blur.
  58826. */
  58827. mainTextureFixedSize?: number;
  58828. /**
  58829. * How big is the kernel of the blur texture.
  58830. */
  58831. blurKernelSize: number;
  58832. /**
  58833. * The camera attached to the layer.
  58834. */
  58835. camera: Nullable<Camera>;
  58836. /**
  58837. * Enable MSAA by chosing the number of samples.
  58838. */
  58839. mainTextureSamples?: number;
  58840. /**
  58841. * The rendering group to draw the layer in.
  58842. */
  58843. renderingGroupId: number;
  58844. }
  58845. /**
  58846. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58847. *
  58848. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58849. *
  58850. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58851. */
  58852. export class GlowLayer extends EffectLayer {
  58853. /**
  58854. * Effect Name of the layer.
  58855. */
  58856. static readonly EffectName: string;
  58857. /**
  58858. * The default blur kernel size used for the glow.
  58859. */
  58860. static DefaultBlurKernelSize: number;
  58861. /**
  58862. * The default texture size ratio used for the glow.
  58863. */
  58864. static DefaultTextureRatio: number;
  58865. /**
  58866. * Sets the kernel size of the blur.
  58867. */
  58868. set blurKernelSize(value: number);
  58869. /**
  58870. * Gets the kernel size of the blur.
  58871. */
  58872. get blurKernelSize(): number;
  58873. /**
  58874. * Sets the glow intensity.
  58875. */
  58876. set intensity(value: number);
  58877. /**
  58878. * Gets the glow intensity.
  58879. */
  58880. get intensity(): number;
  58881. private _options;
  58882. private _intensity;
  58883. private _horizontalBlurPostprocess1;
  58884. private _verticalBlurPostprocess1;
  58885. private _horizontalBlurPostprocess2;
  58886. private _verticalBlurPostprocess2;
  58887. private _blurTexture1;
  58888. private _blurTexture2;
  58889. private _postProcesses1;
  58890. private _postProcesses2;
  58891. private _includedOnlyMeshes;
  58892. private _excludedMeshes;
  58893. private _meshesUsingTheirOwnMaterials;
  58894. /**
  58895. * Callback used to let the user override the color selection on a per mesh basis
  58896. */
  58897. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58898. /**
  58899. * Callback used to let the user override the texture selection on a per mesh basis
  58900. */
  58901. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58902. /**
  58903. * Instantiates a new glow Layer and references it to the scene.
  58904. * @param name The name of the layer
  58905. * @param scene The scene to use the layer in
  58906. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58907. */
  58908. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58909. /**
  58910. * Get the effect name of the layer.
  58911. * @return The effect name
  58912. */
  58913. getEffectName(): string;
  58914. /**
  58915. * Create the merge effect. This is the shader use to blit the information back
  58916. * to the main canvas at the end of the scene rendering.
  58917. */
  58918. protected _createMergeEffect(): Effect;
  58919. /**
  58920. * Creates the render target textures and post processes used in the glow layer.
  58921. */
  58922. protected _createTextureAndPostProcesses(): void;
  58923. /**
  58924. * Checks for the readiness of the element composing the layer.
  58925. * @param subMesh the mesh to check for
  58926. * @param useInstances specify wether or not to use instances to render the mesh
  58927. * @param emissiveTexture the associated emissive texture used to generate the glow
  58928. * @return true if ready otherwise, false
  58929. */
  58930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58931. /**
  58932. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58933. */
  58934. needStencil(): boolean;
  58935. /**
  58936. * Returns true if the mesh can be rendered, otherwise false.
  58937. * @param mesh The mesh to render
  58938. * @param material The material used on the mesh
  58939. * @returns true if it can be rendered otherwise false
  58940. */
  58941. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58942. /**
  58943. * Implementation specific of rendering the generating effect on the main canvas.
  58944. * @param effect The effect used to render through
  58945. */
  58946. protected _internalRender(effect: Effect): void;
  58947. /**
  58948. * Sets the required values for both the emissive texture and and the main color.
  58949. */
  58950. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58951. /**
  58952. * Returns true if the mesh should render, otherwise false.
  58953. * @param mesh The mesh to render
  58954. * @returns true if it should render otherwise false
  58955. */
  58956. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58957. /**
  58958. * Adds specific effects defines.
  58959. * @param defines The defines to add specifics to.
  58960. */
  58961. protected _addCustomEffectDefines(defines: string[]): void;
  58962. /**
  58963. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58964. * @param mesh The mesh to exclude from the glow layer
  58965. */
  58966. addExcludedMesh(mesh: Mesh): void;
  58967. /**
  58968. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58969. * @param mesh The mesh to remove
  58970. */
  58971. removeExcludedMesh(mesh: Mesh): void;
  58972. /**
  58973. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58974. * @param mesh The mesh to include in the glow layer
  58975. */
  58976. addIncludedOnlyMesh(mesh: Mesh): void;
  58977. /**
  58978. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58979. * @param mesh The mesh to remove
  58980. */
  58981. removeIncludedOnlyMesh(mesh: Mesh): void;
  58982. /**
  58983. * Determine if a given mesh will be used in the glow layer
  58984. * @param mesh The mesh to test
  58985. * @returns true if the mesh will be highlighted by the current glow layer
  58986. */
  58987. hasMesh(mesh: AbstractMesh): boolean;
  58988. /**
  58989. * Defines whether the current material of the mesh should be use to render the effect.
  58990. * @param mesh defines the current mesh to render
  58991. */
  58992. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58993. /**
  58994. * Add a mesh to be rendered through its own material and not with emissive only.
  58995. * @param mesh The mesh for which we need to use its material
  58996. */
  58997. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58998. /**
  58999. * Remove a mesh from being rendered through its own material and not with emissive only.
  59000. * @param mesh The mesh for which we need to not use its material
  59001. */
  59002. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59003. /**
  59004. * Free any resources and references associated to a mesh.
  59005. * Internal use
  59006. * @param mesh The mesh to free.
  59007. * @hidden
  59008. */
  59009. _disposeMesh(mesh: Mesh): void;
  59010. /**
  59011. * Gets the class name of the effect layer
  59012. * @returns the string with the class name of the effect layer
  59013. */
  59014. getClassName(): string;
  59015. /**
  59016. * Serializes this glow layer
  59017. * @returns a serialized glow layer object
  59018. */
  59019. serialize(): any;
  59020. /**
  59021. * Creates a Glow Layer from parsed glow layer data
  59022. * @param parsedGlowLayer defines glow layer data
  59023. * @param scene defines the current scene
  59024. * @param rootUrl defines the root URL containing the glow layer information
  59025. * @returns a parsed Glow Layer
  59026. */
  59027. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59028. }
  59029. }
  59030. declare module BABYLON {
  59031. /** @hidden */
  59032. export var glowBlurPostProcessPixelShader: {
  59033. name: string;
  59034. shader: string;
  59035. };
  59036. }
  59037. declare module BABYLON {
  59038. interface AbstractScene {
  59039. /**
  59040. * Return a the first highlight layer of the scene with a given name.
  59041. * @param name The name of the highlight layer to look for.
  59042. * @return The highlight layer if found otherwise null.
  59043. */
  59044. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59045. }
  59046. /**
  59047. * Highlight layer options. This helps customizing the behaviour
  59048. * of the highlight layer.
  59049. */
  59050. export interface IHighlightLayerOptions {
  59051. /**
  59052. * Multiplication factor apply to the canvas size to compute the render target size
  59053. * used to generated the glowing objects (the smaller the faster).
  59054. */
  59055. mainTextureRatio: number;
  59056. /**
  59057. * Enforces a fixed size texture to ensure resize independant blur.
  59058. */
  59059. mainTextureFixedSize?: number;
  59060. /**
  59061. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59062. * of the picture to blur (the smaller the faster).
  59063. */
  59064. blurTextureSizeRatio: number;
  59065. /**
  59066. * How big in texel of the blur texture is the vertical blur.
  59067. */
  59068. blurVerticalSize: number;
  59069. /**
  59070. * How big in texel of the blur texture is the horizontal blur.
  59071. */
  59072. blurHorizontalSize: number;
  59073. /**
  59074. * Alpha blending mode used to apply the blur. Default is combine.
  59075. */
  59076. alphaBlendingMode: number;
  59077. /**
  59078. * The camera attached to the layer.
  59079. */
  59080. camera: Nullable<Camera>;
  59081. /**
  59082. * Should we display highlight as a solid stroke?
  59083. */
  59084. isStroke?: boolean;
  59085. /**
  59086. * The rendering group to draw the layer in.
  59087. */
  59088. renderingGroupId: number;
  59089. }
  59090. /**
  59091. * The highlight layer Helps adding a glow effect around a mesh.
  59092. *
  59093. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59094. * glowy meshes to your scene.
  59095. *
  59096. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59097. */
  59098. export class HighlightLayer extends EffectLayer {
  59099. name: string;
  59100. /**
  59101. * Effect Name of the highlight layer.
  59102. */
  59103. static readonly EffectName: string;
  59104. /**
  59105. * The neutral color used during the preparation of the glow effect.
  59106. * This is black by default as the blend operation is a blend operation.
  59107. */
  59108. static NeutralColor: Color4;
  59109. /**
  59110. * Stencil value used for glowing meshes.
  59111. */
  59112. static GlowingMeshStencilReference: number;
  59113. /**
  59114. * Stencil value used for the other meshes in the scene.
  59115. */
  59116. static NormalMeshStencilReference: number;
  59117. /**
  59118. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59119. */
  59120. innerGlow: boolean;
  59121. /**
  59122. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59123. */
  59124. outerGlow: boolean;
  59125. /**
  59126. * Specifies the horizontal size of the blur.
  59127. */
  59128. set blurHorizontalSize(value: number);
  59129. /**
  59130. * Specifies the vertical size of the blur.
  59131. */
  59132. set blurVerticalSize(value: number);
  59133. /**
  59134. * Gets the horizontal size of the blur.
  59135. */
  59136. get blurHorizontalSize(): number;
  59137. /**
  59138. * Gets the vertical size of the blur.
  59139. */
  59140. get blurVerticalSize(): number;
  59141. /**
  59142. * An event triggered when the highlight layer is being blurred.
  59143. */
  59144. onBeforeBlurObservable: Observable<HighlightLayer>;
  59145. /**
  59146. * An event triggered when the highlight layer has been blurred.
  59147. */
  59148. onAfterBlurObservable: Observable<HighlightLayer>;
  59149. private _instanceGlowingMeshStencilReference;
  59150. private _options;
  59151. private _downSamplePostprocess;
  59152. private _horizontalBlurPostprocess;
  59153. private _verticalBlurPostprocess;
  59154. private _blurTexture;
  59155. private _meshes;
  59156. private _excludedMeshes;
  59157. /**
  59158. * Instantiates a new highlight Layer and references it to the scene..
  59159. * @param name The name of the layer
  59160. * @param scene The scene to use the layer in
  59161. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59162. */
  59163. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59164. /**
  59165. * Get the effect name of the layer.
  59166. * @return The effect name
  59167. */
  59168. getEffectName(): string;
  59169. /**
  59170. * Create the merge effect. This is the shader use to blit the information back
  59171. * to the main canvas at the end of the scene rendering.
  59172. */
  59173. protected _createMergeEffect(): Effect;
  59174. /**
  59175. * Creates the render target textures and post processes used in the highlight layer.
  59176. */
  59177. protected _createTextureAndPostProcesses(): void;
  59178. /**
  59179. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59180. */
  59181. needStencil(): boolean;
  59182. /**
  59183. * Checks for the readiness of the element composing the layer.
  59184. * @param subMesh the mesh to check for
  59185. * @param useInstances specify wether or not to use instances to render the mesh
  59186. * @param emissiveTexture the associated emissive texture used to generate the glow
  59187. * @return true if ready otherwise, false
  59188. */
  59189. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59190. /**
  59191. * Implementation specific of rendering the generating effect on the main canvas.
  59192. * @param effect The effect used to render through
  59193. */
  59194. protected _internalRender(effect: Effect): void;
  59195. /**
  59196. * Returns true if the layer contains information to display, otherwise false.
  59197. */
  59198. shouldRender(): boolean;
  59199. /**
  59200. * Returns true if the mesh should render, otherwise false.
  59201. * @param mesh The mesh to render
  59202. * @returns true if it should render otherwise false
  59203. */
  59204. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59205. /**
  59206. * Returns true if the mesh can be rendered, otherwise false.
  59207. * @param mesh The mesh to render
  59208. * @param material The material used on the mesh
  59209. * @returns true if it can be rendered otherwise false
  59210. */
  59211. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59212. /**
  59213. * Adds specific effects defines.
  59214. * @param defines The defines to add specifics to.
  59215. */
  59216. protected _addCustomEffectDefines(defines: string[]): void;
  59217. /**
  59218. * Sets the required values for both the emissive texture and and the main color.
  59219. */
  59220. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59221. /**
  59222. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59223. * @param mesh The mesh to exclude from the highlight layer
  59224. */
  59225. addExcludedMesh(mesh: Mesh): void;
  59226. /**
  59227. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59228. * @param mesh The mesh to highlight
  59229. */
  59230. removeExcludedMesh(mesh: Mesh): void;
  59231. /**
  59232. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59233. * @param mesh mesh to test
  59234. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59235. */
  59236. hasMesh(mesh: AbstractMesh): boolean;
  59237. /**
  59238. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59239. * @param mesh The mesh to highlight
  59240. * @param color The color of the highlight
  59241. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59242. */
  59243. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59244. /**
  59245. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59246. * @param mesh The mesh to highlight
  59247. */
  59248. removeMesh(mesh: Mesh): void;
  59249. /**
  59250. * Remove all the meshes currently referenced in the highlight layer
  59251. */
  59252. removeAllMeshes(): void;
  59253. /**
  59254. * Force the stencil to the normal expected value for none glowing parts
  59255. */
  59256. private _defaultStencilReference;
  59257. /**
  59258. * Free any resources and references associated to a mesh.
  59259. * Internal use
  59260. * @param mesh The mesh to free.
  59261. * @hidden
  59262. */
  59263. _disposeMesh(mesh: Mesh): void;
  59264. /**
  59265. * Dispose the highlight layer and free resources.
  59266. */
  59267. dispose(): void;
  59268. /**
  59269. * Gets the class name of the effect layer
  59270. * @returns the string with the class name of the effect layer
  59271. */
  59272. getClassName(): string;
  59273. /**
  59274. * Serializes this Highlight layer
  59275. * @returns a serialized Highlight layer object
  59276. */
  59277. serialize(): any;
  59278. /**
  59279. * Creates a Highlight layer from parsed Highlight layer data
  59280. * @param parsedHightlightLayer defines the Highlight layer data
  59281. * @param scene defines the current scene
  59282. * @param rootUrl defines the root URL containing the Highlight layer information
  59283. * @returns a parsed Highlight layer
  59284. */
  59285. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. interface AbstractScene {
  59290. /**
  59291. * The list of layers (background and foreground) of the scene
  59292. */
  59293. layers: Array<Layer>;
  59294. }
  59295. /**
  59296. * Defines the layer scene component responsible to manage any layers
  59297. * in a given scene.
  59298. */
  59299. export class LayerSceneComponent implements ISceneComponent {
  59300. /**
  59301. * The component name helpfull to identify the component in the list of scene components.
  59302. */
  59303. readonly name: string;
  59304. /**
  59305. * The scene the component belongs to.
  59306. */
  59307. scene: Scene;
  59308. private _engine;
  59309. /**
  59310. * Creates a new instance of the component for the given scene
  59311. * @param scene Defines the scene to register the component in
  59312. */
  59313. constructor(scene: Scene);
  59314. /**
  59315. * Registers the component in a given scene
  59316. */
  59317. register(): void;
  59318. /**
  59319. * Rebuilds the elements related to this component in case of
  59320. * context lost for instance.
  59321. */
  59322. rebuild(): void;
  59323. /**
  59324. * Disposes the component and the associated ressources.
  59325. */
  59326. dispose(): void;
  59327. private _draw;
  59328. private _drawCameraPredicate;
  59329. private _drawCameraBackground;
  59330. private _drawCameraForeground;
  59331. private _drawRenderTargetPredicate;
  59332. private _drawRenderTargetBackground;
  59333. private _drawRenderTargetForeground;
  59334. /**
  59335. * Adds all the elements from the container to the scene
  59336. * @param container the container holding the elements
  59337. */
  59338. addFromContainer(container: AbstractScene): void;
  59339. /**
  59340. * Removes all the elements in the container from the scene
  59341. * @param container contains the elements to remove
  59342. * @param dispose if the removed element should be disposed (default: false)
  59343. */
  59344. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59345. }
  59346. }
  59347. declare module BABYLON {
  59348. /** @hidden */
  59349. export var layerPixelShader: {
  59350. name: string;
  59351. shader: string;
  59352. };
  59353. }
  59354. declare module BABYLON {
  59355. /** @hidden */
  59356. export var layerVertexShader: {
  59357. name: string;
  59358. shader: string;
  59359. };
  59360. }
  59361. declare module BABYLON {
  59362. /**
  59363. * This represents a full screen 2d layer.
  59364. * This can be useful to display a picture in the background of your scene for instance.
  59365. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59366. */
  59367. export class Layer {
  59368. /**
  59369. * Define the name of the layer.
  59370. */
  59371. name: string;
  59372. /**
  59373. * Define the texture the layer should display.
  59374. */
  59375. texture: Nullable<Texture>;
  59376. /**
  59377. * Is the layer in background or foreground.
  59378. */
  59379. isBackground: boolean;
  59380. /**
  59381. * Define the color of the layer (instead of texture).
  59382. */
  59383. color: Color4;
  59384. /**
  59385. * Define the scale of the layer in order to zoom in out of the texture.
  59386. */
  59387. scale: Vector2;
  59388. /**
  59389. * Define an offset for the layer in order to shift the texture.
  59390. */
  59391. offset: Vector2;
  59392. /**
  59393. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59394. */
  59395. alphaBlendingMode: number;
  59396. /**
  59397. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59398. * Alpha test will not mix with the background color in case of transparency.
  59399. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59400. */
  59401. alphaTest: boolean;
  59402. /**
  59403. * Define a mask to restrict the layer to only some of the scene cameras.
  59404. */
  59405. layerMask: number;
  59406. /**
  59407. * Define the list of render target the layer is visible into.
  59408. */
  59409. renderTargetTextures: RenderTargetTexture[];
  59410. /**
  59411. * Define if the layer is only used in renderTarget or if it also
  59412. * renders in the main frame buffer of the canvas.
  59413. */
  59414. renderOnlyInRenderTargetTextures: boolean;
  59415. private _scene;
  59416. private _vertexBuffers;
  59417. private _indexBuffer;
  59418. private _effect;
  59419. private _previousDefines;
  59420. /**
  59421. * An event triggered when the layer is disposed.
  59422. */
  59423. onDisposeObservable: Observable<Layer>;
  59424. private _onDisposeObserver;
  59425. /**
  59426. * Back compatibility with callback before the onDisposeObservable existed.
  59427. * The set callback will be triggered when the layer has been disposed.
  59428. */
  59429. set onDispose(callback: () => void);
  59430. /**
  59431. * An event triggered before rendering the scene
  59432. */
  59433. onBeforeRenderObservable: Observable<Layer>;
  59434. private _onBeforeRenderObserver;
  59435. /**
  59436. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59437. * The set callback will be triggered just before rendering the layer.
  59438. */
  59439. set onBeforeRender(callback: () => void);
  59440. /**
  59441. * An event triggered after rendering the scene
  59442. */
  59443. onAfterRenderObservable: Observable<Layer>;
  59444. private _onAfterRenderObserver;
  59445. /**
  59446. * Back compatibility with callback before the onAfterRenderObservable existed.
  59447. * The set callback will be triggered just after rendering the layer.
  59448. */
  59449. set onAfterRender(callback: () => void);
  59450. /**
  59451. * Instantiates a new layer.
  59452. * This represents a full screen 2d layer.
  59453. * This can be useful to display a picture in the background of your scene for instance.
  59454. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59455. * @param name Define the name of the layer in the scene
  59456. * @param imgUrl Define the url of the texture to display in the layer
  59457. * @param scene Define the scene the layer belongs to
  59458. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59459. * @param color Defines a color for the layer
  59460. */
  59461. constructor(
  59462. /**
  59463. * Define the name of the layer.
  59464. */
  59465. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59466. private _createIndexBuffer;
  59467. /** @hidden */
  59468. _rebuild(): void;
  59469. /**
  59470. * Renders the layer in the scene.
  59471. */
  59472. render(): void;
  59473. /**
  59474. * Disposes and releases the associated ressources.
  59475. */
  59476. dispose(): void;
  59477. }
  59478. }
  59479. declare module BABYLON {
  59480. /** @hidden */
  59481. export var lensFlarePixelShader: {
  59482. name: string;
  59483. shader: string;
  59484. };
  59485. }
  59486. declare module BABYLON {
  59487. /** @hidden */
  59488. export var lensFlareVertexShader: {
  59489. name: string;
  59490. shader: string;
  59491. };
  59492. }
  59493. declare module BABYLON {
  59494. /**
  59495. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59496. * It is usually composed of several `lensFlare`.
  59497. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59498. */
  59499. export class LensFlareSystem {
  59500. /**
  59501. * Define the name of the lens flare system
  59502. */
  59503. name: string;
  59504. /**
  59505. * List of lens flares used in this system.
  59506. */
  59507. lensFlares: LensFlare[];
  59508. /**
  59509. * Define a limit from the border the lens flare can be visible.
  59510. */
  59511. borderLimit: number;
  59512. /**
  59513. * Define a viewport border we do not want to see the lens flare in.
  59514. */
  59515. viewportBorder: number;
  59516. /**
  59517. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59518. */
  59519. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59520. /**
  59521. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59522. */
  59523. layerMask: number;
  59524. /**
  59525. * Define the id of the lens flare system in the scene.
  59526. * (equal to name by default)
  59527. */
  59528. id: string;
  59529. private _scene;
  59530. private _emitter;
  59531. private _vertexBuffers;
  59532. private _indexBuffer;
  59533. private _effect;
  59534. private _positionX;
  59535. private _positionY;
  59536. private _isEnabled;
  59537. /** @hidden */
  59538. static _SceneComponentInitialization: (scene: Scene) => void;
  59539. /**
  59540. * Instantiates a lens flare system.
  59541. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59542. * It is usually composed of several `lensFlare`.
  59543. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59544. * @param name Define the name of the lens flare system in the scene
  59545. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59546. * @param scene Define the scene the lens flare system belongs to
  59547. */
  59548. constructor(
  59549. /**
  59550. * Define the name of the lens flare system
  59551. */
  59552. name: string, emitter: any, scene: Scene);
  59553. /**
  59554. * Define if the lens flare system is enabled.
  59555. */
  59556. get isEnabled(): boolean;
  59557. set isEnabled(value: boolean);
  59558. /**
  59559. * Get the scene the effects belongs to.
  59560. * @returns the scene holding the lens flare system
  59561. */
  59562. getScene(): Scene;
  59563. /**
  59564. * Get the emitter of the lens flare system.
  59565. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59566. * @returns the emitter of the lens flare system
  59567. */
  59568. getEmitter(): any;
  59569. /**
  59570. * Set the emitter of the lens flare system.
  59571. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59572. * @param newEmitter Define the new emitter of the system
  59573. */
  59574. setEmitter(newEmitter: any): void;
  59575. /**
  59576. * Get the lens flare system emitter position.
  59577. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59578. * @returns the position
  59579. */
  59580. getEmitterPosition(): Vector3;
  59581. /**
  59582. * @hidden
  59583. */
  59584. computeEffectivePosition(globalViewport: Viewport): boolean;
  59585. /** @hidden */
  59586. _isVisible(): boolean;
  59587. /**
  59588. * @hidden
  59589. */
  59590. render(): boolean;
  59591. /**
  59592. * Dispose and release the lens flare with its associated resources.
  59593. */
  59594. dispose(): void;
  59595. /**
  59596. * Parse a lens flare system from a JSON repressentation
  59597. * @param parsedLensFlareSystem Define the JSON to parse
  59598. * @param scene Define the scene the parsed system should be instantiated in
  59599. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59600. * @returns the parsed system
  59601. */
  59602. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59603. /**
  59604. * Serialize the current Lens Flare System into a JSON representation.
  59605. * @returns the serialized JSON
  59606. */
  59607. serialize(): any;
  59608. }
  59609. }
  59610. declare module BABYLON {
  59611. /**
  59612. * This represents one of the lens effect in a `lensFlareSystem`.
  59613. * It controls one of the indiviual texture used in the effect.
  59614. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59615. */
  59616. export class LensFlare {
  59617. /**
  59618. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59619. */
  59620. size: number;
  59621. /**
  59622. * 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.
  59623. */
  59624. position: number;
  59625. /**
  59626. * Define the lens color.
  59627. */
  59628. color: Color3;
  59629. /**
  59630. * Define the lens texture.
  59631. */
  59632. texture: Nullable<Texture>;
  59633. /**
  59634. * Define the alpha mode to render this particular lens.
  59635. */
  59636. alphaMode: number;
  59637. private _system;
  59638. /**
  59639. * Creates a new Lens Flare.
  59640. * This represents one of the lens effect in a `lensFlareSystem`.
  59641. * It controls one of the indiviual texture used in the effect.
  59642. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59643. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59644. * @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.
  59645. * @param color Define the lens color
  59646. * @param imgUrl Define the lens texture url
  59647. * @param system Define the `lensFlareSystem` this flare is part of
  59648. * @returns The newly created Lens Flare
  59649. */
  59650. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59651. /**
  59652. * Instantiates a new Lens Flare.
  59653. * This represents one of the lens effect in a `lensFlareSystem`.
  59654. * It controls one of the indiviual texture used in the effect.
  59655. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59656. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59657. * @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.
  59658. * @param color Define the lens color
  59659. * @param imgUrl Define the lens texture url
  59660. * @param system Define the `lensFlareSystem` this flare is part of
  59661. */
  59662. constructor(
  59663. /**
  59664. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59665. */
  59666. size: number,
  59667. /**
  59668. * 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.
  59669. */
  59670. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59671. /**
  59672. * Dispose and release the lens flare with its associated resources.
  59673. */
  59674. dispose(): void;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. interface AbstractScene {
  59679. /**
  59680. * The list of lens flare system added to the scene
  59681. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59682. */
  59683. lensFlareSystems: Array<LensFlareSystem>;
  59684. /**
  59685. * Removes the given lens flare system from this scene.
  59686. * @param toRemove The lens flare system to remove
  59687. * @returns The index of the removed lens flare system
  59688. */
  59689. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59690. /**
  59691. * Adds the given lens flare system to this scene
  59692. * @param newLensFlareSystem The lens flare system to add
  59693. */
  59694. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59695. /**
  59696. * Gets a lens flare system using its name
  59697. * @param name defines the name to look for
  59698. * @returns the lens flare system or null if not found
  59699. */
  59700. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59701. /**
  59702. * Gets a lens flare system using its id
  59703. * @param id defines the id to look for
  59704. * @returns the lens flare system or null if not found
  59705. */
  59706. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59707. }
  59708. /**
  59709. * Defines the lens flare scene component responsible to manage any lens flares
  59710. * in a given scene.
  59711. */
  59712. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59713. /**
  59714. * The component name helpfull to identify the component in the list of scene components.
  59715. */
  59716. readonly name: string;
  59717. /**
  59718. * The scene the component belongs to.
  59719. */
  59720. scene: Scene;
  59721. /**
  59722. * Creates a new instance of the component for the given scene
  59723. * @param scene Defines the scene to register the component in
  59724. */
  59725. constructor(scene: Scene);
  59726. /**
  59727. * Registers the component in a given scene
  59728. */
  59729. register(): void;
  59730. /**
  59731. * Rebuilds the elements related to this component in case of
  59732. * context lost for instance.
  59733. */
  59734. rebuild(): void;
  59735. /**
  59736. * Adds all the elements from the container to the scene
  59737. * @param container the container holding the elements
  59738. */
  59739. addFromContainer(container: AbstractScene): void;
  59740. /**
  59741. * Removes all the elements in the container from the scene
  59742. * @param container contains the elements to remove
  59743. * @param dispose if the removed element should be disposed (default: false)
  59744. */
  59745. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59746. /**
  59747. * Serializes the component data to the specified json object
  59748. * @param serializationObject The object to serialize to
  59749. */
  59750. serialize(serializationObject: any): void;
  59751. /**
  59752. * Disposes the component and the associated ressources.
  59753. */
  59754. dispose(): void;
  59755. private _draw;
  59756. }
  59757. }
  59758. declare module BABYLON {
  59759. /** @hidden */
  59760. export var depthPixelShader: {
  59761. name: string;
  59762. shader: string;
  59763. };
  59764. }
  59765. declare module BABYLON {
  59766. /** @hidden */
  59767. export var depthVertexShader: {
  59768. name: string;
  59769. shader: string;
  59770. };
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * This represents a depth renderer in Babylon.
  59775. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59776. */
  59777. export class DepthRenderer {
  59778. private _scene;
  59779. private _depthMap;
  59780. private _effect;
  59781. private readonly _storeNonLinearDepth;
  59782. private readonly _clearColor;
  59783. /** Get if the depth renderer is using packed depth or not */
  59784. readonly isPacked: boolean;
  59785. private _cachedDefines;
  59786. private _camera;
  59787. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59788. enabled: boolean;
  59789. /**
  59790. * Specifiess that the depth renderer will only be used within
  59791. * the camera it is created for.
  59792. * This can help forcing its rendering during the camera processing.
  59793. */
  59794. useOnlyInActiveCamera: boolean;
  59795. /** @hidden */
  59796. static _SceneComponentInitialization: (scene: Scene) => void;
  59797. /**
  59798. * Instantiates a depth renderer
  59799. * @param scene The scene the renderer belongs to
  59800. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59801. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59802. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59803. */
  59804. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59805. /**
  59806. * Creates the depth rendering effect and checks if the effect is ready.
  59807. * @param subMesh The submesh to be used to render the depth map of
  59808. * @param useInstances If multiple world instances should be used
  59809. * @returns if the depth renderer is ready to render the depth map
  59810. */
  59811. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59812. /**
  59813. * Gets the texture which the depth map will be written to.
  59814. * @returns The depth map texture
  59815. */
  59816. getDepthMap(): RenderTargetTexture;
  59817. /**
  59818. * Disposes of the depth renderer.
  59819. */
  59820. dispose(): void;
  59821. }
  59822. }
  59823. declare module BABYLON {
  59824. /** @hidden */
  59825. export var minmaxReduxPixelShader: {
  59826. name: string;
  59827. shader: string;
  59828. };
  59829. }
  59830. declare module BABYLON {
  59831. /**
  59832. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59833. * and maximum values from all values of the texture.
  59834. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59835. * The source values are read from the red channel of the texture.
  59836. */
  59837. export class MinMaxReducer {
  59838. /**
  59839. * Observable triggered when the computation has been performed
  59840. */
  59841. onAfterReductionPerformed: Observable<{
  59842. min: number;
  59843. max: number;
  59844. }>;
  59845. protected _camera: Camera;
  59846. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59847. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59848. protected _postProcessManager: PostProcessManager;
  59849. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59850. protected _forceFullscreenViewport: boolean;
  59851. /**
  59852. * Creates a min/max reducer
  59853. * @param camera The camera to use for the post processes
  59854. */
  59855. constructor(camera: Camera);
  59856. /**
  59857. * Gets the texture used to read the values from.
  59858. */
  59859. get sourceTexture(): Nullable<RenderTargetTexture>;
  59860. /**
  59861. * Sets the source texture to read the values from.
  59862. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59863. * because in such textures '1' value must not be taken into account to compute the maximum
  59864. * as this value is used to clear the texture.
  59865. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59866. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59867. * @param depthRedux Indicates if the texture is a depth texture or not
  59868. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59869. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59870. */
  59871. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59872. /**
  59873. * Defines the refresh rate of the computation.
  59874. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59875. */
  59876. get refreshRate(): number;
  59877. set refreshRate(value: number);
  59878. protected _activated: boolean;
  59879. /**
  59880. * Gets the activation status of the reducer
  59881. */
  59882. get activated(): boolean;
  59883. /**
  59884. * Activates the reduction computation.
  59885. * When activated, the observers registered in onAfterReductionPerformed are
  59886. * called after the compuation is performed
  59887. */
  59888. activate(): void;
  59889. /**
  59890. * Deactivates the reduction computation.
  59891. */
  59892. deactivate(): void;
  59893. /**
  59894. * Disposes the min/max reducer
  59895. * @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.
  59896. */
  59897. dispose(disposeAll?: boolean): void;
  59898. }
  59899. }
  59900. declare module BABYLON {
  59901. /**
  59902. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59903. */
  59904. export class DepthReducer extends MinMaxReducer {
  59905. private _depthRenderer;
  59906. private _depthRendererId;
  59907. /**
  59908. * Gets the depth renderer used for the computation.
  59909. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59910. */
  59911. get depthRenderer(): Nullable<DepthRenderer>;
  59912. /**
  59913. * Creates a depth reducer
  59914. * @param camera The camera used to render the depth texture
  59915. */
  59916. constructor(camera: Camera);
  59917. /**
  59918. * Sets the depth renderer to use to generate the depth map
  59919. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59920. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59921. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59922. */
  59923. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59924. /** @hidden */
  59925. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59926. /**
  59927. * Activates the reduction computation.
  59928. * When activated, the observers registered in onAfterReductionPerformed are
  59929. * called after the compuation is performed
  59930. */
  59931. activate(): void;
  59932. /**
  59933. * Deactivates the reduction computation.
  59934. */
  59935. deactivate(): void;
  59936. /**
  59937. * Disposes the depth reducer
  59938. * @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.
  59939. */
  59940. dispose(disposeAll?: boolean): void;
  59941. }
  59942. }
  59943. declare module BABYLON {
  59944. /**
  59945. * A CSM implementation allowing casting shadows on large scenes.
  59946. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59947. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59948. */
  59949. export class CascadedShadowGenerator extends ShadowGenerator {
  59950. private static readonly frustumCornersNDCSpace;
  59951. /**
  59952. * Name of the CSM class
  59953. */
  59954. static CLASSNAME: string;
  59955. /**
  59956. * Defines the default number of cascades used by the CSM.
  59957. */
  59958. static readonly DEFAULT_CASCADES_COUNT: number;
  59959. /**
  59960. * Defines the minimum number of cascades used by the CSM.
  59961. */
  59962. static readonly MIN_CASCADES_COUNT: number;
  59963. /**
  59964. * Defines the maximum number of cascades used by the CSM.
  59965. */
  59966. static readonly MAX_CASCADES_COUNT: number;
  59967. protected _validateFilter(filter: number): number;
  59968. /**
  59969. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59970. */
  59971. penumbraDarkness: number;
  59972. private _numCascades;
  59973. /**
  59974. * Gets or set the number of cascades used by the CSM.
  59975. */
  59976. get numCascades(): number;
  59977. set numCascades(value: number);
  59978. /**
  59979. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59980. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59981. */
  59982. stabilizeCascades: boolean;
  59983. private _freezeShadowCastersBoundingInfo;
  59984. private _freezeShadowCastersBoundingInfoObservable;
  59985. /**
  59986. * Enables or disables the shadow casters bounding info computation.
  59987. * If your shadow casters don't move, you can disable this feature.
  59988. * If it is enabled, the bounding box computation is done every frame.
  59989. */
  59990. get freezeShadowCastersBoundingInfo(): boolean;
  59991. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59992. private _scbiMin;
  59993. private _scbiMax;
  59994. protected _computeShadowCastersBoundingInfo(): void;
  59995. protected _shadowCastersBoundingInfo: BoundingInfo;
  59996. /**
  59997. * Gets or sets the shadow casters bounding info.
  59998. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59999. * so that the system won't overwrite the bounds you provide
  60000. */
  60001. get shadowCastersBoundingInfo(): BoundingInfo;
  60002. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60003. protected _breaksAreDirty: boolean;
  60004. protected _minDistance: number;
  60005. protected _maxDistance: number;
  60006. /**
  60007. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60008. *
  60009. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60010. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60011. * @param min minimal distance for the breaks (default to 0.)
  60012. * @param max maximal distance for the breaks (default to 1.)
  60013. */
  60014. setMinMaxDistance(min: number, max: number): void;
  60015. /** Gets the minimal distance used in the cascade break computation */
  60016. get minDistance(): number;
  60017. /** Gets the maximal distance used in the cascade break computation */
  60018. get maxDistance(): number;
  60019. /**
  60020. * Gets the class name of that object
  60021. * @returns "CascadedShadowGenerator"
  60022. */
  60023. getClassName(): string;
  60024. private _cascadeMinExtents;
  60025. private _cascadeMaxExtents;
  60026. /**
  60027. * Gets a cascade minimum extents
  60028. * @param cascadeIndex index of the cascade
  60029. * @returns the minimum cascade extents
  60030. */
  60031. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60032. /**
  60033. * Gets a cascade maximum extents
  60034. * @param cascadeIndex index of the cascade
  60035. * @returns the maximum cascade extents
  60036. */
  60037. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60038. private _cascades;
  60039. private _currentLayer;
  60040. private _viewSpaceFrustumsZ;
  60041. private _viewMatrices;
  60042. private _projectionMatrices;
  60043. private _transformMatrices;
  60044. private _transformMatricesAsArray;
  60045. private _frustumLengths;
  60046. private _lightSizeUVCorrection;
  60047. private _depthCorrection;
  60048. private _frustumCornersWorldSpace;
  60049. private _frustumCenter;
  60050. private _shadowCameraPos;
  60051. private _shadowMaxZ;
  60052. /**
  60053. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60054. * It defaults to camera.maxZ
  60055. */
  60056. get shadowMaxZ(): number;
  60057. /**
  60058. * Sets the shadow max z distance.
  60059. */
  60060. set shadowMaxZ(value: number);
  60061. protected _debug: boolean;
  60062. /**
  60063. * Gets or sets the debug flag.
  60064. * When enabled, the cascades are materialized by different colors on the screen.
  60065. */
  60066. get debug(): boolean;
  60067. set debug(dbg: boolean);
  60068. private _depthClamp;
  60069. /**
  60070. * Gets or sets the depth clamping value.
  60071. *
  60072. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60073. * to account for the shadow casters far away.
  60074. *
  60075. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60076. */
  60077. get depthClamp(): boolean;
  60078. set depthClamp(value: boolean);
  60079. private _cascadeBlendPercentage;
  60080. /**
  60081. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60082. * It defaults to 0.1 (10% blending).
  60083. */
  60084. get cascadeBlendPercentage(): number;
  60085. set cascadeBlendPercentage(value: number);
  60086. private _lambda;
  60087. /**
  60088. * Gets or set the lambda parameter.
  60089. * This parameter is used to split the camera frustum and create the cascades.
  60090. * 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.
  60091. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60092. */
  60093. get lambda(): number;
  60094. set lambda(value: number);
  60095. /**
  60096. * Gets the view matrix corresponding to a given cascade
  60097. * @param cascadeNum cascade to retrieve the view matrix from
  60098. * @returns the cascade view matrix
  60099. */
  60100. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60101. /**
  60102. * Gets the projection matrix corresponding to a given cascade
  60103. * @param cascadeNum cascade to retrieve the projection matrix from
  60104. * @returns the cascade projection matrix
  60105. */
  60106. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60107. /**
  60108. * Gets the transformation matrix corresponding to a given cascade
  60109. * @param cascadeNum cascade to retrieve the transformation matrix from
  60110. * @returns the cascade transformation matrix
  60111. */
  60112. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60113. private _depthRenderer;
  60114. /**
  60115. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60116. *
  60117. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60118. *
  60119. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60120. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60121. * @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
  60122. */
  60123. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60124. private _depthReducer;
  60125. private _autoCalcDepthBounds;
  60126. /**
  60127. * Gets or sets the autoCalcDepthBounds property.
  60128. *
  60129. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60130. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60131. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60132. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60133. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60134. */
  60135. get autoCalcDepthBounds(): boolean;
  60136. set autoCalcDepthBounds(value: boolean);
  60137. /**
  60138. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60139. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60140. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60141. * for setting the refresh rate on the renderer yourself!
  60142. */
  60143. get autoCalcDepthBoundsRefreshRate(): number;
  60144. set autoCalcDepthBoundsRefreshRate(value: number);
  60145. /**
  60146. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60147. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60148. * you change the camera near/far planes!
  60149. */
  60150. splitFrustum(): void;
  60151. private _splitFrustum;
  60152. private _computeMatrices;
  60153. private _computeFrustumInWorldSpace;
  60154. private _computeCascadeFrustum;
  60155. /**
  60156. * Support test.
  60157. */
  60158. static get IsSupported(): boolean;
  60159. /** @hidden */
  60160. static _SceneComponentInitialization: (scene: Scene) => void;
  60161. /**
  60162. * Creates a Cascaded Shadow Generator object.
  60163. * A ShadowGenerator is the required tool to use the shadows.
  60164. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60165. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60166. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60167. * @param light The directional light object generating the shadows.
  60168. * @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.
  60169. */
  60170. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60171. protected _initializeGenerator(): void;
  60172. protected _createTargetRenderTexture(): void;
  60173. protected _initializeShadowMap(): void;
  60174. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60175. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60176. /**
  60177. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60178. * @param defines Defines of the material we want to update
  60179. * @param lightIndex Index of the light in the enabled light list of the material
  60180. */
  60181. prepareDefines(defines: any, lightIndex: number): void;
  60182. /**
  60183. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60184. * defined in the generator but impacting the effect).
  60185. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60186. * @param effect The effect we are binfing the information for
  60187. */
  60188. bindShadowLight(lightIndex: string, effect: Effect): void;
  60189. /**
  60190. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60191. * (eq to view projection * shadow projection matrices)
  60192. * @returns The transform matrix used to create the shadow map
  60193. */
  60194. getTransformMatrix(): Matrix;
  60195. /**
  60196. * Disposes the ShadowGenerator.
  60197. * Returns nothing.
  60198. */
  60199. dispose(): void;
  60200. /**
  60201. * Serializes the shadow generator setup to a json object.
  60202. * @returns The serialized JSON object
  60203. */
  60204. serialize(): any;
  60205. /**
  60206. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60207. * @param parsedShadowGenerator The JSON object to parse
  60208. * @param scene The scene to create the shadow map for
  60209. * @returns The parsed shadow generator
  60210. */
  60211. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Defines the shadow generator component responsible to manage any shadow generators
  60217. * in a given scene.
  60218. */
  60219. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60220. /**
  60221. * The component name helpfull to identify the component in the list of scene components.
  60222. */
  60223. readonly name: string;
  60224. /**
  60225. * The scene the component belongs to.
  60226. */
  60227. scene: Scene;
  60228. /**
  60229. * Creates a new instance of the component for the given scene
  60230. * @param scene Defines the scene to register the component in
  60231. */
  60232. constructor(scene: Scene);
  60233. /**
  60234. * Registers the component in a given scene
  60235. */
  60236. register(): void;
  60237. /**
  60238. * Rebuilds the elements related to this component in case of
  60239. * context lost for instance.
  60240. */
  60241. rebuild(): void;
  60242. /**
  60243. * Serializes the component data to the specified json object
  60244. * @param serializationObject The object to serialize to
  60245. */
  60246. serialize(serializationObject: any): void;
  60247. /**
  60248. * Adds all the elements from the container to the scene
  60249. * @param container the container holding the elements
  60250. */
  60251. addFromContainer(container: AbstractScene): void;
  60252. /**
  60253. * Removes all the elements in the container from the scene
  60254. * @param container contains the elements to remove
  60255. * @param dispose if the removed element should be disposed (default: false)
  60256. */
  60257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60258. /**
  60259. * Rebuilds the elements related to this component in case of
  60260. * context lost for instance.
  60261. */
  60262. dispose(): void;
  60263. private _gatherRenderTargets;
  60264. }
  60265. }
  60266. declare module BABYLON {
  60267. /**
  60268. * A point light is a light defined by an unique point in world space.
  60269. * The light is emitted in every direction from this point.
  60270. * A good example of a point light is a standard light bulb.
  60271. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60272. */
  60273. export class PointLight extends ShadowLight {
  60274. private _shadowAngle;
  60275. /**
  60276. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60277. * This specifies what angle the shadow will use to be created.
  60278. *
  60279. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60280. */
  60281. get shadowAngle(): number;
  60282. /**
  60283. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60284. * This specifies what angle the shadow will use to be created.
  60285. *
  60286. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60287. */
  60288. set shadowAngle(value: number);
  60289. /**
  60290. * Gets the direction if it has been set.
  60291. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60292. */
  60293. get direction(): Vector3;
  60294. /**
  60295. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60296. */
  60297. set direction(value: Vector3);
  60298. /**
  60299. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60300. * A PointLight emits the light in every direction.
  60301. * It can cast shadows.
  60302. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60303. * ```javascript
  60304. * var pointLight = new PointLight("pl", camera.position, scene);
  60305. * ```
  60306. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60307. * @param name The light friendly name
  60308. * @param position The position of the point light in the scene
  60309. * @param scene The scene the lights belongs to
  60310. */
  60311. constructor(name: string, position: Vector3, scene: Scene);
  60312. /**
  60313. * Returns the string "PointLight"
  60314. * @returns the class name
  60315. */
  60316. getClassName(): string;
  60317. /**
  60318. * Returns the integer 0.
  60319. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60320. */
  60321. getTypeID(): number;
  60322. /**
  60323. * Specifies wether or not the shadowmap should be a cube texture.
  60324. * @returns true if the shadowmap needs to be a cube texture.
  60325. */
  60326. needCube(): boolean;
  60327. /**
  60328. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60329. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60330. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60331. */
  60332. getShadowDirection(faceIndex?: number): Vector3;
  60333. /**
  60334. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60335. * - fov = PI / 2
  60336. * - aspect ratio : 1.0
  60337. * - z-near and far equal to the active camera minZ and maxZ.
  60338. * Returns the PointLight.
  60339. */
  60340. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60341. protected _buildUniformLayout(): void;
  60342. /**
  60343. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60344. * @param effect The effect to update
  60345. * @param lightIndex The index of the light in the effect to update
  60346. * @returns The point light
  60347. */
  60348. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60349. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60350. /**
  60351. * Prepares the list of defines specific to the light type.
  60352. * @param defines the list of defines
  60353. * @param lightIndex defines the index of the light for the effect
  60354. */
  60355. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60356. }
  60357. }
  60358. declare module BABYLON {
  60359. /**
  60360. * Header information of HDR texture files.
  60361. */
  60362. export interface HDRInfo {
  60363. /**
  60364. * The height of the texture in pixels.
  60365. */
  60366. height: number;
  60367. /**
  60368. * The width of the texture in pixels.
  60369. */
  60370. width: number;
  60371. /**
  60372. * The index of the beginning of the data in the binary file.
  60373. */
  60374. dataPosition: number;
  60375. }
  60376. /**
  60377. * This groups tools to convert HDR texture to native colors array.
  60378. */
  60379. export class HDRTools {
  60380. private static Ldexp;
  60381. private static Rgbe2float;
  60382. private static readStringLine;
  60383. /**
  60384. * Reads header information from an RGBE texture stored in a native array.
  60385. * More information on this format are available here:
  60386. * https://en.wikipedia.org/wiki/RGBE_image_format
  60387. *
  60388. * @param uint8array The binary file stored in native array.
  60389. * @return The header information.
  60390. */
  60391. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60392. /**
  60393. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60394. * This RGBE texture needs to store the information as a panorama.
  60395. *
  60396. * More information on this format are available here:
  60397. * https://en.wikipedia.org/wiki/RGBE_image_format
  60398. *
  60399. * @param buffer The binary file stored in an array buffer.
  60400. * @param size The expected size of the extracted cubemap.
  60401. * @return The Cube Map information.
  60402. */
  60403. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60404. /**
  60405. * Returns the pixels data extracted from an RGBE texture.
  60406. * This pixels will be stored left to right up to down in the R G B order in one array.
  60407. *
  60408. * More information on this format are available here:
  60409. * https://en.wikipedia.org/wiki/RGBE_image_format
  60410. *
  60411. * @param uint8array The binary file stored in an array buffer.
  60412. * @param hdrInfo The header information of the file.
  60413. * @return The pixels data in RGB right to left up to down order.
  60414. */
  60415. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60416. private static RGBE_ReadPixels_RLE;
  60417. private static RGBE_ReadPixels_NOT_RLE;
  60418. }
  60419. }
  60420. declare module BABYLON {
  60421. /**
  60422. * Effect Render Options
  60423. */
  60424. export interface IEffectRendererOptions {
  60425. /**
  60426. * Defines the vertices positions.
  60427. */
  60428. positions?: number[];
  60429. /**
  60430. * Defines the indices.
  60431. */
  60432. indices?: number[];
  60433. }
  60434. /**
  60435. * Helper class to render one or more effects.
  60436. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60437. */
  60438. export class EffectRenderer {
  60439. private engine;
  60440. private static _DefaultOptions;
  60441. private _vertexBuffers;
  60442. private _indexBuffer;
  60443. private _fullscreenViewport;
  60444. /**
  60445. * Creates an effect renderer
  60446. * @param engine the engine to use for rendering
  60447. * @param options defines the options of the effect renderer
  60448. */
  60449. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60450. /**
  60451. * Sets the current viewport in normalized coordinates 0-1
  60452. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60453. */
  60454. setViewport(viewport?: Viewport): void;
  60455. /**
  60456. * Binds the embedded attributes buffer to the effect.
  60457. * @param effect Defines the effect to bind the attributes for
  60458. */
  60459. bindBuffers(effect: Effect): void;
  60460. /**
  60461. * Sets the current effect wrapper to use during draw.
  60462. * The effect needs to be ready before calling this api.
  60463. * This also sets the default full screen position attribute.
  60464. * @param effectWrapper Defines the effect to draw with
  60465. */
  60466. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60467. /**
  60468. * Restores engine states
  60469. */
  60470. restoreStates(): void;
  60471. /**
  60472. * Draws a full screen quad.
  60473. */
  60474. draw(): void;
  60475. private isRenderTargetTexture;
  60476. /**
  60477. * renders one or more effects to a specified texture
  60478. * @param effectWrapper the effect to renderer
  60479. * @param outputTexture texture to draw to, if null it will render to the screen.
  60480. */
  60481. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60482. /**
  60483. * Disposes of the effect renderer
  60484. */
  60485. dispose(): void;
  60486. }
  60487. /**
  60488. * Options to create an EffectWrapper
  60489. */
  60490. interface EffectWrapperCreationOptions {
  60491. /**
  60492. * Engine to use to create the effect
  60493. */
  60494. engine: ThinEngine;
  60495. /**
  60496. * Fragment shader for the effect
  60497. */
  60498. fragmentShader: string;
  60499. /**
  60500. * Use the shader store instead of direct source code
  60501. */
  60502. useShaderStore?: boolean;
  60503. /**
  60504. * Vertex shader for the effect
  60505. */
  60506. vertexShader?: string;
  60507. /**
  60508. * Attributes to use in the shader
  60509. */
  60510. attributeNames?: Array<string>;
  60511. /**
  60512. * Uniforms to use in the shader
  60513. */
  60514. uniformNames?: Array<string>;
  60515. /**
  60516. * Texture sampler names to use in the shader
  60517. */
  60518. samplerNames?: Array<string>;
  60519. /**
  60520. * Defines to use in the shader
  60521. */
  60522. defines?: Array<string>;
  60523. /**
  60524. * Callback when effect is compiled
  60525. */
  60526. onCompiled?: Nullable<(effect: Effect) => void>;
  60527. /**
  60528. * The friendly name of the effect displayed in Spector.
  60529. */
  60530. name?: string;
  60531. }
  60532. /**
  60533. * Wraps an effect to be used for rendering
  60534. */
  60535. export class EffectWrapper {
  60536. /**
  60537. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60538. */
  60539. onApplyObservable: Observable<{}>;
  60540. /**
  60541. * The underlying effect
  60542. */
  60543. effect: Effect;
  60544. /**
  60545. * Creates an effect to be renderer
  60546. * @param creationOptions options to create the effect
  60547. */
  60548. constructor(creationOptions: EffectWrapperCreationOptions);
  60549. /**
  60550. * Disposes of the effect wrapper
  60551. */
  60552. dispose(): void;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. /** @hidden */
  60557. export var hdrFilteringVertexShader: {
  60558. name: string;
  60559. shader: string;
  60560. };
  60561. }
  60562. declare module BABYLON {
  60563. /** @hidden */
  60564. export var hdrFilteringPixelShader: {
  60565. name: string;
  60566. shader: string;
  60567. };
  60568. }
  60569. declare module BABYLON {
  60570. /**
  60571. * Options for texture filtering
  60572. */
  60573. interface IHDRFilteringOptions {
  60574. /**
  60575. * Scales pixel intensity for the input HDR map.
  60576. */
  60577. hdrScale?: number;
  60578. /**
  60579. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60580. */
  60581. quality?: number;
  60582. }
  60583. /**
  60584. * Filters HDR maps to get correct renderings of PBR reflections
  60585. */
  60586. export class HDRFiltering {
  60587. private _engine;
  60588. private _effectRenderer;
  60589. private _effectWrapper;
  60590. private _lodGenerationOffset;
  60591. private _lodGenerationScale;
  60592. /**
  60593. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60594. * you care about baking speed.
  60595. */
  60596. quality: number;
  60597. /**
  60598. * Scales pixel intensity for the input HDR map.
  60599. */
  60600. hdrScale: number;
  60601. /**
  60602. * Instantiates HDR filter for reflection maps
  60603. *
  60604. * @param engine Thin engine
  60605. * @param options Options
  60606. */
  60607. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60608. private _createRenderTarget;
  60609. private _prefilterInternal;
  60610. private _createEffect;
  60611. /**
  60612. * Get a value indicating if the filter is ready to be used
  60613. * @param texture Texture to filter
  60614. * @returns true if the filter is ready
  60615. */
  60616. isReady(texture: BaseTexture): boolean;
  60617. /**
  60618. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60619. * Prefiltering will be invoked at the end of next rendering pass.
  60620. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60621. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60622. * @param texture Texture to filter
  60623. * @param onFinished Callback when filtering is done
  60624. * @return Promise called when prefiltering is done
  60625. */
  60626. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60627. }
  60628. }
  60629. declare module BABYLON {
  60630. /**
  60631. * This represents a texture coming from an HDR input.
  60632. *
  60633. * The only supported format is currently panorama picture stored in RGBE format.
  60634. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60635. */
  60636. export class HDRCubeTexture extends BaseTexture {
  60637. private static _facesMapping;
  60638. private _generateHarmonics;
  60639. private _noMipmap;
  60640. private _prefilterOnLoad;
  60641. private _textureMatrix;
  60642. private _size;
  60643. private _onLoad;
  60644. private _onError;
  60645. /**
  60646. * The texture URL.
  60647. */
  60648. url: string;
  60649. protected _isBlocking: boolean;
  60650. /**
  60651. * Sets wether or not the texture is blocking during loading.
  60652. */
  60653. set isBlocking(value: boolean);
  60654. /**
  60655. * Gets wether or not the texture is blocking during loading.
  60656. */
  60657. get isBlocking(): boolean;
  60658. protected _rotationY: number;
  60659. /**
  60660. * Sets texture matrix rotation angle around Y axis in radians.
  60661. */
  60662. set rotationY(value: number);
  60663. /**
  60664. * Gets texture matrix rotation angle around Y axis radians.
  60665. */
  60666. get rotationY(): number;
  60667. /**
  60668. * Gets or sets the center of the bounding box associated with the cube texture
  60669. * It must define where the camera used to render the texture was set
  60670. */
  60671. boundingBoxPosition: Vector3;
  60672. private _boundingBoxSize;
  60673. /**
  60674. * Gets or sets the size of the bounding box associated with the cube texture
  60675. * When defined, the cubemap will switch to local mode
  60676. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60677. * @example https://www.babylonjs-playground.com/#RNASML
  60678. */
  60679. set boundingBoxSize(value: Vector3);
  60680. get boundingBoxSize(): Vector3;
  60681. /**
  60682. * Instantiates an HDRTexture from the following parameters.
  60683. *
  60684. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60685. * @param sceneOrEngine The scene or engine the texture will be used in
  60686. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60687. * @param noMipmap Forces to not generate the mipmap if true
  60688. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60689. * @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)
  60690. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60691. */
  60692. 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>);
  60693. /**
  60694. * Get the current class name of the texture useful for serialization or dynamic coding.
  60695. * @returns "HDRCubeTexture"
  60696. */
  60697. getClassName(): string;
  60698. /**
  60699. * Occurs when the file is raw .hdr file.
  60700. */
  60701. private loadTexture;
  60702. clone(): HDRCubeTexture;
  60703. delayLoad(): void;
  60704. /**
  60705. * Get the texture reflection matrix used to rotate/transform the reflection.
  60706. * @returns the reflection matrix
  60707. */
  60708. getReflectionTextureMatrix(): Matrix;
  60709. /**
  60710. * Set the texture reflection matrix used to rotate/transform the reflection.
  60711. * @param value Define the reflection matrix to set
  60712. */
  60713. setReflectionTextureMatrix(value: Matrix): void;
  60714. /**
  60715. * Parses a JSON representation of an HDR Texture in order to create the texture
  60716. * @param parsedTexture Define the JSON representation
  60717. * @param scene Define the scene the texture should be created in
  60718. * @param rootUrl Define the root url in case we need to load relative dependencies
  60719. * @returns the newly created texture after parsing
  60720. */
  60721. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60722. serialize(): any;
  60723. }
  60724. }
  60725. declare module BABYLON {
  60726. /**
  60727. * Class used to control physics engine
  60728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60729. */
  60730. export class PhysicsEngine implements IPhysicsEngine {
  60731. private _physicsPlugin;
  60732. /**
  60733. * Global value used to control the smallest number supported by the simulation
  60734. */
  60735. static Epsilon: number;
  60736. private _impostors;
  60737. private _joints;
  60738. private _subTimeStep;
  60739. /**
  60740. * Gets the gravity vector used by the simulation
  60741. */
  60742. gravity: Vector3;
  60743. /**
  60744. * Factory used to create the default physics plugin.
  60745. * @returns The default physics plugin
  60746. */
  60747. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60748. /**
  60749. * Creates a new Physics Engine
  60750. * @param gravity defines the gravity vector used by the simulation
  60751. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60752. */
  60753. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60754. /**
  60755. * Sets the gravity vector used by the simulation
  60756. * @param gravity defines the gravity vector to use
  60757. */
  60758. setGravity(gravity: Vector3): void;
  60759. /**
  60760. * Set the time step of the physics engine.
  60761. * Default is 1/60.
  60762. * To slow it down, enter 1/600 for example.
  60763. * To speed it up, 1/30
  60764. * @param newTimeStep defines the new timestep to apply to this world.
  60765. */
  60766. setTimeStep(newTimeStep?: number): void;
  60767. /**
  60768. * Get the time step of the physics engine.
  60769. * @returns the current time step
  60770. */
  60771. getTimeStep(): number;
  60772. /**
  60773. * Set the sub time step of the physics engine.
  60774. * Default is 0 meaning there is no sub steps
  60775. * To increase physics resolution precision, set a small value (like 1 ms)
  60776. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60777. */
  60778. setSubTimeStep(subTimeStep?: number): void;
  60779. /**
  60780. * Get the sub time step of the physics engine.
  60781. * @returns the current sub time step
  60782. */
  60783. getSubTimeStep(): number;
  60784. /**
  60785. * Release all resources
  60786. */
  60787. dispose(): void;
  60788. /**
  60789. * Gets the name of the current physics plugin
  60790. * @returns the name of the plugin
  60791. */
  60792. getPhysicsPluginName(): string;
  60793. /**
  60794. * Adding a new impostor for the impostor tracking.
  60795. * This will be done by the impostor itself.
  60796. * @param impostor the impostor to add
  60797. */
  60798. addImpostor(impostor: PhysicsImpostor): void;
  60799. /**
  60800. * Remove an impostor from the engine.
  60801. * This impostor and its mesh will not longer be updated by the physics engine.
  60802. * @param impostor the impostor to remove
  60803. */
  60804. removeImpostor(impostor: PhysicsImpostor): void;
  60805. /**
  60806. * Add a joint to the physics engine
  60807. * @param mainImpostor defines the main impostor to which the joint is added.
  60808. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60809. * @param joint defines the joint that will connect both impostors.
  60810. */
  60811. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60812. /**
  60813. * Removes a joint from the simulation
  60814. * @param mainImpostor defines the impostor used with the joint
  60815. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60816. * @param joint defines the joint to remove
  60817. */
  60818. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60819. /**
  60820. * Called by the scene. No need to call it.
  60821. * @param delta defines the timespam between frames
  60822. */
  60823. _step(delta: number): void;
  60824. /**
  60825. * Gets the current plugin used to run the simulation
  60826. * @returns current plugin
  60827. */
  60828. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60829. /**
  60830. * Gets the list of physic impostors
  60831. * @returns an array of PhysicsImpostor
  60832. */
  60833. getImpostors(): Array<PhysicsImpostor>;
  60834. /**
  60835. * Gets the impostor for a physics enabled object
  60836. * @param object defines the object impersonated by the impostor
  60837. * @returns the PhysicsImpostor or null if not found
  60838. */
  60839. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60840. /**
  60841. * Gets the impostor for a physics body object
  60842. * @param body defines physics body used by the impostor
  60843. * @returns the PhysicsImpostor or null if not found
  60844. */
  60845. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60846. /**
  60847. * Does a raycast in the physics world
  60848. * @param from when should the ray start?
  60849. * @param to when should the ray end?
  60850. * @returns PhysicsRaycastResult
  60851. */
  60852. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60853. }
  60854. }
  60855. declare module BABYLON {
  60856. /** @hidden */
  60857. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60858. private _useDeltaForWorldStep;
  60859. world: any;
  60860. name: string;
  60861. private _physicsMaterials;
  60862. private _fixedTimeStep;
  60863. private _cannonRaycastResult;
  60864. private _raycastResult;
  60865. private _physicsBodysToRemoveAfterStep;
  60866. private _firstFrame;
  60867. BJSCANNON: any;
  60868. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60869. setGravity(gravity: Vector3): void;
  60870. setTimeStep(timeStep: number): void;
  60871. getTimeStep(): number;
  60872. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60873. private _removeMarkedPhysicsBodiesFromWorld;
  60874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60875. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60876. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60877. private _processChildMeshes;
  60878. removePhysicsBody(impostor: PhysicsImpostor): void;
  60879. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60880. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60881. private _addMaterial;
  60882. private _checkWithEpsilon;
  60883. private _createShape;
  60884. private _createHeightmap;
  60885. private _minus90X;
  60886. private _plus90X;
  60887. private _tmpPosition;
  60888. private _tmpDeltaPosition;
  60889. private _tmpUnityRotation;
  60890. private _updatePhysicsBodyTransformation;
  60891. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60893. isSupported(): boolean;
  60894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60899. getBodyMass(impostor: PhysicsImpostor): number;
  60900. getBodyFriction(impostor: PhysicsImpostor): number;
  60901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60902. getBodyRestitution(impostor: PhysicsImpostor): number;
  60903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60904. sleepBody(impostor: PhysicsImpostor): void;
  60905. wakeUpBody(impostor: PhysicsImpostor): void;
  60906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60907. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60910. getRadius(impostor: PhysicsImpostor): number;
  60911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60912. dispose(): void;
  60913. private _extendNamespace;
  60914. /**
  60915. * Does a raycast in the physics world
  60916. * @param from when should the ray start?
  60917. * @param to when should the ray end?
  60918. * @returns PhysicsRaycastResult
  60919. */
  60920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60921. }
  60922. }
  60923. declare module BABYLON {
  60924. /** @hidden */
  60925. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60926. private _useDeltaForWorldStep;
  60927. world: any;
  60928. name: string;
  60929. BJSOIMO: any;
  60930. private _raycastResult;
  60931. private _fixedTimeStep;
  60932. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60933. setGravity(gravity: Vector3): void;
  60934. setTimeStep(timeStep: number): void;
  60935. getTimeStep(): number;
  60936. private _tmpImpostorsArray;
  60937. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60938. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60939. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60940. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60941. private _tmpPositionVector;
  60942. removePhysicsBody(impostor: PhysicsImpostor): void;
  60943. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60944. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60945. isSupported(): boolean;
  60946. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60947. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60948. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60949. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60950. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60951. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60952. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60953. getBodyMass(impostor: PhysicsImpostor): number;
  60954. getBodyFriction(impostor: PhysicsImpostor): number;
  60955. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60956. getBodyRestitution(impostor: PhysicsImpostor): number;
  60957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60958. sleepBody(impostor: PhysicsImpostor): void;
  60959. wakeUpBody(impostor: PhysicsImpostor): void;
  60960. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60961. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60962. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60963. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60964. getRadius(impostor: PhysicsImpostor): number;
  60965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60966. dispose(): void;
  60967. /**
  60968. * Does a raycast in the physics world
  60969. * @param from when should the ray start?
  60970. * @param to when should the ray end?
  60971. * @returns PhysicsRaycastResult
  60972. */
  60973. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60974. }
  60975. }
  60976. declare module BABYLON {
  60977. /**
  60978. * AmmoJS Physics plugin
  60979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60980. * @see https://github.com/kripken/ammo.js/
  60981. */
  60982. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60983. private _useDeltaForWorldStep;
  60984. /**
  60985. * Reference to the Ammo library
  60986. */
  60987. bjsAMMO: any;
  60988. /**
  60989. * Created ammoJS world which physics bodies are added to
  60990. */
  60991. world: any;
  60992. /**
  60993. * Name of the plugin
  60994. */
  60995. name: string;
  60996. private _timeStep;
  60997. private _fixedTimeStep;
  60998. private _maxSteps;
  60999. private _tmpQuaternion;
  61000. private _tmpAmmoTransform;
  61001. private _tmpAmmoQuaternion;
  61002. private _tmpAmmoConcreteContactResultCallback;
  61003. private _collisionConfiguration;
  61004. private _dispatcher;
  61005. private _overlappingPairCache;
  61006. private _solver;
  61007. private _softBodySolver;
  61008. private _tmpAmmoVectorA;
  61009. private _tmpAmmoVectorB;
  61010. private _tmpAmmoVectorC;
  61011. private _tmpAmmoVectorD;
  61012. private _tmpContactCallbackResult;
  61013. private _tmpAmmoVectorRCA;
  61014. private _tmpAmmoVectorRCB;
  61015. private _raycastResult;
  61016. private static readonly DISABLE_COLLISION_FLAG;
  61017. private static readonly KINEMATIC_FLAG;
  61018. private static readonly DISABLE_DEACTIVATION_FLAG;
  61019. /**
  61020. * Initializes the ammoJS plugin
  61021. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61022. * @param ammoInjection can be used to inject your own ammo reference
  61023. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61024. */
  61025. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61026. /**
  61027. * Sets the gravity of the physics world (m/(s^2))
  61028. * @param gravity Gravity to set
  61029. */
  61030. setGravity(gravity: Vector3): void;
  61031. /**
  61032. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61033. * @param timeStep timestep to use in seconds
  61034. */
  61035. setTimeStep(timeStep: number): void;
  61036. /**
  61037. * 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)
  61038. * @param fixedTimeStep fixedTimeStep to use in seconds
  61039. */
  61040. setFixedTimeStep(fixedTimeStep: number): void;
  61041. /**
  61042. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61043. * @param maxSteps the maximum number of steps by the physics engine per frame
  61044. */
  61045. setMaxSteps(maxSteps: number): void;
  61046. /**
  61047. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61048. * @returns the current timestep in seconds
  61049. */
  61050. getTimeStep(): number;
  61051. /**
  61052. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61053. */
  61054. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61055. private _isImpostorInContact;
  61056. private _isImpostorPairInContact;
  61057. private _stepSimulation;
  61058. /**
  61059. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61060. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61061. * After the step the babylon meshes are set to the position of the physics imposters
  61062. * @param delta amount of time to step forward
  61063. * @param impostors array of imposters to update before/after the step
  61064. */
  61065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61066. /**
  61067. * Update babylon mesh to match physics world object
  61068. * @param impostor imposter to match
  61069. */
  61070. private _afterSoftStep;
  61071. /**
  61072. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61073. * @param impostor imposter to match
  61074. */
  61075. private _ropeStep;
  61076. /**
  61077. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61078. * @param impostor imposter to match
  61079. */
  61080. private _softbodyOrClothStep;
  61081. private _tmpMatrix;
  61082. /**
  61083. * Applies an impulse on the imposter
  61084. * @param impostor imposter to apply impulse to
  61085. * @param force amount of force to be applied to the imposter
  61086. * @param contactPoint the location to apply the impulse on the imposter
  61087. */
  61088. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61089. /**
  61090. * Applies a force on the imposter
  61091. * @param impostor imposter to apply force
  61092. * @param force amount of force to be applied to the imposter
  61093. * @param contactPoint the location to apply the force on the imposter
  61094. */
  61095. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61096. /**
  61097. * Creates a physics body using the plugin
  61098. * @param impostor the imposter to create the physics body on
  61099. */
  61100. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61101. /**
  61102. * Removes the physics body from the imposter and disposes of the body's memory
  61103. * @param impostor imposter to remove the physics body from
  61104. */
  61105. removePhysicsBody(impostor: PhysicsImpostor): void;
  61106. /**
  61107. * Generates a joint
  61108. * @param impostorJoint the imposter joint to create the joint with
  61109. */
  61110. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61111. /**
  61112. * Removes a joint
  61113. * @param impostorJoint the imposter joint to remove the joint from
  61114. */
  61115. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61116. private _addMeshVerts;
  61117. /**
  61118. * Initialise the soft body vertices to match its object's (mesh) vertices
  61119. * Softbody vertices (nodes) are in world space and to match this
  61120. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61121. * @param impostor to create the softbody for
  61122. */
  61123. private _softVertexData;
  61124. /**
  61125. * Create an impostor's soft body
  61126. * @param impostor to create the softbody for
  61127. */
  61128. private _createSoftbody;
  61129. /**
  61130. * Create cloth for an impostor
  61131. * @param impostor to create the softbody for
  61132. */
  61133. private _createCloth;
  61134. /**
  61135. * Create rope for an impostor
  61136. * @param impostor to create the softbody for
  61137. */
  61138. private _createRope;
  61139. /**
  61140. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61141. * @param impostor to create the custom physics shape for
  61142. */
  61143. private _createCustom;
  61144. private _addHullVerts;
  61145. private _createShape;
  61146. /**
  61147. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61148. * @param impostor imposter containing the physics body and babylon object
  61149. */
  61150. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61151. /**
  61152. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61153. * @param impostor imposter containing the physics body and babylon object
  61154. * @param newPosition new position
  61155. * @param newRotation new rotation
  61156. */
  61157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61158. /**
  61159. * If this plugin is supported
  61160. * @returns true if its supported
  61161. */
  61162. isSupported(): boolean;
  61163. /**
  61164. * Sets the linear velocity of the physics body
  61165. * @param impostor imposter to set the velocity on
  61166. * @param velocity velocity to set
  61167. */
  61168. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61169. /**
  61170. * Sets the angular velocity of the physics body
  61171. * @param impostor imposter to set the velocity on
  61172. * @param velocity velocity to set
  61173. */
  61174. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61175. /**
  61176. * gets the linear velocity
  61177. * @param impostor imposter to get linear velocity from
  61178. * @returns linear velocity
  61179. */
  61180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61181. /**
  61182. * gets the angular velocity
  61183. * @param impostor imposter to get angular velocity from
  61184. * @returns angular velocity
  61185. */
  61186. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61187. /**
  61188. * Sets the mass of physics body
  61189. * @param impostor imposter to set the mass on
  61190. * @param mass mass to set
  61191. */
  61192. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61193. /**
  61194. * Gets the mass of the physics body
  61195. * @param impostor imposter to get the mass from
  61196. * @returns mass
  61197. */
  61198. getBodyMass(impostor: PhysicsImpostor): number;
  61199. /**
  61200. * Gets friction of the impostor
  61201. * @param impostor impostor to get friction from
  61202. * @returns friction value
  61203. */
  61204. getBodyFriction(impostor: PhysicsImpostor): number;
  61205. /**
  61206. * Sets friction of the impostor
  61207. * @param impostor impostor to set friction on
  61208. * @param friction friction value
  61209. */
  61210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61211. /**
  61212. * Gets restitution of the impostor
  61213. * @param impostor impostor to get restitution from
  61214. * @returns restitution value
  61215. */
  61216. getBodyRestitution(impostor: PhysicsImpostor): number;
  61217. /**
  61218. * Sets resitution of the impostor
  61219. * @param impostor impostor to set resitution on
  61220. * @param restitution resitution value
  61221. */
  61222. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61223. /**
  61224. * Gets pressure inside the impostor
  61225. * @param impostor impostor to get pressure from
  61226. * @returns pressure value
  61227. */
  61228. getBodyPressure(impostor: PhysicsImpostor): number;
  61229. /**
  61230. * Sets pressure inside a soft body impostor
  61231. * Cloth and rope must remain 0 pressure
  61232. * @param impostor impostor to set pressure on
  61233. * @param pressure pressure value
  61234. */
  61235. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61236. /**
  61237. * Gets stiffness of the impostor
  61238. * @param impostor impostor to get stiffness from
  61239. * @returns pressure value
  61240. */
  61241. getBodyStiffness(impostor: PhysicsImpostor): number;
  61242. /**
  61243. * Sets stiffness of the impostor
  61244. * @param impostor impostor to set stiffness on
  61245. * @param stiffness stiffness value from 0 to 1
  61246. */
  61247. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61248. /**
  61249. * Gets velocityIterations of the impostor
  61250. * @param impostor impostor to get velocity iterations from
  61251. * @returns velocityIterations value
  61252. */
  61253. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61254. /**
  61255. * Sets velocityIterations of the impostor
  61256. * @param impostor impostor to set velocity iterations on
  61257. * @param velocityIterations velocityIterations value
  61258. */
  61259. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61260. /**
  61261. * Gets positionIterations of the impostor
  61262. * @param impostor impostor to get position iterations from
  61263. * @returns positionIterations value
  61264. */
  61265. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61266. /**
  61267. * Sets positionIterations of the impostor
  61268. * @param impostor impostor to set position on
  61269. * @param positionIterations positionIterations value
  61270. */
  61271. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61272. /**
  61273. * Append an anchor to a cloth object
  61274. * @param impostor is the cloth impostor to add anchor to
  61275. * @param otherImpostor is the rigid impostor to anchor to
  61276. * @param width ratio across width from 0 to 1
  61277. * @param height ratio up height from 0 to 1
  61278. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61279. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61280. */
  61281. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61282. /**
  61283. * Append an hook to a rope object
  61284. * @param impostor is the rope impostor to add hook to
  61285. * @param otherImpostor is the rigid impostor to hook to
  61286. * @param length ratio along the rope from 0 to 1
  61287. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61288. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61289. */
  61290. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61291. /**
  61292. * Sleeps the physics body and stops it from being active
  61293. * @param impostor impostor to sleep
  61294. */
  61295. sleepBody(impostor: PhysicsImpostor): void;
  61296. /**
  61297. * Activates the physics body
  61298. * @param impostor impostor to activate
  61299. */
  61300. wakeUpBody(impostor: PhysicsImpostor): void;
  61301. /**
  61302. * Updates the distance parameters of the joint
  61303. * @param joint joint to update
  61304. * @param maxDistance maximum distance of the joint
  61305. * @param minDistance minimum distance of the joint
  61306. */
  61307. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61308. /**
  61309. * Sets a motor on the joint
  61310. * @param joint joint to set motor on
  61311. * @param speed speed of the motor
  61312. * @param maxForce maximum force of the motor
  61313. * @param motorIndex index of the motor
  61314. */
  61315. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61316. /**
  61317. * Sets the motors limit
  61318. * @param joint joint to set limit on
  61319. * @param upperLimit upper limit
  61320. * @param lowerLimit lower limit
  61321. */
  61322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61323. /**
  61324. * Syncs the position and rotation of a mesh with the impostor
  61325. * @param mesh mesh to sync
  61326. * @param impostor impostor to update the mesh with
  61327. */
  61328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61329. /**
  61330. * Gets the radius of the impostor
  61331. * @param impostor impostor to get radius from
  61332. * @returns the radius
  61333. */
  61334. getRadius(impostor: PhysicsImpostor): number;
  61335. /**
  61336. * Gets the box size of the impostor
  61337. * @param impostor impostor to get box size from
  61338. * @param result the resulting box size
  61339. */
  61340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61341. /**
  61342. * Disposes of the impostor
  61343. */
  61344. dispose(): void;
  61345. /**
  61346. * Does a raycast in the physics world
  61347. * @param from when should the ray start?
  61348. * @param to when should the ray end?
  61349. * @returns PhysicsRaycastResult
  61350. */
  61351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61352. }
  61353. }
  61354. declare module BABYLON {
  61355. interface AbstractScene {
  61356. /**
  61357. * The list of reflection probes added to the scene
  61358. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61359. */
  61360. reflectionProbes: Array<ReflectionProbe>;
  61361. /**
  61362. * Removes the given reflection probe from this scene.
  61363. * @param toRemove The reflection probe to remove
  61364. * @returns The index of the removed reflection probe
  61365. */
  61366. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61367. /**
  61368. * Adds the given reflection probe to this scene.
  61369. * @param newReflectionProbe The reflection probe to add
  61370. */
  61371. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61372. }
  61373. /**
  61374. * Class used to generate realtime reflection / refraction cube textures
  61375. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61376. */
  61377. export class ReflectionProbe {
  61378. /** defines the name of the probe */
  61379. name: string;
  61380. private _scene;
  61381. private _renderTargetTexture;
  61382. private _projectionMatrix;
  61383. private _viewMatrix;
  61384. private _target;
  61385. private _add;
  61386. private _attachedMesh;
  61387. private _invertYAxis;
  61388. /** Gets or sets probe position (center of the cube map) */
  61389. position: Vector3;
  61390. /**
  61391. * Creates a new reflection probe
  61392. * @param name defines the name of the probe
  61393. * @param size defines the texture resolution (for each face)
  61394. * @param scene defines the hosting scene
  61395. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61396. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61397. */
  61398. constructor(
  61399. /** defines the name of the probe */
  61400. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61401. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61402. get samples(): number;
  61403. set samples(value: number);
  61404. /** Gets or sets the refresh rate to use (on every frame by default) */
  61405. get refreshRate(): number;
  61406. set refreshRate(value: number);
  61407. /**
  61408. * Gets the hosting scene
  61409. * @returns a Scene
  61410. */
  61411. getScene(): Scene;
  61412. /** Gets the internal CubeTexture used to render to */
  61413. get cubeTexture(): RenderTargetTexture;
  61414. /** Gets the list of meshes to render */
  61415. get renderList(): Nullable<AbstractMesh[]>;
  61416. /**
  61417. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61418. * @param mesh defines the mesh to attach to
  61419. */
  61420. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61421. /**
  61422. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61423. * @param renderingGroupId The rendering group id corresponding to its index
  61424. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61425. */
  61426. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61427. /**
  61428. * Clean all associated resources
  61429. */
  61430. dispose(): void;
  61431. /**
  61432. * Converts the reflection probe information to a readable string for debug purpose.
  61433. * @param fullDetails Supports for multiple levels of logging within scene loading
  61434. * @returns the human readable reflection probe info
  61435. */
  61436. toString(fullDetails?: boolean): string;
  61437. /**
  61438. * Get the class name of the relfection probe.
  61439. * @returns "ReflectionProbe"
  61440. */
  61441. getClassName(): string;
  61442. /**
  61443. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61444. * @returns The JSON representation of the texture
  61445. */
  61446. serialize(): any;
  61447. /**
  61448. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61449. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61450. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61451. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61452. * @returns The parsed reflection probe if successful
  61453. */
  61454. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61455. }
  61456. }
  61457. declare module BABYLON {
  61458. /** @hidden */
  61459. export var _BabylonLoaderRegistered: boolean;
  61460. /**
  61461. * Helps setting up some configuration for the babylon file loader.
  61462. */
  61463. export class BabylonFileLoaderConfiguration {
  61464. /**
  61465. * The loader does not allow injecting custom physix engine into the plugins.
  61466. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61467. * So you could set this variable to your engine import to make it work.
  61468. */
  61469. static LoaderInjectedPhysicsEngine: any;
  61470. }
  61471. }
  61472. declare module BABYLON {
  61473. /**
  61474. * The Physically based simple base material of BJS.
  61475. *
  61476. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61477. * It is used as the base class for both the specGloss and metalRough conventions.
  61478. */
  61479. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61480. /**
  61481. * Number of Simultaneous lights allowed on the material.
  61482. */
  61483. maxSimultaneousLights: number;
  61484. /**
  61485. * If sets to true, disables all the lights affecting the material.
  61486. */
  61487. disableLighting: boolean;
  61488. /**
  61489. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61490. */
  61491. environmentTexture: BaseTexture;
  61492. /**
  61493. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61494. */
  61495. invertNormalMapX: boolean;
  61496. /**
  61497. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61498. */
  61499. invertNormalMapY: boolean;
  61500. /**
  61501. * Normal map used in the model.
  61502. */
  61503. normalTexture: BaseTexture;
  61504. /**
  61505. * Emissivie color used to self-illuminate the model.
  61506. */
  61507. emissiveColor: Color3;
  61508. /**
  61509. * Emissivie texture used to self-illuminate the model.
  61510. */
  61511. emissiveTexture: BaseTexture;
  61512. /**
  61513. * Occlusion Channel Strenght.
  61514. */
  61515. occlusionStrength: number;
  61516. /**
  61517. * Occlusion Texture of the material (adding extra occlusion effects).
  61518. */
  61519. occlusionTexture: BaseTexture;
  61520. /**
  61521. * Defines the alpha limits in alpha test mode.
  61522. */
  61523. alphaCutOff: number;
  61524. /**
  61525. * Gets the current double sided mode.
  61526. */
  61527. get doubleSided(): boolean;
  61528. /**
  61529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61530. */
  61531. set doubleSided(value: boolean);
  61532. /**
  61533. * Stores the pre-calculated light information of a mesh in a texture.
  61534. */
  61535. lightmapTexture: BaseTexture;
  61536. /**
  61537. * If true, the light map contains occlusion information instead of lighting info.
  61538. */
  61539. useLightmapAsShadowmap: boolean;
  61540. /**
  61541. * Instantiates a new PBRMaterial instance.
  61542. *
  61543. * @param name The material name
  61544. * @param scene The scene the material will be use in.
  61545. */
  61546. constructor(name: string, scene: Scene);
  61547. getClassName(): string;
  61548. }
  61549. }
  61550. declare module BABYLON {
  61551. /**
  61552. * The PBR material of BJS following the metal roughness convention.
  61553. *
  61554. * This fits to the PBR convention in the GLTF definition:
  61555. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61556. */
  61557. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61558. /**
  61559. * The base color has two different interpretations depending on the value of metalness.
  61560. * When the material is a metal, the base color is the specific measured reflectance value
  61561. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61562. * of the material.
  61563. */
  61564. baseColor: Color3;
  61565. /**
  61566. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61567. * well as opacity information in the alpha channel.
  61568. */
  61569. baseTexture: BaseTexture;
  61570. /**
  61571. * Specifies the metallic scalar value of the material.
  61572. * Can also be used to scale the metalness values of the metallic texture.
  61573. */
  61574. metallic: number;
  61575. /**
  61576. * Specifies the roughness scalar value of the material.
  61577. * Can also be used to scale the roughness values of the metallic texture.
  61578. */
  61579. roughness: number;
  61580. /**
  61581. * Texture containing both the metallic value in the B channel and the
  61582. * roughness value in the G channel to keep better precision.
  61583. */
  61584. metallicRoughnessTexture: BaseTexture;
  61585. /**
  61586. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61587. *
  61588. * @param name The material name
  61589. * @param scene The scene the material will be use in.
  61590. */
  61591. constructor(name: string, scene: Scene);
  61592. /**
  61593. * Return the currrent class name of the material.
  61594. */
  61595. getClassName(): string;
  61596. /**
  61597. * Makes a duplicate of the current material.
  61598. * @param name - name to use for the new material.
  61599. */
  61600. clone(name: string): PBRMetallicRoughnessMaterial;
  61601. /**
  61602. * Serialize the material to a parsable JSON object.
  61603. */
  61604. serialize(): any;
  61605. /**
  61606. * Parses a JSON object correponding to the serialize function.
  61607. */
  61608. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61609. }
  61610. }
  61611. declare module BABYLON {
  61612. /**
  61613. * The PBR material of BJS following the specular glossiness convention.
  61614. *
  61615. * This fits to the PBR convention in the GLTF definition:
  61616. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61617. */
  61618. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61619. /**
  61620. * Specifies the diffuse color of the material.
  61621. */
  61622. diffuseColor: Color3;
  61623. /**
  61624. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61625. * channel.
  61626. */
  61627. diffuseTexture: BaseTexture;
  61628. /**
  61629. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61630. */
  61631. specularColor: Color3;
  61632. /**
  61633. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61634. */
  61635. glossiness: number;
  61636. /**
  61637. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61638. */
  61639. specularGlossinessTexture: BaseTexture;
  61640. /**
  61641. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61642. *
  61643. * @param name The material name
  61644. * @param scene The scene the material will be use in.
  61645. */
  61646. constructor(name: string, scene: Scene);
  61647. /**
  61648. * Return the currrent class name of the material.
  61649. */
  61650. getClassName(): string;
  61651. /**
  61652. * Makes a duplicate of the current material.
  61653. * @param name - name to use for the new material.
  61654. */
  61655. clone(name: string): PBRSpecularGlossinessMaterial;
  61656. /**
  61657. * Serialize the material to a parsable JSON object.
  61658. */
  61659. serialize(): any;
  61660. /**
  61661. * Parses a JSON object correponding to the serialize function.
  61662. */
  61663. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61664. }
  61665. }
  61666. declare module BABYLON {
  61667. /**
  61668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61669. * It can help converting any input color in a desired output one. This can then be used to create effects
  61670. * from sepia, black and white to sixties or futuristic rendering...
  61671. *
  61672. * The only supported format is currently 3dl.
  61673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61674. */
  61675. export class ColorGradingTexture extends BaseTexture {
  61676. /**
  61677. * The texture URL.
  61678. */
  61679. url: string;
  61680. /**
  61681. * Empty line regex stored for GC.
  61682. */
  61683. private static _noneEmptyLineRegex;
  61684. private _textureMatrix;
  61685. private _onLoad;
  61686. /**
  61687. * Instantiates a ColorGradingTexture from the following parameters.
  61688. *
  61689. * @param url The location of the color gradind data (currently only supporting 3dl)
  61690. * @param sceneOrEngine The scene or engine the texture will be used in
  61691. * @param onLoad defines a callback triggered when the texture has been loaded
  61692. */
  61693. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61694. /**
  61695. * Fires the onload event from the constructor if requested.
  61696. */
  61697. private _triggerOnLoad;
  61698. /**
  61699. * Returns the texture matrix used in most of the material.
  61700. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61701. */
  61702. getTextureMatrix(): Matrix;
  61703. /**
  61704. * Occurs when the file being loaded is a .3dl LUT file.
  61705. */
  61706. private load3dlTexture;
  61707. /**
  61708. * Starts the loading process of the texture.
  61709. */
  61710. private loadTexture;
  61711. /**
  61712. * Clones the color gradind texture.
  61713. */
  61714. clone(): ColorGradingTexture;
  61715. /**
  61716. * Called during delayed load for textures.
  61717. */
  61718. delayLoad(): void;
  61719. /**
  61720. * Parses a color grading texture serialized by Babylon.
  61721. * @param parsedTexture The texture information being parsedTexture
  61722. * @param scene The scene to load the texture in
  61723. * @param rootUrl The root url of the data assets to load
  61724. * @return A color gradind texture
  61725. */
  61726. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61727. /**
  61728. * Serializes the LUT texture to json format.
  61729. */
  61730. serialize(): any;
  61731. }
  61732. }
  61733. declare module BABYLON {
  61734. /**
  61735. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61736. */
  61737. export class EquiRectangularCubeTexture extends BaseTexture {
  61738. /** The six faces of the cube. */
  61739. private static _FacesMapping;
  61740. private _noMipmap;
  61741. private _onLoad;
  61742. private _onError;
  61743. /** The size of the cubemap. */
  61744. private _size;
  61745. /** The buffer of the image. */
  61746. private _buffer;
  61747. /** The width of the input image. */
  61748. private _width;
  61749. /** The height of the input image. */
  61750. private _height;
  61751. /** The URL to the image. */
  61752. url: string;
  61753. /**
  61754. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61755. * @param url The location of the image
  61756. * @param scene The scene the texture will be used in
  61757. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61758. * @param noMipmap Forces to not generate the mipmap if true
  61759. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61760. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61761. * @param onLoad — defines a callback called when texture is loaded
  61762. * @param onError — defines a callback called if there is an error
  61763. */
  61764. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61765. /**
  61766. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61767. */
  61768. private loadImage;
  61769. /**
  61770. * Convert the image buffer into a cubemap and create a CubeTexture.
  61771. */
  61772. private loadTexture;
  61773. /**
  61774. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61775. * @param buffer The ArrayBuffer that should be converted.
  61776. * @returns The buffer as Float32Array.
  61777. */
  61778. private getFloat32ArrayFromArrayBuffer;
  61779. /**
  61780. * Get the current class name of the texture useful for serialization or dynamic coding.
  61781. * @returns "EquiRectangularCubeTexture"
  61782. */
  61783. getClassName(): string;
  61784. /**
  61785. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61786. * @returns A clone of the current EquiRectangularCubeTexture.
  61787. */
  61788. clone(): EquiRectangularCubeTexture;
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /**
  61793. * Defines the options related to the creation of an HtmlElementTexture
  61794. */
  61795. export interface IHtmlElementTextureOptions {
  61796. /**
  61797. * Defines wether mip maps should be created or not.
  61798. */
  61799. generateMipMaps?: boolean;
  61800. /**
  61801. * Defines the sampling mode of the texture.
  61802. */
  61803. samplingMode?: number;
  61804. /**
  61805. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61806. */
  61807. engine: Nullable<ThinEngine>;
  61808. /**
  61809. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61810. */
  61811. scene: Nullable<Scene>;
  61812. }
  61813. /**
  61814. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61815. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61816. * is automatically managed.
  61817. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61818. * in your application.
  61819. *
  61820. * As the update is not automatic, you need to call them manually.
  61821. */
  61822. export class HtmlElementTexture extends BaseTexture {
  61823. /**
  61824. * The texture URL.
  61825. */
  61826. element: HTMLVideoElement | HTMLCanvasElement;
  61827. private static readonly DefaultOptions;
  61828. private _textureMatrix;
  61829. private _isVideo;
  61830. private _generateMipMaps;
  61831. private _samplingMode;
  61832. /**
  61833. * Instantiates a HtmlElementTexture from the following parameters.
  61834. *
  61835. * @param name Defines the name of the texture
  61836. * @param element Defines the video or canvas the texture is filled with
  61837. * @param options Defines the other none mandatory texture creation options
  61838. */
  61839. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61840. private _createInternalTexture;
  61841. /**
  61842. * Returns the texture matrix used in most of the material.
  61843. */
  61844. getTextureMatrix(): Matrix;
  61845. /**
  61846. * Updates the content of the texture.
  61847. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61848. */
  61849. update(invertY?: Nullable<boolean>): void;
  61850. }
  61851. }
  61852. declare module BABYLON {
  61853. /**
  61854. * Based on jsTGALoader - Javascript loader for TGA file
  61855. * By Vincent Thibault
  61856. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61857. */
  61858. export class TGATools {
  61859. private static _TYPE_INDEXED;
  61860. private static _TYPE_RGB;
  61861. private static _TYPE_GREY;
  61862. private static _TYPE_RLE_INDEXED;
  61863. private static _TYPE_RLE_RGB;
  61864. private static _TYPE_RLE_GREY;
  61865. private static _ORIGIN_MASK;
  61866. private static _ORIGIN_SHIFT;
  61867. private static _ORIGIN_BL;
  61868. private static _ORIGIN_BR;
  61869. private static _ORIGIN_UL;
  61870. private static _ORIGIN_UR;
  61871. /**
  61872. * Gets the header of a TGA file
  61873. * @param data defines the TGA data
  61874. * @returns the header
  61875. */
  61876. static GetTGAHeader(data: Uint8Array): any;
  61877. /**
  61878. * Uploads TGA content to a Babylon Texture
  61879. * @hidden
  61880. */
  61881. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61882. /** @hidden */
  61883. 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;
  61884. /** @hidden */
  61885. 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;
  61886. /** @hidden */
  61887. 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;
  61888. /** @hidden */
  61889. 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;
  61890. /** @hidden */
  61891. 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;
  61892. /** @hidden */
  61893. 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;
  61894. }
  61895. }
  61896. declare module BABYLON {
  61897. /**
  61898. * Implementation of the TGA Texture Loader.
  61899. * @hidden
  61900. */
  61901. export class _TGATextureLoader implements IInternalTextureLoader {
  61902. /**
  61903. * Defines wether the loader supports cascade loading the different faces.
  61904. */
  61905. readonly supportCascades: boolean;
  61906. /**
  61907. * This returns if the loader support the current file information.
  61908. * @param extension defines the file extension of the file being loaded
  61909. * @returns true if the loader can load the specified file
  61910. */
  61911. canLoad(extension: string): boolean;
  61912. /**
  61913. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61914. * @param data contains the texture data
  61915. * @param texture defines the BabylonJS internal texture
  61916. * @param createPolynomials will be true if polynomials have been requested
  61917. * @param onLoad defines the callback to trigger once the texture is ready
  61918. * @param onError defines the callback to trigger in case of error
  61919. */
  61920. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61921. /**
  61922. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61923. * @param data contains the texture data
  61924. * @param texture defines the BabylonJS internal texture
  61925. * @param callback defines the method to call once ready to upload
  61926. */
  61927. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61928. }
  61929. }
  61930. declare module BABYLON {
  61931. /**
  61932. * Info about the .basis files
  61933. */
  61934. class BasisFileInfo {
  61935. /**
  61936. * If the file has alpha
  61937. */
  61938. hasAlpha: boolean;
  61939. /**
  61940. * Info about each image of the basis file
  61941. */
  61942. images: Array<{
  61943. levels: Array<{
  61944. width: number;
  61945. height: number;
  61946. transcodedPixels: ArrayBufferView;
  61947. }>;
  61948. }>;
  61949. }
  61950. /**
  61951. * Result of transcoding a basis file
  61952. */
  61953. class TranscodeResult {
  61954. /**
  61955. * Info about the .basis file
  61956. */
  61957. fileInfo: BasisFileInfo;
  61958. /**
  61959. * Format to use when loading the file
  61960. */
  61961. format: number;
  61962. }
  61963. /**
  61964. * Configuration options for the Basis transcoder
  61965. */
  61966. export class BasisTranscodeConfiguration {
  61967. /**
  61968. * Supported compression formats used to determine the supported output format of the transcoder
  61969. */
  61970. supportedCompressionFormats?: {
  61971. /**
  61972. * etc1 compression format
  61973. */
  61974. etc1?: boolean;
  61975. /**
  61976. * s3tc compression format
  61977. */
  61978. s3tc?: boolean;
  61979. /**
  61980. * pvrtc compression format
  61981. */
  61982. pvrtc?: boolean;
  61983. /**
  61984. * etc2 compression format
  61985. */
  61986. etc2?: boolean;
  61987. };
  61988. /**
  61989. * If mipmap levels should be loaded for transcoded images (Default: true)
  61990. */
  61991. loadMipmapLevels?: boolean;
  61992. /**
  61993. * Index of a single image to load (Default: all images)
  61994. */
  61995. loadSingleImage?: number;
  61996. }
  61997. /**
  61998. * Used to load .Basis files
  61999. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62000. */
  62001. export class BasisTools {
  62002. private static _IgnoreSupportedFormats;
  62003. /**
  62004. * URL to use when loading the basis transcoder
  62005. */
  62006. static JSModuleURL: string;
  62007. /**
  62008. * URL to use when loading the wasm module for the transcoder
  62009. */
  62010. static WasmModuleURL: string;
  62011. /**
  62012. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62013. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62014. * @returns internal format corresponding to the Basis format
  62015. */
  62016. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62017. private static _WorkerPromise;
  62018. private static _Worker;
  62019. private static _actionId;
  62020. private static _CreateWorkerAsync;
  62021. /**
  62022. * Transcodes a loaded image file to compressed pixel data
  62023. * @param data image data to transcode
  62024. * @param config configuration options for the transcoding
  62025. * @returns a promise resulting in the transcoded image
  62026. */
  62027. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62028. /**
  62029. * Loads a texture from the transcode result
  62030. * @param texture texture load to
  62031. * @param transcodeResult the result of transcoding the basis file to load from
  62032. */
  62033. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Loader for .basis file format
  62039. */
  62040. export class _BasisTextureLoader implements IInternalTextureLoader {
  62041. /**
  62042. * Defines whether the loader supports cascade loading the different faces.
  62043. */
  62044. readonly supportCascades: boolean;
  62045. /**
  62046. * This returns if the loader support the current file information.
  62047. * @param extension defines the file extension of the file being loaded
  62048. * @returns true if the loader can load the specified file
  62049. */
  62050. canLoad(extension: string): boolean;
  62051. /**
  62052. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62053. * @param data contains the texture data
  62054. * @param texture defines the BabylonJS internal texture
  62055. * @param createPolynomials will be true if polynomials have been requested
  62056. * @param onLoad defines the callback to trigger once the texture is ready
  62057. * @param onError defines the callback to trigger in case of error
  62058. */
  62059. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62060. /**
  62061. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62062. * @param data contains the texture data
  62063. * @param texture defines the BabylonJS internal texture
  62064. * @param callback defines the method to call once ready to upload
  62065. */
  62066. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62067. }
  62068. }
  62069. declare module BABYLON {
  62070. /**
  62071. * Defines the basic options interface of a TexturePacker Frame
  62072. */
  62073. export interface ITexturePackerFrame {
  62074. /**
  62075. * The frame ID
  62076. */
  62077. id: number;
  62078. /**
  62079. * The frames Scale
  62080. */
  62081. scale: Vector2;
  62082. /**
  62083. * The Frames offset
  62084. */
  62085. offset: Vector2;
  62086. }
  62087. /**
  62088. * This is a support class for frame Data on texture packer sets.
  62089. */
  62090. export class TexturePackerFrame implements ITexturePackerFrame {
  62091. /**
  62092. * The frame ID
  62093. */
  62094. id: number;
  62095. /**
  62096. * The frames Scale
  62097. */
  62098. scale: Vector2;
  62099. /**
  62100. * The Frames offset
  62101. */
  62102. offset: Vector2;
  62103. /**
  62104. * Initializes a texture package frame.
  62105. * @param id The numerical frame identifier
  62106. * @param scale Scalar Vector2 for UV frame
  62107. * @param offset Vector2 for the frame position in UV units.
  62108. * @returns TexturePackerFrame
  62109. */
  62110. constructor(id: number, scale: Vector2, offset: Vector2);
  62111. }
  62112. }
  62113. declare module BABYLON {
  62114. /**
  62115. * Defines the basic options interface of a TexturePacker
  62116. */
  62117. export interface ITexturePackerOptions {
  62118. /**
  62119. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62120. */
  62121. map?: string[];
  62122. /**
  62123. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62124. */
  62125. uvsIn?: string;
  62126. /**
  62127. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62128. */
  62129. uvsOut?: string;
  62130. /**
  62131. * number representing the layout style. Defaults to LAYOUT_STRIP
  62132. */
  62133. layout?: number;
  62134. /**
  62135. * number of columns if using custom column count layout(2). This defaults to 4.
  62136. */
  62137. colnum?: number;
  62138. /**
  62139. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62140. */
  62141. updateInputMeshes?: boolean;
  62142. /**
  62143. * boolean flag to dispose all the source textures. Defaults to true.
  62144. */
  62145. disposeSources?: boolean;
  62146. /**
  62147. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62148. */
  62149. fillBlanks?: boolean;
  62150. /**
  62151. * string value representing the context fill style color. Defaults to 'black'.
  62152. */
  62153. customFillColor?: string;
  62154. /**
  62155. * Width and Height Value of each Frame in the TexturePacker Sets
  62156. */
  62157. frameSize?: number;
  62158. /**
  62159. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62160. */
  62161. paddingRatio?: number;
  62162. /**
  62163. * Number that declares the fill method for the padding gutter.
  62164. */
  62165. paddingMode?: number;
  62166. /**
  62167. * If in SUBUV_COLOR padding mode what color to use.
  62168. */
  62169. paddingColor?: Color3 | Color4;
  62170. }
  62171. /**
  62172. * Defines the basic interface of a TexturePacker JSON File
  62173. */
  62174. export interface ITexturePackerJSON {
  62175. /**
  62176. * The frame ID
  62177. */
  62178. name: string;
  62179. /**
  62180. * The base64 channel data
  62181. */
  62182. sets: any;
  62183. /**
  62184. * The options of the Packer
  62185. */
  62186. options: ITexturePackerOptions;
  62187. /**
  62188. * The frame data of the Packer
  62189. */
  62190. frames: Array<number>;
  62191. }
  62192. /**
  62193. * This is a support class that generates a series of packed texture sets.
  62194. * @see https://doc.babylonjs.com/babylon101/materials
  62195. */
  62196. export class TexturePacker {
  62197. /** Packer Layout Constant 0 */
  62198. static readonly LAYOUT_STRIP: number;
  62199. /** Packer Layout Constant 1 */
  62200. static readonly LAYOUT_POWER2: number;
  62201. /** Packer Layout Constant 2 */
  62202. static readonly LAYOUT_COLNUM: number;
  62203. /** Packer Layout Constant 0 */
  62204. static readonly SUBUV_WRAP: number;
  62205. /** Packer Layout Constant 1 */
  62206. static readonly SUBUV_EXTEND: number;
  62207. /** Packer Layout Constant 2 */
  62208. static readonly SUBUV_COLOR: number;
  62209. /** The Name of the Texture Package */
  62210. name: string;
  62211. /** The scene scope of the TexturePacker */
  62212. scene: Scene;
  62213. /** The Meshes to target */
  62214. meshes: AbstractMesh[];
  62215. /** Arguments passed with the Constructor */
  62216. options: ITexturePackerOptions;
  62217. /** The promise that is started upon initialization */
  62218. promise: Nullable<Promise<TexturePacker | string>>;
  62219. /** The Container object for the channel sets that are generated */
  62220. sets: object;
  62221. /** The Container array for the frames that are generated */
  62222. frames: TexturePackerFrame[];
  62223. /** The expected number of textures the system is parsing. */
  62224. private _expecting;
  62225. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62226. private _paddingValue;
  62227. /**
  62228. * Initializes a texture package series from an array of meshes or a single mesh.
  62229. * @param name The name of the package
  62230. * @param meshes The target meshes to compose the package from
  62231. * @param options The arguments that texture packer should follow while building.
  62232. * @param scene The scene which the textures are scoped to.
  62233. * @returns TexturePacker
  62234. */
  62235. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62236. /**
  62237. * Starts the package process
  62238. * @param resolve The promises resolution function
  62239. * @returns TexturePacker
  62240. */
  62241. private _createFrames;
  62242. /**
  62243. * Calculates the Size of the Channel Sets
  62244. * @returns Vector2
  62245. */
  62246. private _calculateSize;
  62247. /**
  62248. * Calculates the UV data for the frames.
  62249. * @param baseSize the base frameSize
  62250. * @param padding the base frame padding
  62251. * @param dtSize size of the Dynamic Texture for that channel
  62252. * @param dtUnits is 1/dtSize
  62253. * @param update flag to update the input meshes
  62254. */
  62255. private _calculateMeshUVFrames;
  62256. /**
  62257. * Calculates the frames Offset.
  62258. * @param index of the frame
  62259. * @returns Vector2
  62260. */
  62261. private _getFrameOffset;
  62262. /**
  62263. * Updates a Mesh to the frame data
  62264. * @param mesh that is the target
  62265. * @param frameID or the frame index
  62266. */
  62267. private _updateMeshUV;
  62268. /**
  62269. * Updates a Meshes materials to use the texture packer channels
  62270. * @param m is the mesh to target
  62271. * @param force all channels on the packer to be set.
  62272. */
  62273. private _updateTextureReferences;
  62274. /**
  62275. * Public method to set a Mesh to a frame
  62276. * @param m that is the target
  62277. * @param frameID or the frame index
  62278. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62279. */
  62280. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62281. /**
  62282. * Starts the async promise to compile the texture packer.
  62283. * @returns Promise<void>
  62284. */
  62285. processAsync(): Promise<void>;
  62286. /**
  62287. * Disposes all textures associated with this packer
  62288. */
  62289. dispose(): void;
  62290. /**
  62291. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62292. * @param imageType is the image type to use.
  62293. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62294. */
  62295. download(imageType?: string, quality?: number): void;
  62296. /**
  62297. * Public method to load a texturePacker JSON file.
  62298. * @param data of the JSON file in string format.
  62299. */
  62300. updateFromJSON(data: string): void;
  62301. }
  62302. }
  62303. declare module BABYLON {
  62304. /**
  62305. * 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.
  62306. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62307. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62308. */
  62309. export class CustomProceduralTexture extends ProceduralTexture {
  62310. private _animate;
  62311. private _time;
  62312. private _config;
  62313. private _texturePath;
  62314. /**
  62315. * Instantiates a new Custom Procedural Texture.
  62316. * 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.
  62317. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62318. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62319. * @param name Define the name of the texture
  62320. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62321. * @param size Define the size of the texture to create
  62322. * @param scene Define the scene the texture belongs to
  62323. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62324. * @param generateMipMaps Define if the texture should creates mip maps or not
  62325. */
  62326. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62327. private _loadJson;
  62328. /**
  62329. * Is the texture ready to be used ? (rendered at least once)
  62330. * @returns true if ready, otherwise, false.
  62331. */
  62332. isReady(): boolean;
  62333. /**
  62334. * Render the texture to its associated render target.
  62335. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62336. */
  62337. render(useCameraPostProcess?: boolean): void;
  62338. /**
  62339. * Update the list of dependant textures samplers in the shader.
  62340. */
  62341. updateTextures(): void;
  62342. /**
  62343. * Update the uniform values of the procedural texture in the shader.
  62344. */
  62345. updateShaderUniforms(): void;
  62346. /**
  62347. * Define if the texture animates or not.
  62348. */
  62349. get animate(): boolean;
  62350. set animate(value: boolean);
  62351. }
  62352. }
  62353. declare module BABYLON {
  62354. /** @hidden */
  62355. export var noisePixelShader: {
  62356. name: string;
  62357. shader: string;
  62358. };
  62359. }
  62360. declare module BABYLON {
  62361. /**
  62362. * Class used to generate noise procedural textures
  62363. */
  62364. export class NoiseProceduralTexture extends ProceduralTexture {
  62365. /** Gets or sets the start time (default is 0) */
  62366. time: number;
  62367. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62368. brightness: number;
  62369. /** Defines the number of octaves to process */
  62370. octaves: number;
  62371. /** Defines the level of persistence (0.8 by default) */
  62372. persistence: number;
  62373. /** Gets or sets animation speed factor (default is 1) */
  62374. animationSpeedFactor: number;
  62375. /**
  62376. * Creates a new NoiseProceduralTexture
  62377. * @param name defines the name fo the texture
  62378. * @param size defines the size of the texture (default is 256)
  62379. * @param scene defines the hosting scene
  62380. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62381. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62382. */
  62383. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62384. private _updateShaderUniforms;
  62385. protected _getDefines(): string;
  62386. /** Generate the current state of the procedural texture */
  62387. render(useCameraPostProcess?: boolean): void;
  62388. /**
  62389. * Serializes this noise procedural texture
  62390. * @returns a serialized noise procedural texture object
  62391. */
  62392. serialize(): any;
  62393. /**
  62394. * Clone the texture.
  62395. * @returns the cloned texture
  62396. */
  62397. clone(): NoiseProceduralTexture;
  62398. /**
  62399. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62400. * @param parsedTexture defines parsed texture data
  62401. * @param scene defines the current scene
  62402. * @param rootUrl defines the root URL containing noise procedural texture information
  62403. * @returns a parsed NoiseProceduralTexture
  62404. */
  62405. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62406. }
  62407. }
  62408. declare module BABYLON {
  62409. /**
  62410. * Raw cube texture where the raw buffers are passed in
  62411. */
  62412. export class RawCubeTexture extends CubeTexture {
  62413. /**
  62414. * Creates a cube texture where the raw buffers are passed in.
  62415. * @param scene defines the scene the texture is attached to
  62416. * @param data defines the array of data to use to create each face
  62417. * @param size defines the size of the textures
  62418. * @param format defines the format of the data
  62419. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62420. * @param generateMipMaps defines if the engine should generate the mip levels
  62421. * @param invertY defines if data must be stored with Y axis inverted
  62422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62423. * @param compression defines the compression used (null by default)
  62424. */
  62425. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62426. /**
  62427. * Updates the raw cube texture.
  62428. * @param data defines the data to store
  62429. * @param format defines the data format
  62430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62431. * @param invertY defines if data must be stored with Y axis inverted
  62432. * @param compression defines the compression used (null by default)
  62433. * @param level defines which level of the texture to update
  62434. */
  62435. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62436. /**
  62437. * Updates a raw cube texture with RGBD encoded data.
  62438. * @param data defines the array of data [mipmap][face] to use to create each face
  62439. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62440. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62441. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62442. * @returns a promsie that resolves when the operation is complete
  62443. */
  62444. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62445. /**
  62446. * Clones the raw cube texture.
  62447. * @return a new cube texture
  62448. */
  62449. clone(): CubeTexture;
  62450. /** @hidden */
  62451. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62452. }
  62453. }
  62454. declare module BABYLON {
  62455. /**
  62456. * Class used to store 2D array textures containing user data
  62457. */
  62458. export class RawTexture2DArray extends Texture {
  62459. /** Gets or sets the texture format to use */
  62460. format: number;
  62461. /**
  62462. * Create a new RawTexture2DArray
  62463. * @param data defines the data of the texture
  62464. * @param width defines the width of the texture
  62465. * @param height defines the height of the texture
  62466. * @param depth defines the number of layers of the texture
  62467. * @param format defines the texture format to use
  62468. * @param scene defines the hosting scene
  62469. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62470. * @param invertY defines if texture must be stored with Y axis inverted
  62471. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62473. */
  62474. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62475. /** Gets or sets the texture format to use */
  62476. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62477. /**
  62478. * Update the texture with new data
  62479. * @param data defines the data to store in the texture
  62480. */
  62481. update(data: ArrayBufferView): void;
  62482. }
  62483. }
  62484. declare module BABYLON {
  62485. /**
  62486. * Class used to store 3D textures containing user data
  62487. */
  62488. export class RawTexture3D extends Texture {
  62489. /** Gets or sets the texture format to use */
  62490. format: number;
  62491. /**
  62492. * Create a new RawTexture3D
  62493. * @param data defines the data of the texture
  62494. * @param width defines the width of the texture
  62495. * @param height defines the height of the texture
  62496. * @param depth defines the depth of the texture
  62497. * @param format defines the texture format to use
  62498. * @param scene defines the hosting scene
  62499. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62500. * @param invertY defines if texture must be stored with Y axis inverted
  62501. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62502. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62503. */
  62504. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62505. /** Gets or sets the texture format to use */
  62506. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62507. /**
  62508. * Update the texture with new data
  62509. * @param data defines the data to store in the texture
  62510. */
  62511. update(data: ArrayBufferView): void;
  62512. }
  62513. }
  62514. declare module BABYLON {
  62515. /**
  62516. * Creates a refraction texture used by refraction channel of the standard material.
  62517. * It is like a mirror but to see through a material.
  62518. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62519. */
  62520. export class RefractionTexture extends RenderTargetTexture {
  62521. /**
  62522. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62523. * 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.
  62524. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62525. */
  62526. refractionPlane: Plane;
  62527. /**
  62528. * Define how deep under the surface we should see.
  62529. */
  62530. depth: number;
  62531. /**
  62532. * Creates a refraction texture used by refraction channel of the standard material.
  62533. * It is like a mirror but to see through a material.
  62534. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62535. * @param name Define the texture name
  62536. * @param size Define the size of the underlying texture
  62537. * @param scene Define the scene the refraction belongs to
  62538. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62539. */
  62540. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62541. /**
  62542. * Clone the refraction texture.
  62543. * @returns the cloned texture
  62544. */
  62545. clone(): RefractionTexture;
  62546. /**
  62547. * Serialize the texture to a JSON representation you could use in Parse later on
  62548. * @returns the serialized JSON representation
  62549. */
  62550. serialize(): any;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Block used to add support for vertex skinning (bones)
  62556. */
  62557. export class BonesBlock extends NodeMaterialBlock {
  62558. /**
  62559. * Creates a new BonesBlock
  62560. * @param name defines the block name
  62561. */
  62562. constructor(name: string);
  62563. /**
  62564. * Initialize the block and prepare the context for build
  62565. * @param state defines the state that will be used for the build
  62566. */
  62567. initialize(state: NodeMaterialBuildState): void;
  62568. /**
  62569. * Gets the current class name
  62570. * @returns the class name
  62571. */
  62572. getClassName(): string;
  62573. /**
  62574. * Gets the matrix indices input component
  62575. */
  62576. get matricesIndices(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the matrix weights input component
  62579. */
  62580. get matricesWeights(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the extra matrix indices input component
  62583. */
  62584. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62585. /**
  62586. * Gets the extra matrix weights input component
  62587. */
  62588. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the world input component
  62591. */
  62592. get world(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the output component
  62595. */
  62596. get output(): NodeMaterialConnectionPoint;
  62597. autoConfigure(material: NodeMaterial): void;
  62598. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62601. protected _buildBlock(state: NodeMaterialBuildState): this;
  62602. }
  62603. }
  62604. declare module BABYLON {
  62605. /**
  62606. * Block used to add support for instances
  62607. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62608. */
  62609. export class InstancesBlock extends NodeMaterialBlock {
  62610. /**
  62611. * Creates a new InstancesBlock
  62612. * @param name defines the block name
  62613. */
  62614. constructor(name: string);
  62615. /**
  62616. * Gets the current class name
  62617. * @returns the class name
  62618. */
  62619. getClassName(): string;
  62620. /**
  62621. * Gets the first world row input component
  62622. */
  62623. get world0(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the second world row input component
  62626. */
  62627. get world1(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the third world row input component
  62630. */
  62631. get world2(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the forth world row input component
  62634. */
  62635. get world3(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the world input component
  62638. */
  62639. get world(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the output component
  62642. */
  62643. get output(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the isntanceID component
  62646. */
  62647. get instanceID(): NodeMaterialConnectionPoint;
  62648. autoConfigure(material: NodeMaterial): void;
  62649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62650. protected _buildBlock(state: NodeMaterialBuildState): this;
  62651. }
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Block used to add morph targets support to vertex shader
  62656. */
  62657. export class MorphTargetsBlock extends NodeMaterialBlock {
  62658. private _repeatableContentAnchor;
  62659. /**
  62660. * Create a new MorphTargetsBlock
  62661. * @param name defines the block name
  62662. */
  62663. constructor(name: string);
  62664. /**
  62665. * Gets the current class name
  62666. * @returns the class name
  62667. */
  62668. getClassName(): string;
  62669. /**
  62670. * Gets the position input component
  62671. */
  62672. get position(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the normal input component
  62675. */
  62676. get normal(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the tangent input component
  62679. */
  62680. get tangent(): NodeMaterialConnectionPoint;
  62681. /**
  62682. * Gets the tangent input component
  62683. */
  62684. get uv(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the position output component
  62687. */
  62688. get positionOutput(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the normal output component
  62691. */
  62692. get normalOutput(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the tangent output component
  62695. */
  62696. get tangentOutput(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the tangent output component
  62699. */
  62700. get uvOutput(): NodeMaterialConnectionPoint;
  62701. initialize(state: NodeMaterialBuildState): void;
  62702. autoConfigure(material: NodeMaterial): void;
  62703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62705. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62706. protected _buildBlock(state: NodeMaterialBuildState): this;
  62707. }
  62708. }
  62709. declare module BABYLON {
  62710. /**
  62711. * Block used to get data information from a light
  62712. */
  62713. export class LightInformationBlock extends NodeMaterialBlock {
  62714. private _lightDataUniformName;
  62715. private _lightColorUniformName;
  62716. private _lightTypeDefineName;
  62717. /**
  62718. * Gets or sets the light associated with this block
  62719. */
  62720. light: Nullable<Light>;
  62721. /**
  62722. * Creates a new LightInformationBlock
  62723. * @param name defines the block name
  62724. */
  62725. constructor(name: string);
  62726. /**
  62727. * Gets the current class name
  62728. * @returns the class name
  62729. */
  62730. getClassName(): string;
  62731. /**
  62732. * Gets the world position input component
  62733. */
  62734. get worldPosition(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the direction output component
  62737. */
  62738. get direction(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the direction output component
  62741. */
  62742. get color(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the direction output component
  62745. */
  62746. get intensity(): NodeMaterialConnectionPoint;
  62747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62749. protected _buildBlock(state: NodeMaterialBuildState): this;
  62750. serialize(): any;
  62751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62752. }
  62753. }
  62754. declare module BABYLON {
  62755. /**
  62756. * Block used to add image processing support to fragment shader
  62757. */
  62758. export class ImageProcessingBlock extends NodeMaterialBlock {
  62759. /**
  62760. * Create a new ImageProcessingBlock
  62761. * @param name defines the block name
  62762. */
  62763. constructor(name: string);
  62764. /**
  62765. * Gets the current class name
  62766. * @returns the class name
  62767. */
  62768. getClassName(): string;
  62769. /**
  62770. * Gets the color input component
  62771. */
  62772. get color(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the output component
  62775. */
  62776. get output(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Initialize the block and prepare the context for build
  62779. * @param state defines the state that will be used for the build
  62780. */
  62781. initialize(state: NodeMaterialBuildState): void;
  62782. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62785. protected _buildBlock(state: NodeMaterialBuildState): this;
  62786. }
  62787. }
  62788. declare module BABYLON {
  62789. /**
  62790. * Block used to pertub normals based on a normal map
  62791. */
  62792. export class PerturbNormalBlock extends NodeMaterialBlock {
  62793. private _tangentSpaceParameterName;
  62794. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62795. invertX: boolean;
  62796. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62797. invertY: boolean;
  62798. /**
  62799. * Create a new PerturbNormalBlock
  62800. * @param name defines the block name
  62801. */
  62802. constructor(name: string);
  62803. /**
  62804. * Gets the current class name
  62805. * @returns the class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * Gets the world position input component
  62810. */
  62811. get worldPosition(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the world normal input component
  62814. */
  62815. get worldNormal(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the world tangent input component
  62818. */
  62819. get worldTangent(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the uv input component
  62822. */
  62823. get uv(): NodeMaterialConnectionPoint;
  62824. /**
  62825. * Gets the normal map color input component
  62826. */
  62827. get normalMapColor(): NodeMaterialConnectionPoint;
  62828. /**
  62829. * Gets the strength input component
  62830. */
  62831. get strength(): NodeMaterialConnectionPoint;
  62832. /**
  62833. * Gets the output component
  62834. */
  62835. get output(): NodeMaterialConnectionPoint;
  62836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62838. autoConfigure(material: NodeMaterial): void;
  62839. protected _buildBlock(state: NodeMaterialBuildState): this;
  62840. protected _dumpPropertiesCode(): string;
  62841. serialize(): any;
  62842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62843. }
  62844. }
  62845. declare module BABYLON {
  62846. /**
  62847. * Block used to discard a pixel if a value is smaller than a cutoff
  62848. */
  62849. export class DiscardBlock extends NodeMaterialBlock {
  62850. /**
  62851. * Create a new DiscardBlock
  62852. * @param name defines the block name
  62853. */
  62854. constructor(name: string);
  62855. /**
  62856. * Gets the current class name
  62857. * @returns the class name
  62858. */
  62859. getClassName(): string;
  62860. /**
  62861. * Gets the color input component
  62862. */
  62863. get value(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the cutoff input component
  62866. */
  62867. get cutoff(): NodeMaterialConnectionPoint;
  62868. protected _buildBlock(state: NodeMaterialBuildState): this;
  62869. }
  62870. }
  62871. declare module BABYLON {
  62872. /**
  62873. * Block used to test if the fragment shader is front facing
  62874. */
  62875. export class FrontFacingBlock extends NodeMaterialBlock {
  62876. /**
  62877. * Creates a new FrontFacingBlock
  62878. * @param name defines the block name
  62879. */
  62880. constructor(name: string);
  62881. /**
  62882. * Gets the current class name
  62883. * @returns the class name
  62884. */
  62885. getClassName(): string;
  62886. /**
  62887. * Gets the output component
  62888. */
  62889. get output(): NodeMaterialConnectionPoint;
  62890. protected _buildBlock(state: NodeMaterialBuildState): this;
  62891. }
  62892. }
  62893. declare module BABYLON {
  62894. /**
  62895. * Block used to get the derivative value on x and y of a given input
  62896. */
  62897. export class DerivativeBlock extends NodeMaterialBlock {
  62898. /**
  62899. * Create a new DerivativeBlock
  62900. * @param name defines the block name
  62901. */
  62902. constructor(name: string);
  62903. /**
  62904. * Gets the current class name
  62905. * @returns the class name
  62906. */
  62907. getClassName(): string;
  62908. /**
  62909. * Gets the input component
  62910. */
  62911. get input(): NodeMaterialConnectionPoint;
  62912. /**
  62913. * Gets the derivative output on x
  62914. */
  62915. get dx(): NodeMaterialConnectionPoint;
  62916. /**
  62917. * Gets the derivative output on y
  62918. */
  62919. get dy(): NodeMaterialConnectionPoint;
  62920. protected _buildBlock(state: NodeMaterialBuildState): this;
  62921. }
  62922. }
  62923. declare module BABYLON {
  62924. /**
  62925. * Block used to make gl_FragCoord available
  62926. */
  62927. export class FragCoordBlock extends NodeMaterialBlock {
  62928. /**
  62929. * Creates a new FragCoordBlock
  62930. * @param name defines the block name
  62931. */
  62932. constructor(name: string);
  62933. /**
  62934. * Gets the current class name
  62935. * @returns the class name
  62936. */
  62937. getClassName(): string;
  62938. /**
  62939. * Gets the xy component
  62940. */
  62941. get xy(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the xyz component
  62944. */
  62945. get xyz(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the xyzw component
  62948. */
  62949. get xyzw(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the x component
  62952. */
  62953. get x(): NodeMaterialConnectionPoint;
  62954. /**
  62955. * Gets the y component
  62956. */
  62957. get y(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the z component
  62960. */
  62961. get z(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the w component
  62964. */
  62965. get output(): NodeMaterialConnectionPoint;
  62966. protected writeOutputs(state: NodeMaterialBuildState): string;
  62967. protected _buildBlock(state: NodeMaterialBuildState): this;
  62968. }
  62969. }
  62970. declare module BABYLON {
  62971. /**
  62972. * Block used to get the screen sizes
  62973. */
  62974. export class ScreenSizeBlock extends NodeMaterialBlock {
  62975. private _varName;
  62976. private _scene;
  62977. /**
  62978. * Creates a new ScreenSizeBlock
  62979. * @param name defines the block name
  62980. */
  62981. constructor(name: string);
  62982. /**
  62983. * Gets the current class name
  62984. * @returns the class name
  62985. */
  62986. getClassName(): string;
  62987. /**
  62988. * Gets the xy component
  62989. */
  62990. get xy(): NodeMaterialConnectionPoint;
  62991. /**
  62992. * Gets the x component
  62993. */
  62994. get x(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the y component
  62997. */
  62998. get y(): NodeMaterialConnectionPoint;
  62999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63000. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module BABYLON {
  63005. /**
  63006. * Block used to add support for scene fog
  63007. */
  63008. export class FogBlock extends NodeMaterialBlock {
  63009. private _fogDistanceName;
  63010. private _fogParameters;
  63011. /**
  63012. * Create a new FogBlock
  63013. * @param name defines the block name
  63014. */
  63015. constructor(name: string);
  63016. /**
  63017. * Gets the current class name
  63018. * @returns the class name
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Gets the world position input component
  63023. */
  63024. get worldPosition(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the view input component
  63027. */
  63028. get view(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the color input component
  63031. */
  63032. get input(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the fog color input component
  63035. */
  63036. get fogColor(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the output component
  63039. */
  63040. get output(): NodeMaterialConnectionPoint;
  63041. autoConfigure(material: NodeMaterial): void;
  63042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63044. protected _buildBlock(state: NodeMaterialBuildState): this;
  63045. }
  63046. }
  63047. declare module BABYLON {
  63048. /**
  63049. * Block used to add light in the fragment shader
  63050. */
  63051. export class LightBlock extends NodeMaterialBlock {
  63052. private _lightId;
  63053. /**
  63054. * Gets or sets the light associated with this block
  63055. */
  63056. light: Nullable<Light>;
  63057. /**
  63058. * Create a new LightBlock
  63059. * @param name defines the block name
  63060. */
  63061. constructor(name: string);
  63062. /**
  63063. * Gets the current class name
  63064. * @returns the class name
  63065. */
  63066. getClassName(): string;
  63067. /**
  63068. * Gets the world position input component
  63069. */
  63070. get worldPosition(): NodeMaterialConnectionPoint;
  63071. /**
  63072. * Gets the world normal input component
  63073. */
  63074. get worldNormal(): NodeMaterialConnectionPoint;
  63075. /**
  63076. * Gets the camera (or eye) position component
  63077. */
  63078. get cameraPosition(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the glossiness component
  63081. */
  63082. get glossiness(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the glossinness power component
  63085. */
  63086. get glossPower(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the diffuse color component
  63089. */
  63090. get diffuseColor(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the specular color component
  63093. */
  63094. get specularColor(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the diffuse output component
  63097. */
  63098. get diffuseOutput(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the specular output component
  63101. */
  63102. get specularOutput(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the shadow output component
  63105. */
  63106. get shadow(): NodeMaterialConnectionPoint;
  63107. autoConfigure(material: NodeMaterial): void;
  63108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63109. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63111. private _injectVertexCode;
  63112. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63113. serialize(): any;
  63114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63115. }
  63116. }
  63117. declare module BABYLON {
  63118. /**
  63119. * Block used to read a reflection texture from a sampler
  63120. */
  63121. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63122. /**
  63123. * Create a new ReflectionTextureBlock
  63124. * @param name defines the block name
  63125. */
  63126. constructor(name: string);
  63127. /**
  63128. * Gets the current class name
  63129. * @returns the class name
  63130. */
  63131. getClassName(): string;
  63132. /**
  63133. * Gets the world position input component
  63134. */
  63135. get position(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the world position input component
  63138. */
  63139. get worldPosition(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the world normal input component
  63142. */
  63143. get worldNormal(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the world input component
  63146. */
  63147. get world(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the camera (or eye) position component
  63150. */
  63151. get cameraPosition(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the view input component
  63154. */
  63155. get view(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the rgb output component
  63158. */
  63159. get rgb(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the rgba output component
  63162. */
  63163. get rgba(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the r output component
  63166. */
  63167. get r(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the g output component
  63170. */
  63171. get g(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the b output component
  63174. */
  63175. get b(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the a output component
  63178. */
  63179. get a(): NodeMaterialConnectionPoint;
  63180. autoConfigure(material: NodeMaterial): void;
  63181. protected _buildBlock(state: NodeMaterialBuildState): this;
  63182. }
  63183. }
  63184. declare module BABYLON {
  63185. /**
  63186. * Block used to add 2 vectors
  63187. */
  63188. export class AddBlock extends NodeMaterialBlock {
  63189. /**
  63190. * Creates a new AddBlock
  63191. * @param name defines the block name
  63192. */
  63193. constructor(name: string);
  63194. /**
  63195. * Gets the current class name
  63196. * @returns the class name
  63197. */
  63198. getClassName(): string;
  63199. /**
  63200. * Gets the left operand input component
  63201. */
  63202. get left(): NodeMaterialConnectionPoint;
  63203. /**
  63204. * Gets the right operand input component
  63205. */
  63206. get right(): NodeMaterialConnectionPoint;
  63207. /**
  63208. * Gets the output component
  63209. */
  63210. get output(): NodeMaterialConnectionPoint;
  63211. protected _buildBlock(state: NodeMaterialBuildState): this;
  63212. }
  63213. }
  63214. declare module BABYLON {
  63215. /**
  63216. * Block used to scale a vector by a float
  63217. */
  63218. export class ScaleBlock extends NodeMaterialBlock {
  63219. /**
  63220. * Creates a new ScaleBlock
  63221. * @param name defines the block name
  63222. */
  63223. constructor(name: string);
  63224. /**
  63225. * Gets the current class name
  63226. * @returns the class name
  63227. */
  63228. getClassName(): string;
  63229. /**
  63230. * Gets the input component
  63231. */
  63232. get input(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the factor input component
  63235. */
  63236. get factor(): NodeMaterialConnectionPoint;
  63237. /**
  63238. * Gets the output component
  63239. */
  63240. get output(): NodeMaterialConnectionPoint;
  63241. protected _buildBlock(state: NodeMaterialBuildState): this;
  63242. }
  63243. }
  63244. declare module BABYLON {
  63245. /**
  63246. * Block used to clamp a float
  63247. */
  63248. export class ClampBlock extends NodeMaterialBlock {
  63249. /** Gets or sets the minimum range */
  63250. minimum: number;
  63251. /** Gets or sets the maximum range */
  63252. maximum: number;
  63253. /**
  63254. * Creates a new ClampBlock
  63255. * @param name defines the block name
  63256. */
  63257. constructor(name: string);
  63258. /**
  63259. * Gets the current class name
  63260. * @returns the class name
  63261. */
  63262. getClassName(): string;
  63263. /**
  63264. * Gets the value input component
  63265. */
  63266. get value(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the output component
  63269. */
  63270. get output(): NodeMaterialConnectionPoint;
  63271. protected _buildBlock(state: NodeMaterialBuildState): this;
  63272. protected _dumpPropertiesCode(): string;
  63273. serialize(): any;
  63274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63275. }
  63276. }
  63277. declare module BABYLON {
  63278. /**
  63279. * Block used to apply a cross product between 2 vectors
  63280. */
  63281. export class CrossBlock extends NodeMaterialBlock {
  63282. /**
  63283. * Creates a new CrossBlock
  63284. * @param name defines the block name
  63285. */
  63286. constructor(name: string);
  63287. /**
  63288. * Gets the current class name
  63289. * @returns the class name
  63290. */
  63291. getClassName(): string;
  63292. /**
  63293. * Gets the left operand input component
  63294. */
  63295. get left(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the right operand input component
  63298. */
  63299. get right(): NodeMaterialConnectionPoint;
  63300. /**
  63301. * Gets the output component
  63302. */
  63303. get output(): NodeMaterialConnectionPoint;
  63304. protected _buildBlock(state: NodeMaterialBuildState): this;
  63305. }
  63306. }
  63307. declare module BABYLON {
  63308. /**
  63309. * Block used to apply a dot product between 2 vectors
  63310. */
  63311. export class DotBlock extends NodeMaterialBlock {
  63312. /**
  63313. * Creates a new DotBlock
  63314. * @param name defines the block name
  63315. */
  63316. constructor(name: string);
  63317. /**
  63318. * Gets the current class name
  63319. * @returns the class name
  63320. */
  63321. getClassName(): string;
  63322. /**
  63323. * Gets the left operand input component
  63324. */
  63325. get left(): NodeMaterialConnectionPoint;
  63326. /**
  63327. * Gets the right operand input component
  63328. */
  63329. get right(): NodeMaterialConnectionPoint;
  63330. /**
  63331. * Gets the output component
  63332. */
  63333. get output(): NodeMaterialConnectionPoint;
  63334. protected _buildBlock(state: NodeMaterialBuildState): this;
  63335. }
  63336. }
  63337. declare module BABYLON {
  63338. /**
  63339. * Block used to normalize a vector
  63340. */
  63341. export class NormalizeBlock extends NodeMaterialBlock {
  63342. /**
  63343. * Creates a new NormalizeBlock
  63344. * @param name defines the block name
  63345. */
  63346. constructor(name: string);
  63347. /**
  63348. * Gets the current class name
  63349. * @returns the class name
  63350. */
  63351. getClassName(): string;
  63352. /**
  63353. * Gets the input component
  63354. */
  63355. get input(): NodeMaterialConnectionPoint;
  63356. /**
  63357. * Gets the output component
  63358. */
  63359. get output(): NodeMaterialConnectionPoint;
  63360. protected _buildBlock(state: NodeMaterialBuildState): this;
  63361. }
  63362. }
  63363. declare module BABYLON {
  63364. /**
  63365. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63366. */
  63367. export class ColorMergerBlock extends NodeMaterialBlock {
  63368. /**
  63369. * Create a new ColorMergerBlock
  63370. * @param name defines the block name
  63371. */
  63372. constructor(name: string);
  63373. /**
  63374. * Gets the current class name
  63375. * @returns the class name
  63376. */
  63377. getClassName(): string;
  63378. /**
  63379. * Gets the rgb component (input)
  63380. */
  63381. get rgbIn(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the r component (input)
  63384. */
  63385. get r(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the g component (input)
  63388. */
  63389. get g(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the b component (input)
  63392. */
  63393. get b(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the a component (input)
  63396. */
  63397. get a(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the rgba component (output)
  63400. */
  63401. get rgba(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the rgb component (output)
  63404. */
  63405. get rgbOut(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the rgb component (output)
  63408. * @deprecated Please use rgbOut instead.
  63409. */
  63410. get rgb(): NodeMaterialConnectionPoint;
  63411. protected _buildBlock(state: NodeMaterialBuildState): this;
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /**
  63416. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63417. */
  63418. export class VectorSplitterBlock extends NodeMaterialBlock {
  63419. /**
  63420. * Create a new VectorSplitterBlock
  63421. * @param name defines the block name
  63422. */
  63423. constructor(name: string);
  63424. /**
  63425. * Gets the current class name
  63426. * @returns the class name
  63427. */
  63428. getClassName(): string;
  63429. /**
  63430. * Gets the xyzw component (input)
  63431. */
  63432. get xyzw(): NodeMaterialConnectionPoint;
  63433. /**
  63434. * Gets the xyz component (input)
  63435. */
  63436. get xyzIn(): NodeMaterialConnectionPoint;
  63437. /**
  63438. * Gets the xy component (input)
  63439. */
  63440. get xyIn(): NodeMaterialConnectionPoint;
  63441. /**
  63442. * Gets the xyz component (output)
  63443. */
  63444. get xyzOut(): NodeMaterialConnectionPoint;
  63445. /**
  63446. * Gets the xy component (output)
  63447. */
  63448. get xyOut(): NodeMaterialConnectionPoint;
  63449. /**
  63450. * Gets the x component (output)
  63451. */
  63452. get x(): NodeMaterialConnectionPoint;
  63453. /**
  63454. * Gets the y component (output)
  63455. */
  63456. get y(): NodeMaterialConnectionPoint;
  63457. /**
  63458. * Gets the z component (output)
  63459. */
  63460. get z(): NodeMaterialConnectionPoint;
  63461. /**
  63462. * Gets the w component (output)
  63463. */
  63464. get w(): NodeMaterialConnectionPoint;
  63465. protected _inputRename(name: string): string;
  63466. protected _outputRename(name: string): string;
  63467. protected _buildBlock(state: NodeMaterialBuildState): this;
  63468. }
  63469. }
  63470. declare module BABYLON {
  63471. /**
  63472. * Block used to lerp between 2 values
  63473. */
  63474. export class LerpBlock extends NodeMaterialBlock {
  63475. /**
  63476. * Creates a new LerpBlock
  63477. * @param name defines the block name
  63478. */
  63479. constructor(name: string);
  63480. /**
  63481. * Gets the current class name
  63482. * @returns the class name
  63483. */
  63484. getClassName(): string;
  63485. /**
  63486. * Gets the left operand input component
  63487. */
  63488. get left(): NodeMaterialConnectionPoint;
  63489. /**
  63490. * Gets the right operand input component
  63491. */
  63492. get right(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the gradient operand input component
  63495. */
  63496. get gradient(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the output component
  63499. */
  63500. get output(): NodeMaterialConnectionPoint;
  63501. protected _buildBlock(state: NodeMaterialBuildState): this;
  63502. }
  63503. }
  63504. declare module BABYLON {
  63505. /**
  63506. * Block used to divide 2 vectors
  63507. */
  63508. export class DivideBlock extends NodeMaterialBlock {
  63509. /**
  63510. * Creates a new DivideBlock
  63511. * @param name defines the block name
  63512. */
  63513. constructor(name: string);
  63514. /**
  63515. * Gets the current class name
  63516. * @returns the class name
  63517. */
  63518. getClassName(): string;
  63519. /**
  63520. * Gets the left operand input component
  63521. */
  63522. get left(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the right operand input component
  63525. */
  63526. get right(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the output component
  63529. */
  63530. get output(): NodeMaterialConnectionPoint;
  63531. protected _buildBlock(state: NodeMaterialBuildState): this;
  63532. }
  63533. }
  63534. declare module BABYLON {
  63535. /**
  63536. * Block used to subtract 2 vectors
  63537. */
  63538. export class SubtractBlock extends NodeMaterialBlock {
  63539. /**
  63540. * Creates a new SubtractBlock
  63541. * @param name defines the block name
  63542. */
  63543. constructor(name: string);
  63544. /**
  63545. * Gets the current class name
  63546. * @returns the class name
  63547. */
  63548. getClassName(): string;
  63549. /**
  63550. * Gets the left operand input component
  63551. */
  63552. get left(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the right operand input component
  63555. */
  63556. get right(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the output component
  63559. */
  63560. get output(): NodeMaterialConnectionPoint;
  63561. protected _buildBlock(state: NodeMaterialBuildState): this;
  63562. }
  63563. }
  63564. declare module BABYLON {
  63565. /**
  63566. * Block used to step a value
  63567. */
  63568. export class StepBlock extends NodeMaterialBlock {
  63569. /**
  63570. * Creates a new StepBlock
  63571. * @param name defines the block name
  63572. */
  63573. constructor(name: string);
  63574. /**
  63575. * Gets the current class name
  63576. * @returns the class name
  63577. */
  63578. getClassName(): string;
  63579. /**
  63580. * Gets the value operand input component
  63581. */
  63582. get value(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the edge operand input component
  63585. */
  63586. get edge(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the output component
  63589. */
  63590. get output(): NodeMaterialConnectionPoint;
  63591. protected _buildBlock(state: NodeMaterialBuildState): this;
  63592. }
  63593. }
  63594. declare module BABYLON {
  63595. /**
  63596. * Block used to get the opposite (1 - x) of a value
  63597. */
  63598. export class OneMinusBlock extends NodeMaterialBlock {
  63599. /**
  63600. * Creates a new OneMinusBlock
  63601. * @param name defines the block name
  63602. */
  63603. constructor(name: string);
  63604. /**
  63605. * Gets the current class name
  63606. * @returns the class name
  63607. */
  63608. getClassName(): string;
  63609. /**
  63610. * Gets the input component
  63611. */
  63612. get input(): NodeMaterialConnectionPoint;
  63613. /**
  63614. * Gets the output component
  63615. */
  63616. get output(): NodeMaterialConnectionPoint;
  63617. protected _buildBlock(state: NodeMaterialBuildState): this;
  63618. }
  63619. }
  63620. declare module BABYLON {
  63621. /**
  63622. * Block used to get the view direction
  63623. */
  63624. export class ViewDirectionBlock extends NodeMaterialBlock {
  63625. /**
  63626. * Creates a new ViewDirectionBlock
  63627. * @param name defines the block name
  63628. */
  63629. constructor(name: string);
  63630. /**
  63631. * Gets the current class name
  63632. * @returns the class name
  63633. */
  63634. getClassName(): string;
  63635. /**
  63636. * Gets the world position component
  63637. */
  63638. get worldPosition(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the camera position component
  63641. */
  63642. get cameraPosition(): NodeMaterialConnectionPoint;
  63643. /**
  63644. * Gets the output component
  63645. */
  63646. get output(): NodeMaterialConnectionPoint;
  63647. autoConfigure(material: NodeMaterial): void;
  63648. protected _buildBlock(state: NodeMaterialBuildState): this;
  63649. }
  63650. }
  63651. declare module BABYLON {
  63652. /**
  63653. * Block used to compute fresnel value
  63654. */
  63655. export class FresnelBlock extends NodeMaterialBlock {
  63656. /**
  63657. * Create a new FresnelBlock
  63658. * @param name defines the block name
  63659. */
  63660. constructor(name: string);
  63661. /**
  63662. * Gets the current class name
  63663. * @returns the class name
  63664. */
  63665. getClassName(): string;
  63666. /**
  63667. * Gets the world normal input component
  63668. */
  63669. get worldNormal(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the view direction input component
  63672. */
  63673. get viewDirection(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the bias input component
  63676. */
  63677. get bias(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the camera (or eye) position component
  63680. */
  63681. get power(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the fresnel output component
  63684. */
  63685. get fresnel(): NodeMaterialConnectionPoint;
  63686. autoConfigure(material: NodeMaterial): void;
  63687. protected _buildBlock(state: NodeMaterialBuildState): this;
  63688. }
  63689. }
  63690. declare module BABYLON {
  63691. /**
  63692. * Block used to get the max of 2 values
  63693. */
  63694. export class MaxBlock extends NodeMaterialBlock {
  63695. /**
  63696. * Creates a new MaxBlock
  63697. * @param name defines the block name
  63698. */
  63699. constructor(name: string);
  63700. /**
  63701. * Gets the current class name
  63702. * @returns the class name
  63703. */
  63704. getClassName(): string;
  63705. /**
  63706. * Gets the left operand input component
  63707. */
  63708. get left(): NodeMaterialConnectionPoint;
  63709. /**
  63710. * Gets the right operand input component
  63711. */
  63712. get right(): NodeMaterialConnectionPoint;
  63713. /**
  63714. * Gets the output component
  63715. */
  63716. get output(): NodeMaterialConnectionPoint;
  63717. protected _buildBlock(state: NodeMaterialBuildState): this;
  63718. }
  63719. }
  63720. declare module BABYLON {
  63721. /**
  63722. * Block used to get the min of 2 values
  63723. */
  63724. export class MinBlock extends NodeMaterialBlock {
  63725. /**
  63726. * Creates a new MinBlock
  63727. * @param name defines the block name
  63728. */
  63729. constructor(name: string);
  63730. /**
  63731. * Gets the current class name
  63732. * @returns the class name
  63733. */
  63734. getClassName(): string;
  63735. /**
  63736. * Gets the left operand input component
  63737. */
  63738. get left(): NodeMaterialConnectionPoint;
  63739. /**
  63740. * Gets the right operand input component
  63741. */
  63742. get right(): NodeMaterialConnectionPoint;
  63743. /**
  63744. * Gets the output component
  63745. */
  63746. get output(): NodeMaterialConnectionPoint;
  63747. protected _buildBlock(state: NodeMaterialBuildState): this;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /**
  63752. * Block used to get the distance between 2 values
  63753. */
  63754. export class DistanceBlock extends NodeMaterialBlock {
  63755. /**
  63756. * Creates a new DistanceBlock
  63757. * @param name defines the block name
  63758. */
  63759. constructor(name: string);
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the left operand input component
  63767. */
  63768. get left(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the right operand input component
  63771. */
  63772. get right(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the output component
  63775. */
  63776. get output(): NodeMaterialConnectionPoint;
  63777. protected _buildBlock(state: NodeMaterialBuildState): this;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * Block used to get the length of a vector
  63783. */
  63784. export class LengthBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Creates a new LengthBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the value input component
  63797. */
  63798. get value(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the output component
  63801. */
  63802. get output(): NodeMaterialConnectionPoint;
  63803. protected _buildBlock(state: NodeMaterialBuildState): this;
  63804. }
  63805. }
  63806. declare module BABYLON {
  63807. /**
  63808. * Block used to get negative version of a value (i.e. x * -1)
  63809. */
  63810. export class NegateBlock extends NodeMaterialBlock {
  63811. /**
  63812. * Creates a new NegateBlock
  63813. * @param name defines the block name
  63814. */
  63815. constructor(name: string);
  63816. /**
  63817. * Gets the current class name
  63818. * @returns the class name
  63819. */
  63820. getClassName(): string;
  63821. /**
  63822. * Gets the value input component
  63823. */
  63824. get value(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the output component
  63827. */
  63828. get output(): NodeMaterialConnectionPoint;
  63829. protected _buildBlock(state: NodeMaterialBuildState): this;
  63830. }
  63831. }
  63832. declare module BABYLON {
  63833. /**
  63834. * Block used to get the value of the first parameter raised to the power of the second
  63835. */
  63836. export class PowBlock extends NodeMaterialBlock {
  63837. /**
  63838. * Creates a new PowBlock
  63839. * @param name defines the block name
  63840. */
  63841. constructor(name: string);
  63842. /**
  63843. * Gets the current class name
  63844. * @returns the class name
  63845. */
  63846. getClassName(): string;
  63847. /**
  63848. * Gets the value operand input component
  63849. */
  63850. get value(): NodeMaterialConnectionPoint;
  63851. /**
  63852. * Gets the power operand input component
  63853. */
  63854. get power(): NodeMaterialConnectionPoint;
  63855. /**
  63856. * Gets the output component
  63857. */
  63858. get output(): NodeMaterialConnectionPoint;
  63859. protected _buildBlock(state: NodeMaterialBuildState): this;
  63860. }
  63861. }
  63862. declare module BABYLON {
  63863. /**
  63864. * Block used to get a random number
  63865. */
  63866. export class RandomNumberBlock extends NodeMaterialBlock {
  63867. /**
  63868. * Creates a new RandomNumberBlock
  63869. * @param name defines the block name
  63870. */
  63871. constructor(name: string);
  63872. /**
  63873. * Gets the current class name
  63874. * @returns the class name
  63875. */
  63876. getClassName(): string;
  63877. /**
  63878. * Gets the seed input component
  63879. */
  63880. get seed(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the output component
  63883. */
  63884. get output(): NodeMaterialConnectionPoint;
  63885. protected _buildBlock(state: NodeMaterialBuildState): this;
  63886. }
  63887. }
  63888. declare module BABYLON {
  63889. /**
  63890. * Block used to compute arc tangent of 2 values
  63891. */
  63892. export class ArcTan2Block extends NodeMaterialBlock {
  63893. /**
  63894. * Creates a new ArcTan2Block
  63895. * @param name defines the block name
  63896. */
  63897. constructor(name: string);
  63898. /**
  63899. * Gets the current class name
  63900. * @returns the class name
  63901. */
  63902. getClassName(): string;
  63903. /**
  63904. * Gets the x operand input component
  63905. */
  63906. get x(): NodeMaterialConnectionPoint;
  63907. /**
  63908. * Gets the y operand input component
  63909. */
  63910. get y(): NodeMaterialConnectionPoint;
  63911. /**
  63912. * Gets the output component
  63913. */
  63914. get output(): NodeMaterialConnectionPoint;
  63915. protected _buildBlock(state: NodeMaterialBuildState): this;
  63916. }
  63917. }
  63918. declare module BABYLON {
  63919. /**
  63920. * Block used to smooth step a value
  63921. */
  63922. export class SmoothStepBlock extends NodeMaterialBlock {
  63923. /**
  63924. * Creates a new SmoothStepBlock
  63925. * @param name defines the block name
  63926. */
  63927. constructor(name: string);
  63928. /**
  63929. * Gets the current class name
  63930. * @returns the class name
  63931. */
  63932. getClassName(): string;
  63933. /**
  63934. * Gets the value operand input component
  63935. */
  63936. get value(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the first edge operand input component
  63939. */
  63940. get edge0(): NodeMaterialConnectionPoint;
  63941. /**
  63942. * Gets the second edge operand input component
  63943. */
  63944. get edge1(): NodeMaterialConnectionPoint;
  63945. /**
  63946. * Gets the output component
  63947. */
  63948. get output(): NodeMaterialConnectionPoint;
  63949. protected _buildBlock(state: NodeMaterialBuildState): this;
  63950. }
  63951. }
  63952. declare module BABYLON {
  63953. /**
  63954. * Block used to get the reciprocal (1 / x) of a value
  63955. */
  63956. export class ReciprocalBlock extends NodeMaterialBlock {
  63957. /**
  63958. * Creates a new ReciprocalBlock
  63959. * @param name defines the block name
  63960. */
  63961. constructor(name: string);
  63962. /**
  63963. * Gets the current class name
  63964. * @returns the class name
  63965. */
  63966. getClassName(): string;
  63967. /**
  63968. * Gets the input component
  63969. */
  63970. get input(): NodeMaterialConnectionPoint;
  63971. /**
  63972. * Gets the output component
  63973. */
  63974. get output(): NodeMaterialConnectionPoint;
  63975. protected _buildBlock(state: NodeMaterialBuildState): this;
  63976. }
  63977. }
  63978. declare module BABYLON {
  63979. /**
  63980. * Block used to replace a color by another one
  63981. */
  63982. export class ReplaceColorBlock extends NodeMaterialBlock {
  63983. /**
  63984. * Creates a new ReplaceColorBlock
  63985. * @param name defines the block name
  63986. */
  63987. constructor(name: string);
  63988. /**
  63989. * Gets the current class name
  63990. * @returns the class name
  63991. */
  63992. getClassName(): string;
  63993. /**
  63994. * Gets the value input component
  63995. */
  63996. get value(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the reference input component
  63999. */
  64000. get reference(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the distance input component
  64003. */
  64004. get distance(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the replacement input component
  64007. */
  64008. get replacement(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the output component
  64011. */
  64012. get output(): NodeMaterialConnectionPoint;
  64013. protected _buildBlock(state: NodeMaterialBuildState): this;
  64014. }
  64015. }
  64016. declare module BABYLON {
  64017. /**
  64018. * Block used to posterize a value
  64019. * @see https://en.wikipedia.org/wiki/Posterization
  64020. */
  64021. export class PosterizeBlock extends NodeMaterialBlock {
  64022. /**
  64023. * Creates a new PosterizeBlock
  64024. * @param name defines the block name
  64025. */
  64026. constructor(name: string);
  64027. /**
  64028. * Gets the current class name
  64029. * @returns the class name
  64030. */
  64031. getClassName(): string;
  64032. /**
  64033. * Gets the value input component
  64034. */
  64035. get value(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the steps input component
  64038. */
  64039. get steps(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the output component
  64042. */
  64043. get output(): NodeMaterialConnectionPoint;
  64044. protected _buildBlock(state: NodeMaterialBuildState): this;
  64045. }
  64046. }
  64047. declare module BABYLON {
  64048. /**
  64049. * Operations supported by the Wave block
  64050. */
  64051. export enum WaveBlockKind {
  64052. /** SawTooth */
  64053. SawTooth = 0,
  64054. /** Square */
  64055. Square = 1,
  64056. /** Triangle */
  64057. Triangle = 2
  64058. }
  64059. /**
  64060. * Block used to apply wave operation to floats
  64061. */
  64062. export class WaveBlock extends NodeMaterialBlock {
  64063. /**
  64064. * Gets or sets the kibnd of wave to be applied by the block
  64065. */
  64066. kind: WaveBlockKind;
  64067. /**
  64068. * Creates a new WaveBlock
  64069. * @param name defines the block name
  64070. */
  64071. constructor(name: string);
  64072. /**
  64073. * Gets the current class name
  64074. * @returns the class name
  64075. */
  64076. getClassName(): string;
  64077. /**
  64078. * Gets the input component
  64079. */
  64080. get input(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the output component
  64083. */
  64084. get output(): NodeMaterialConnectionPoint;
  64085. protected _buildBlock(state: NodeMaterialBuildState): this;
  64086. serialize(): any;
  64087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64088. }
  64089. }
  64090. declare module BABYLON {
  64091. /**
  64092. * Class used to store a color step for the GradientBlock
  64093. */
  64094. export class GradientBlockColorStep {
  64095. private _step;
  64096. /**
  64097. * Gets value indicating which step this color is associated with (between 0 and 1)
  64098. */
  64099. get step(): number;
  64100. /**
  64101. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64102. */
  64103. set step(val: number);
  64104. private _color;
  64105. /**
  64106. * Gets the color associated with this step
  64107. */
  64108. get color(): Color3;
  64109. /**
  64110. * Sets the color associated with this step
  64111. */
  64112. set color(val: Color3);
  64113. /**
  64114. * Creates a new GradientBlockColorStep
  64115. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64116. * @param color defines the color associated with this step
  64117. */
  64118. constructor(step: number, color: Color3);
  64119. }
  64120. /**
  64121. * Block used to return a color from a gradient based on an input value between 0 and 1
  64122. */
  64123. export class GradientBlock extends NodeMaterialBlock {
  64124. /**
  64125. * Gets or sets the list of color steps
  64126. */
  64127. colorSteps: GradientBlockColorStep[];
  64128. /** Gets an observable raised when the value is changed */
  64129. onValueChangedObservable: Observable<GradientBlock>;
  64130. /** calls observable when the value is changed*/
  64131. colorStepsUpdated(): void;
  64132. /**
  64133. * Creates a new GradientBlock
  64134. * @param name defines the block name
  64135. */
  64136. constructor(name: string);
  64137. /**
  64138. * Gets the current class name
  64139. * @returns the class name
  64140. */
  64141. getClassName(): string;
  64142. /**
  64143. * Gets the gradient input component
  64144. */
  64145. get gradient(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the output component
  64148. */
  64149. get output(): NodeMaterialConnectionPoint;
  64150. private _writeColorConstant;
  64151. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64152. serialize(): any;
  64153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64154. protected _dumpPropertiesCode(): string;
  64155. }
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * Block used to normalize lerp between 2 values
  64160. */
  64161. export class NLerpBlock extends NodeMaterialBlock {
  64162. /**
  64163. * Creates a new NLerpBlock
  64164. * @param name defines the block name
  64165. */
  64166. constructor(name: string);
  64167. /**
  64168. * Gets the current class name
  64169. * @returns the class name
  64170. */
  64171. getClassName(): string;
  64172. /**
  64173. * Gets the left operand input component
  64174. */
  64175. get left(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the right operand input component
  64178. */
  64179. get right(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the gradient operand input component
  64182. */
  64183. get gradient(): NodeMaterialConnectionPoint;
  64184. /**
  64185. * Gets the output component
  64186. */
  64187. get output(): NodeMaterialConnectionPoint;
  64188. protected _buildBlock(state: NodeMaterialBuildState): this;
  64189. }
  64190. }
  64191. declare module BABYLON {
  64192. /**
  64193. * block used to Generate a Worley Noise 3D Noise Pattern
  64194. */
  64195. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64196. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64197. manhattanDistance: boolean;
  64198. /**
  64199. * Creates a new WorleyNoise3DBlock
  64200. * @param name defines the block name
  64201. */
  64202. constructor(name: string);
  64203. /**
  64204. * Gets the current class name
  64205. * @returns the class name
  64206. */
  64207. getClassName(): string;
  64208. /**
  64209. * Gets the seed input component
  64210. */
  64211. get seed(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Gets the jitter input component
  64214. */
  64215. get jitter(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the output component
  64218. */
  64219. get output(): NodeMaterialConnectionPoint;
  64220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64221. /**
  64222. * Exposes the properties to the UI?
  64223. */
  64224. protected _dumpPropertiesCode(): string;
  64225. /**
  64226. * Exposes the properties to the Seralize?
  64227. */
  64228. serialize(): any;
  64229. /**
  64230. * Exposes the properties to the deseralize?
  64231. */
  64232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64233. }
  64234. }
  64235. declare module BABYLON {
  64236. /**
  64237. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64238. */
  64239. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64240. /**
  64241. * Creates a new SimplexPerlin3DBlock
  64242. * @param name defines the block name
  64243. */
  64244. constructor(name: string);
  64245. /**
  64246. * Gets the current class name
  64247. * @returns the class name
  64248. */
  64249. getClassName(): string;
  64250. /**
  64251. * Gets the seed operand input component
  64252. */
  64253. get seed(): NodeMaterialConnectionPoint;
  64254. /**
  64255. * Gets the output component
  64256. */
  64257. get output(): NodeMaterialConnectionPoint;
  64258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64259. }
  64260. }
  64261. declare module BABYLON {
  64262. /**
  64263. * Block used to blend normals
  64264. */
  64265. export class NormalBlendBlock extends NodeMaterialBlock {
  64266. /**
  64267. * Creates a new NormalBlendBlock
  64268. * @param name defines the block name
  64269. */
  64270. constructor(name: string);
  64271. /**
  64272. * Gets the current class name
  64273. * @returns the class name
  64274. */
  64275. getClassName(): string;
  64276. /**
  64277. * Gets the first input component
  64278. */
  64279. get normalMap0(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the second input component
  64282. */
  64283. get normalMap1(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the output component
  64286. */
  64287. get output(): NodeMaterialConnectionPoint;
  64288. protected _buildBlock(state: NodeMaterialBuildState): this;
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /**
  64293. * Block used to rotate a 2d vector by a given angle
  64294. */
  64295. export class Rotate2dBlock extends NodeMaterialBlock {
  64296. /**
  64297. * Creates a new Rotate2dBlock
  64298. * @param name defines the block name
  64299. */
  64300. constructor(name: string);
  64301. /**
  64302. * Gets the current class name
  64303. * @returns the class name
  64304. */
  64305. getClassName(): string;
  64306. /**
  64307. * Gets the input vector
  64308. */
  64309. get input(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the input angle
  64312. */
  64313. get angle(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the output component
  64316. */
  64317. get output(): NodeMaterialConnectionPoint;
  64318. autoConfigure(material: NodeMaterial): void;
  64319. protected _buildBlock(state: NodeMaterialBuildState): this;
  64320. }
  64321. }
  64322. declare module BABYLON {
  64323. /**
  64324. * Block used to get the reflected vector from a direction and a normal
  64325. */
  64326. export class ReflectBlock extends NodeMaterialBlock {
  64327. /**
  64328. * Creates a new ReflectBlock
  64329. * @param name defines the block name
  64330. */
  64331. constructor(name: string);
  64332. /**
  64333. * Gets the current class name
  64334. * @returns the class name
  64335. */
  64336. getClassName(): string;
  64337. /**
  64338. * Gets the incident component
  64339. */
  64340. get incident(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the normal component
  64343. */
  64344. get normal(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the output component
  64347. */
  64348. get output(): NodeMaterialConnectionPoint;
  64349. protected _buildBlock(state: NodeMaterialBuildState): this;
  64350. }
  64351. }
  64352. declare module BABYLON {
  64353. /**
  64354. * Block used to get the refracted vector from a direction and a normal
  64355. */
  64356. export class RefractBlock extends NodeMaterialBlock {
  64357. /**
  64358. * Creates a new RefractBlock
  64359. * @param name defines the block name
  64360. */
  64361. constructor(name: string);
  64362. /**
  64363. * Gets the current class name
  64364. * @returns the class name
  64365. */
  64366. getClassName(): string;
  64367. /**
  64368. * Gets the incident component
  64369. */
  64370. get incident(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the normal component
  64373. */
  64374. get normal(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the index of refraction component
  64377. */
  64378. get ior(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the output component
  64381. */
  64382. get output(): NodeMaterialConnectionPoint;
  64383. protected _buildBlock(state: NodeMaterialBuildState): this;
  64384. }
  64385. }
  64386. declare module BABYLON {
  64387. /**
  64388. * Block used to desaturate a color
  64389. */
  64390. export class DesaturateBlock extends NodeMaterialBlock {
  64391. /**
  64392. * Creates a new DesaturateBlock
  64393. * @param name defines the block name
  64394. */
  64395. constructor(name: string);
  64396. /**
  64397. * Gets the current class name
  64398. * @returns the class name
  64399. */
  64400. getClassName(): string;
  64401. /**
  64402. * Gets the color operand input component
  64403. */
  64404. get color(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the level operand input component
  64407. */
  64408. get level(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the output component
  64411. */
  64412. get output(): NodeMaterialConnectionPoint;
  64413. protected _buildBlock(state: NodeMaterialBuildState): this;
  64414. }
  64415. }
  64416. declare module BABYLON {
  64417. /**
  64418. * Block used to implement the ambient occlusion module of the PBR material
  64419. */
  64420. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64421. /**
  64422. * Create a new AmbientOcclusionBlock
  64423. * @param name defines the block name
  64424. */
  64425. constructor(name: string);
  64426. /**
  64427. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64428. */
  64429. useAmbientInGrayScale: boolean;
  64430. /**
  64431. * Initialize the block and prepare the context for build
  64432. * @param state defines the state that will be used for the build
  64433. */
  64434. initialize(state: NodeMaterialBuildState): void;
  64435. /**
  64436. * Gets the current class name
  64437. * @returns the class name
  64438. */
  64439. getClassName(): string;
  64440. /**
  64441. * Gets the texture input component
  64442. */
  64443. get texture(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the texture intensity component
  64446. */
  64447. get intensity(): NodeMaterialConnectionPoint;
  64448. /**
  64449. * Gets the direct light intensity input component
  64450. */
  64451. get directLightIntensity(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the ambient occlusion object output component
  64454. */
  64455. get ambientOcc(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the main code of the block (fragment side)
  64458. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64459. * @returns the shader code
  64460. */
  64461. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64463. protected _buildBlock(state: NodeMaterialBuildState): this;
  64464. protected _dumpPropertiesCode(): string;
  64465. serialize(): any;
  64466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /**
  64471. * Block used to implement the reflection module of the PBR material
  64472. */
  64473. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64474. /** @hidden */
  64475. _defineLODReflectionAlpha: string;
  64476. /** @hidden */
  64477. _defineLinearSpecularReflection: string;
  64478. private _vEnvironmentIrradianceName;
  64479. /** @hidden */
  64480. _vReflectionMicrosurfaceInfosName: string;
  64481. /** @hidden */
  64482. _vReflectionInfosName: string;
  64483. /** @hidden */
  64484. _vReflectionFilteringInfoName: string;
  64485. private _scene;
  64486. /**
  64487. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64488. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64489. * It's less burden on the user side in the editor part.
  64490. */
  64491. /** @hidden */
  64492. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64493. /** @hidden */
  64494. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64495. /** @hidden */
  64496. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64497. /**
  64498. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64499. * diffuse part of the IBL.
  64500. */
  64501. useSphericalHarmonics: boolean;
  64502. /**
  64503. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64504. */
  64505. forceIrradianceInFragment: boolean;
  64506. /**
  64507. * Create a new ReflectionBlock
  64508. * @param name defines the block name
  64509. */
  64510. constructor(name: string);
  64511. /**
  64512. * Gets the current class name
  64513. * @returns the class name
  64514. */
  64515. getClassName(): string;
  64516. /**
  64517. * Gets the position input component
  64518. */
  64519. get position(): NodeMaterialConnectionPoint;
  64520. /**
  64521. * Gets the world position input component
  64522. */
  64523. get worldPosition(): NodeMaterialConnectionPoint;
  64524. /**
  64525. * Gets the world normal input component
  64526. */
  64527. get worldNormal(): NodeMaterialConnectionPoint;
  64528. /**
  64529. * Gets the world input component
  64530. */
  64531. get world(): NodeMaterialConnectionPoint;
  64532. /**
  64533. * Gets the camera (or eye) position component
  64534. */
  64535. get cameraPosition(): NodeMaterialConnectionPoint;
  64536. /**
  64537. * Gets the view input component
  64538. */
  64539. get view(): NodeMaterialConnectionPoint;
  64540. /**
  64541. * Gets the color input component
  64542. */
  64543. get color(): NodeMaterialConnectionPoint;
  64544. /**
  64545. * Gets the reflection object output component
  64546. */
  64547. get reflection(): NodeMaterialConnectionPoint;
  64548. /**
  64549. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64550. */
  64551. get hasTexture(): boolean;
  64552. /**
  64553. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64554. */
  64555. get reflectionColor(): string;
  64556. protected _getTexture(): Nullable<BaseTexture>;
  64557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64559. /**
  64560. * Gets the code to inject in the vertex shader
  64561. * @param state current state of the node material building
  64562. * @returns the shader code
  64563. */
  64564. handleVertexSide(state: NodeMaterialBuildState): string;
  64565. /**
  64566. * Gets the main code of the block (fragment side)
  64567. * @param state current state of the node material building
  64568. * @param normalVarName name of the existing variable corresponding to the normal
  64569. * @returns the shader code
  64570. */
  64571. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64572. protected _buildBlock(state: NodeMaterialBuildState): this;
  64573. protected _dumpPropertiesCode(): string;
  64574. serialize(): any;
  64575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64576. }
  64577. }
  64578. declare module BABYLON {
  64579. /**
  64580. * Block used to implement the sheen module of the PBR material
  64581. */
  64582. export class SheenBlock extends NodeMaterialBlock {
  64583. /**
  64584. * Create a new SheenBlock
  64585. * @param name defines the block name
  64586. */
  64587. constructor(name: string);
  64588. /**
  64589. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64590. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64591. * making it easier to setup and tweak the effect
  64592. */
  64593. albedoScaling: boolean;
  64594. /**
  64595. * Defines if the sheen is linked to the sheen color.
  64596. */
  64597. linkSheenWithAlbedo: boolean;
  64598. /**
  64599. * Initialize the block and prepare the context for build
  64600. * @param state defines the state that will be used for the build
  64601. */
  64602. initialize(state: NodeMaterialBuildState): void;
  64603. /**
  64604. * Gets the current class name
  64605. * @returns the class name
  64606. */
  64607. getClassName(): string;
  64608. /**
  64609. * Gets the intensity input component
  64610. */
  64611. get intensity(): NodeMaterialConnectionPoint;
  64612. /**
  64613. * Gets the color input component
  64614. */
  64615. get color(): NodeMaterialConnectionPoint;
  64616. /**
  64617. * Gets the roughness input component
  64618. */
  64619. get roughness(): NodeMaterialConnectionPoint;
  64620. /**
  64621. * Gets the sheen object output component
  64622. */
  64623. get sheen(): NodeMaterialConnectionPoint;
  64624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64625. /**
  64626. * Gets the main code of the block (fragment side)
  64627. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64628. * @returns the shader code
  64629. */
  64630. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64631. protected _buildBlock(state: NodeMaterialBuildState): this;
  64632. protected _dumpPropertiesCode(): string;
  64633. serialize(): any;
  64634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64635. }
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * Block used to implement the reflectivity module of the PBR material
  64640. */
  64641. export class ReflectivityBlock extends NodeMaterialBlock {
  64642. private _metallicReflectanceColor;
  64643. private _metallicF0Factor;
  64644. /** @hidden */
  64645. _vMetallicReflectanceFactorsName: string;
  64646. /**
  64647. * The property below is set by the main PBR block prior to calling methods of this class.
  64648. */
  64649. /** @hidden */
  64650. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64651. /**
  64652. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64653. */
  64654. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64655. /**
  64656. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64657. */
  64658. useMetallnessFromMetallicTextureBlue: boolean;
  64659. /**
  64660. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64661. */
  64662. useRoughnessFromMetallicTextureAlpha: boolean;
  64663. /**
  64664. * Specifies if the metallic texture contains the roughness information in its green channel.
  64665. */
  64666. useRoughnessFromMetallicTextureGreen: boolean;
  64667. /**
  64668. * Create a new ReflectivityBlock
  64669. * @param name defines the block name
  64670. */
  64671. constructor(name: string);
  64672. /**
  64673. * Initialize the block and prepare the context for build
  64674. * @param state defines the state that will be used for the build
  64675. */
  64676. initialize(state: NodeMaterialBuildState): void;
  64677. /**
  64678. * Gets the current class name
  64679. * @returns the class name
  64680. */
  64681. getClassName(): string;
  64682. /**
  64683. * Gets the metallic input component
  64684. */
  64685. get metallic(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the roughness input component
  64688. */
  64689. get roughness(): NodeMaterialConnectionPoint;
  64690. /**
  64691. * Gets the texture input component
  64692. */
  64693. get texture(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the reflectivity object output component
  64696. */
  64697. get reflectivity(): NodeMaterialConnectionPoint;
  64698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64699. /**
  64700. * Gets the main code of the block (fragment side)
  64701. * @param state current state of the node material building
  64702. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64703. * @returns the shader code
  64704. */
  64705. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64707. protected _buildBlock(state: NodeMaterialBuildState): this;
  64708. protected _dumpPropertiesCode(): string;
  64709. serialize(): any;
  64710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64711. }
  64712. }
  64713. declare module BABYLON {
  64714. /**
  64715. * Block used to implement the anisotropy module of the PBR material
  64716. */
  64717. export class AnisotropyBlock extends NodeMaterialBlock {
  64718. /**
  64719. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64720. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64721. * It's less burden on the user side in the editor part.
  64722. */
  64723. /** @hidden */
  64724. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64725. /** @hidden */
  64726. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64727. /**
  64728. * Create a new AnisotropyBlock
  64729. * @param name defines the block name
  64730. */
  64731. constructor(name: string);
  64732. /**
  64733. * Initialize the block and prepare the context for build
  64734. * @param state defines the state that will be used for the build
  64735. */
  64736. initialize(state: NodeMaterialBuildState): void;
  64737. /**
  64738. * Gets the current class name
  64739. * @returns the class name
  64740. */
  64741. getClassName(): string;
  64742. /**
  64743. * Gets the intensity input component
  64744. */
  64745. get intensity(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the direction input component
  64748. */
  64749. get direction(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the texture input component
  64752. */
  64753. get texture(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the uv input component
  64756. */
  64757. get uv(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the worldTangent input component
  64760. */
  64761. get worldTangent(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the anisotropy object output component
  64764. */
  64765. get anisotropy(): NodeMaterialConnectionPoint;
  64766. private _generateTBNSpace;
  64767. /**
  64768. * Gets the main code of the block (fragment side)
  64769. * @param state current state of the node material building
  64770. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64771. * @returns the shader code
  64772. */
  64773. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64775. protected _buildBlock(state: NodeMaterialBuildState): this;
  64776. }
  64777. }
  64778. declare module BABYLON {
  64779. /**
  64780. * Block used to implement the clear coat module of the PBR material
  64781. */
  64782. export class ClearCoatBlock extends NodeMaterialBlock {
  64783. private _scene;
  64784. /**
  64785. * Create a new ClearCoatBlock
  64786. * @param name defines the block name
  64787. */
  64788. constructor(name: string);
  64789. /**
  64790. * Initialize the block and prepare the context for build
  64791. * @param state defines the state that will be used for the build
  64792. */
  64793. initialize(state: NodeMaterialBuildState): void;
  64794. /**
  64795. * Gets the current class name
  64796. * @returns the class name
  64797. */
  64798. getClassName(): string;
  64799. /**
  64800. * Gets the intensity input component
  64801. */
  64802. get intensity(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the roughness input component
  64805. */
  64806. get roughness(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the ior input component
  64809. */
  64810. get ior(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the texture input component
  64813. */
  64814. get texture(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the bump texture input component
  64817. */
  64818. get bumpTexture(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the uv input component
  64821. */
  64822. get uv(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the tint color input component
  64825. */
  64826. get tintColor(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the tint "at distance" input component
  64829. */
  64830. get tintAtDistance(): NodeMaterialConnectionPoint;
  64831. /**
  64832. * Gets the tint thickness input component
  64833. */
  64834. get tintThickness(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the world tangent input component
  64837. */
  64838. get worldTangent(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the clear coat object output component
  64841. */
  64842. get clearcoat(): NodeMaterialConnectionPoint;
  64843. autoConfigure(material: NodeMaterial): void;
  64844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64846. private _generateTBNSpace;
  64847. /**
  64848. * Gets the main code of the block (fragment side)
  64849. * @param state current state of the node material building
  64850. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64851. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64852. * @param worldPosVarName name of the variable holding the world position
  64853. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64854. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64855. * @param worldNormalVarName name of the variable holding the world normal
  64856. * @returns the shader code
  64857. */
  64858. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64859. protected _buildBlock(state: NodeMaterialBuildState): this;
  64860. }
  64861. }
  64862. declare module BABYLON {
  64863. /**
  64864. * Block used to implement the sub surface module of the PBR material
  64865. */
  64866. export class SubSurfaceBlock extends NodeMaterialBlock {
  64867. /**
  64868. * Create a new SubSurfaceBlock
  64869. * @param name defines the block name
  64870. */
  64871. constructor(name: string);
  64872. /**
  64873. * Stores the intensity of the different subsurface effects in the thickness texture.
  64874. * * the green channel is the translucency intensity.
  64875. * * the blue channel is the scattering intensity.
  64876. * * the alpha channel is the refraction intensity.
  64877. */
  64878. useMaskFromThicknessTexture: boolean;
  64879. /**
  64880. * Initialize the block and prepare the context for build
  64881. * @param state defines the state that will be used for the build
  64882. */
  64883. initialize(state: NodeMaterialBuildState): void;
  64884. /**
  64885. * Gets the current class name
  64886. * @returns the class name
  64887. */
  64888. getClassName(): string;
  64889. /**
  64890. * Gets the min thickness input component
  64891. */
  64892. get minThickness(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the max thickness input component
  64895. */
  64896. get maxThickness(): NodeMaterialConnectionPoint;
  64897. /**
  64898. * Gets the thickness texture component
  64899. */
  64900. get thicknessTexture(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the tint color input component
  64903. */
  64904. get tintColor(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the translucency intensity input component
  64907. */
  64908. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the translucency diffusion distance input component
  64911. */
  64912. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64913. /**
  64914. * Gets the refraction object parameters
  64915. */
  64916. get refraction(): NodeMaterialConnectionPoint;
  64917. /**
  64918. * Gets the sub surface object output component
  64919. */
  64920. get subsurface(): NodeMaterialConnectionPoint;
  64921. autoConfigure(material: NodeMaterial): void;
  64922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64923. /**
  64924. * Gets the main code of the block (fragment side)
  64925. * @param state current state of the node material building
  64926. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64927. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64928. * @param worldPosVarName name of the variable holding the world position
  64929. * @returns the shader code
  64930. */
  64931. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64932. protected _buildBlock(state: NodeMaterialBuildState): this;
  64933. }
  64934. }
  64935. declare module BABYLON {
  64936. /**
  64937. * Block used to implement the PBR metallic/roughness model
  64938. */
  64939. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64940. /**
  64941. * Gets or sets the light associated with this block
  64942. */
  64943. light: Nullable<Light>;
  64944. private _lightId;
  64945. private _scene;
  64946. private _environmentBRDFTexture;
  64947. private _environmentBrdfSamplerName;
  64948. private _vNormalWName;
  64949. private _invertNormalName;
  64950. /**
  64951. * Create a new ReflectionBlock
  64952. * @param name defines the block name
  64953. */
  64954. constructor(name: string);
  64955. /**
  64956. * Intensity of the direct lights e.g. the four lights available in your scene.
  64957. * This impacts both the direct diffuse and specular highlights.
  64958. */
  64959. directIntensity: number;
  64960. /**
  64961. * Intensity of the environment e.g. how much the environment will light the object
  64962. * either through harmonics for rough material or through the refelction for shiny ones.
  64963. */
  64964. environmentIntensity: number;
  64965. /**
  64966. * This is a special control allowing the reduction of the specular highlights coming from the
  64967. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64968. */
  64969. specularIntensity: number;
  64970. /**
  64971. * Defines the falloff type used in this material.
  64972. * It by default is Physical.
  64973. */
  64974. lightFalloff: number;
  64975. /**
  64976. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64977. */
  64978. useAlphaFromAlbedoTexture: boolean;
  64979. /**
  64980. * Specifies that alpha test should be used
  64981. */
  64982. useAlphaTest: boolean;
  64983. /**
  64984. * Defines the alpha limits in alpha test mode.
  64985. */
  64986. alphaTestCutoff: number;
  64987. /**
  64988. * Specifies that alpha blending should be used
  64989. */
  64990. useAlphaBlending: boolean;
  64991. /**
  64992. * Defines if the alpha value should be determined via the rgb values.
  64993. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64994. */
  64995. opacityRGB: boolean;
  64996. /**
  64997. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64998. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64999. */
  65000. useRadianceOverAlpha: boolean;
  65001. /**
  65002. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65003. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65004. */
  65005. useSpecularOverAlpha: boolean;
  65006. /**
  65007. * Enables specular anti aliasing in the PBR shader.
  65008. * It will both interacts on the Geometry for analytical and IBL lighting.
  65009. * It also prefilter the roughness map based on the bump values.
  65010. */
  65011. enableSpecularAntiAliasing: boolean;
  65012. /**
  65013. * Enables realtime filtering on the texture.
  65014. */
  65015. realTimeFiltering: boolean;
  65016. /**
  65017. * Quality switch for realtime filtering
  65018. */
  65019. realTimeFilteringQuality: number;
  65020. /**
  65021. * Defines if the material uses energy conservation.
  65022. */
  65023. useEnergyConservation: boolean;
  65024. /**
  65025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65026. * too much the area relying on ambient texture to define their ambient occlusion.
  65027. */
  65028. useRadianceOcclusion: boolean;
  65029. /**
  65030. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65031. * makes the reflect vector face the model (under horizon).
  65032. */
  65033. useHorizonOcclusion: boolean;
  65034. /**
  65035. * If set to true, no lighting calculations will be applied.
  65036. */
  65037. unlit: boolean;
  65038. /**
  65039. * Force normal to face away from face.
  65040. */
  65041. forceNormalForward: boolean;
  65042. /**
  65043. * Defines the material debug mode.
  65044. * It helps seeing only some components of the material while troubleshooting.
  65045. */
  65046. debugMode: number;
  65047. /**
  65048. * Specify from where on screen the debug mode should start.
  65049. * The value goes from -1 (full screen) to 1 (not visible)
  65050. * It helps with side by side comparison against the final render
  65051. * This defaults to 0
  65052. */
  65053. debugLimit: number;
  65054. /**
  65055. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65056. * You can use the factor to better multiply the final value.
  65057. */
  65058. debugFactor: number;
  65059. /**
  65060. * Initialize the block and prepare the context for build
  65061. * @param state defines the state that will be used for the build
  65062. */
  65063. initialize(state: NodeMaterialBuildState): void;
  65064. /**
  65065. * Gets the current class name
  65066. * @returns the class name
  65067. */
  65068. getClassName(): string;
  65069. /**
  65070. * Gets the world position input component
  65071. */
  65072. get worldPosition(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the world normal input component
  65075. */
  65076. get worldNormal(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the perturbed normal input component
  65079. */
  65080. get perturbedNormal(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the camera position input component
  65083. */
  65084. get cameraPosition(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the base color input component
  65087. */
  65088. get baseColor(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the opacity texture input component
  65091. */
  65092. get opacityTexture(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the ambient color input component
  65095. */
  65096. get ambientColor(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the reflectivity object parameters
  65099. */
  65100. get reflectivity(): NodeMaterialConnectionPoint;
  65101. /**
  65102. * Gets the ambient occlusion object parameters
  65103. */
  65104. get ambientOcc(): NodeMaterialConnectionPoint;
  65105. /**
  65106. * Gets the reflection object parameters
  65107. */
  65108. get reflection(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the sheen object parameters
  65111. */
  65112. get sheen(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the clear coat object parameters
  65115. */
  65116. get clearcoat(): NodeMaterialConnectionPoint;
  65117. /**
  65118. * Gets the sub surface object parameters
  65119. */
  65120. get subsurface(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the anisotropy object parameters
  65123. */
  65124. get anisotropy(): NodeMaterialConnectionPoint;
  65125. /**
  65126. * Gets the ambient output component
  65127. */
  65128. get ambient(): NodeMaterialConnectionPoint;
  65129. /**
  65130. * Gets the diffuse output component
  65131. */
  65132. get diffuse(): NodeMaterialConnectionPoint;
  65133. /**
  65134. * Gets the specular output component
  65135. */
  65136. get specular(): NodeMaterialConnectionPoint;
  65137. /**
  65138. * Gets the sheen output component
  65139. */
  65140. get sheenDir(): NodeMaterialConnectionPoint;
  65141. /**
  65142. * Gets the clear coat output component
  65143. */
  65144. get clearcoatDir(): NodeMaterialConnectionPoint;
  65145. /**
  65146. * Gets the indirect diffuse output component
  65147. */
  65148. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65149. /**
  65150. * Gets the indirect specular output component
  65151. */
  65152. get specularIndirect(): NodeMaterialConnectionPoint;
  65153. /**
  65154. * Gets the indirect sheen output component
  65155. */
  65156. get sheenIndirect(): NodeMaterialConnectionPoint;
  65157. /**
  65158. * Gets the indirect clear coat output component
  65159. */
  65160. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65161. /**
  65162. * Gets the refraction output component
  65163. */
  65164. get refraction(): NodeMaterialConnectionPoint;
  65165. /**
  65166. * Gets the global lighting output component
  65167. */
  65168. get lighting(): NodeMaterialConnectionPoint;
  65169. /**
  65170. * Gets the shadow output component
  65171. */
  65172. get shadow(): NodeMaterialConnectionPoint;
  65173. /**
  65174. * Gets the alpha output component
  65175. */
  65176. get alpha(): NodeMaterialConnectionPoint;
  65177. autoConfigure(material: NodeMaterial): void;
  65178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65179. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65181. private _injectVertexCode;
  65182. /**
  65183. * Gets the code corresponding to the albedo/opacity module
  65184. * @returns the shader code
  65185. */
  65186. getAlbedoOpacityCode(): string;
  65187. protected _buildBlock(state: NodeMaterialBuildState): this;
  65188. protected _dumpPropertiesCode(): string;
  65189. serialize(): any;
  65190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65191. }
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Block used to compute value of one parameter modulo another
  65196. */
  65197. export class ModBlock extends NodeMaterialBlock {
  65198. /**
  65199. * Creates a new ModBlock
  65200. * @param name defines the block name
  65201. */
  65202. constructor(name: string);
  65203. /**
  65204. * Gets the current class name
  65205. * @returns the class name
  65206. */
  65207. getClassName(): string;
  65208. /**
  65209. * Gets the left operand input component
  65210. */
  65211. get left(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the right operand input component
  65214. */
  65215. get right(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the output component
  65218. */
  65219. get output(): NodeMaterialConnectionPoint;
  65220. protected _buildBlock(state: NodeMaterialBuildState): this;
  65221. }
  65222. }
  65223. declare module BABYLON {
  65224. /**
  65225. * Configuration for Draco compression
  65226. */
  65227. export interface IDracoCompressionConfiguration {
  65228. /**
  65229. * Configuration for the decoder.
  65230. */
  65231. decoder: {
  65232. /**
  65233. * The url to the WebAssembly module.
  65234. */
  65235. wasmUrl?: string;
  65236. /**
  65237. * The url to the WebAssembly binary.
  65238. */
  65239. wasmBinaryUrl?: string;
  65240. /**
  65241. * The url to the fallback JavaScript module.
  65242. */
  65243. fallbackUrl?: string;
  65244. };
  65245. }
  65246. /**
  65247. * Draco compression (https://google.github.io/draco/)
  65248. *
  65249. * This class wraps the Draco module.
  65250. *
  65251. * **Encoder**
  65252. *
  65253. * The encoder is not currently implemented.
  65254. *
  65255. * **Decoder**
  65256. *
  65257. * 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.
  65258. *
  65259. * To update the configuration, use the following code:
  65260. * ```javascript
  65261. * DracoCompression.Configuration = {
  65262. * decoder: {
  65263. * wasmUrl: "<url to the WebAssembly library>",
  65264. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65265. * fallbackUrl: "<url to the fallback JavaScript library>",
  65266. * }
  65267. * };
  65268. * ```
  65269. *
  65270. * 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.
  65271. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65272. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65273. *
  65274. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65275. * ```javascript
  65276. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65277. * ```
  65278. *
  65279. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65280. */
  65281. export class DracoCompression implements IDisposable {
  65282. private _workerPoolPromise?;
  65283. private _decoderModulePromise?;
  65284. /**
  65285. * The configuration. Defaults to the following urls:
  65286. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65287. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65288. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65289. */
  65290. static Configuration: IDracoCompressionConfiguration;
  65291. /**
  65292. * Returns true if the decoder configuration is available.
  65293. */
  65294. static get DecoderAvailable(): boolean;
  65295. /**
  65296. * Default number of workers to create when creating the draco compression object.
  65297. */
  65298. static DefaultNumWorkers: number;
  65299. private static GetDefaultNumWorkers;
  65300. private static _Default;
  65301. /**
  65302. * Default instance for the draco compression object.
  65303. */
  65304. static get Default(): DracoCompression;
  65305. /**
  65306. * Constructor
  65307. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65308. */
  65309. constructor(numWorkers?: number);
  65310. /**
  65311. * Stop all async operations and release resources.
  65312. */
  65313. dispose(): void;
  65314. /**
  65315. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65316. * @returns a promise that resolves when ready
  65317. */
  65318. whenReadyAsync(): Promise<void>;
  65319. /**
  65320. * Decode Draco compressed mesh data to vertex data.
  65321. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65322. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65323. * @returns A promise that resolves with the decoded vertex data
  65324. */
  65325. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65326. [kind: string]: number;
  65327. }): Promise<VertexData>;
  65328. }
  65329. }
  65330. declare module BABYLON {
  65331. /**
  65332. * Class for building Constructive Solid Geometry
  65333. */
  65334. export class CSG {
  65335. private polygons;
  65336. /**
  65337. * The world matrix
  65338. */
  65339. matrix: Matrix;
  65340. /**
  65341. * Stores the position
  65342. */
  65343. position: Vector3;
  65344. /**
  65345. * Stores the rotation
  65346. */
  65347. rotation: Vector3;
  65348. /**
  65349. * Stores the rotation quaternion
  65350. */
  65351. rotationQuaternion: Nullable<Quaternion>;
  65352. /**
  65353. * Stores the scaling vector
  65354. */
  65355. scaling: Vector3;
  65356. /**
  65357. * Convert the Mesh to CSG
  65358. * @param mesh The Mesh to convert to CSG
  65359. * @returns A new CSG from the Mesh
  65360. */
  65361. static FromMesh(mesh: Mesh): CSG;
  65362. /**
  65363. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65364. * @param polygons Polygons used to construct a CSG solid
  65365. */
  65366. private static FromPolygons;
  65367. /**
  65368. * Clones, or makes a deep copy, of the CSG
  65369. * @returns A new CSG
  65370. */
  65371. clone(): CSG;
  65372. /**
  65373. * Unions this CSG with another CSG
  65374. * @param csg The CSG to union against this CSG
  65375. * @returns The unioned CSG
  65376. */
  65377. union(csg: CSG): CSG;
  65378. /**
  65379. * Unions this CSG with another CSG in place
  65380. * @param csg The CSG to union against this CSG
  65381. */
  65382. unionInPlace(csg: CSG): void;
  65383. /**
  65384. * Subtracts this CSG with another CSG
  65385. * @param csg The CSG to subtract against this CSG
  65386. * @returns A new CSG
  65387. */
  65388. subtract(csg: CSG): CSG;
  65389. /**
  65390. * Subtracts this CSG with another CSG in place
  65391. * @param csg The CSG to subtact against this CSG
  65392. */
  65393. subtractInPlace(csg: CSG): void;
  65394. /**
  65395. * Intersect this CSG with another CSG
  65396. * @param csg The CSG to intersect against this CSG
  65397. * @returns A new CSG
  65398. */
  65399. intersect(csg: CSG): CSG;
  65400. /**
  65401. * Intersects this CSG with another CSG in place
  65402. * @param csg The CSG to intersect against this CSG
  65403. */
  65404. intersectInPlace(csg: CSG): void;
  65405. /**
  65406. * Return a new CSG solid with solid and empty space switched. This solid is
  65407. * not modified.
  65408. * @returns A new CSG solid with solid and empty space switched
  65409. */
  65410. inverse(): CSG;
  65411. /**
  65412. * Inverses the CSG in place
  65413. */
  65414. inverseInPlace(): void;
  65415. /**
  65416. * This is used to keep meshes transformations so they can be restored
  65417. * when we build back a Babylon Mesh
  65418. * NB : All CSG operations are performed in world coordinates
  65419. * @param csg The CSG to copy the transform attributes from
  65420. * @returns This CSG
  65421. */
  65422. copyTransformAttributes(csg: CSG): CSG;
  65423. /**
  65424. * Build Raw mesh from CSG
  65425. * Coordinates here are in world space
  65426. * @param name The name of the mesh geometry
  65427. * @param scene The Scene
  65428. * @param keepSubMeshes Specifies if the submeshes should be kept
  65429. * @returns A new Mesh
  65430. */
  65431. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65432. /**
  65433. * Build Mesh from CSG taking material and transforms into account
  65434. * @param name The name of the Mesh
  65435. * @param material The material of the Mesh
  65436. * @param scene The Scene
  65437. * @param keepSubMeshes Specifies if submeshes should be kept
  65438. * @returns The new Mesh
  65439. */
  65440. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65441. }
  65442. }
  65443. declare module BABYLON {
  65444. /**
  65445. * Class used to create a trail following a mesh
  65446. */
  65447. export class TrailMesh extends Mesh {
  65448. private _generator;
  65449. private _autoStart;
  65450. private _running;
  65451. private _diameter;
  65452. private _length;
  65453. private _sectionPolygonPointsCount;
  65454. private _sectionVectors;
  65455. private _sectionNormalVectors;
  65456. private _beforeRenderObserver;
  65457. /**
  65458. * @constructor
  65459. * @param name The value used by scene.getMeshByName() to do a lookup.
  65460. * @param generator The mesh or transform node to generate a trail.
  65461. * @param scene The scene to add this mesh to.
  65462. * @param diameter Diameter of trailing mesh. Default is 1.
  65463. * @param length Length of trailing mesh. Default is 60.
  65464. * @param autoStart Automatically start trailing mesh. Default true.
  65465. */
  65466. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65467. /**
  65468. * "TrailMesh"
  65469. * @returns "TrailMesh"
  65470. */
  65471. getClassName(): string;
  65472. private _createMesh;
  65473. /**
  65474. * Start trailing mesh.
  65475. */
  65476. start(): void;
  65477. /**
  65478. * Stop trailing mesh.
  65479. */
  65480. stop(): void;
  65481. /**
  65482. * Update trailing mesh geometry.
  65483. */
  65484. update(): void;
  65485. /**
  65486. * Returns a new TrailMesh object.
  65487. * @param name is a string, the name given to the new mesh
  65488. * @param newGenerator use new generator object for cloned trail mesh
  65489. * @returns a new mesh
  65490. */
  65491. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65492. /**
  65493. * Serializes this trail mesh
  65494. * @param serializationObject object to write serialization to
  65495. */
  65496. serialize(serializationObject: any): void;
  65497. /**
  65498. * Parses a serialized trail mesh
  65499. * @param parsedMesh the serialized mesh
  65500. * @param scene the scene to create the trail mesh in
  65501. * @returns the created trail mesh
  65502. */
  65503. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65504. }
  65505. }
  65506. declare module BABYLON {
  65507. /**
  65508. * Class containing static functions to help procedurally build meshes
  65509. */
  65510. export class TiledBoxBuilder {
  65511. /**
  65512. * Creates a box mesh
  65513. * 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)
  65514. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65516. * * 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
  65517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65518. * @param name defines the name of the mesh
  65519. * @param options defines the options used to create the mesh
  65520. * @param scene defines the hosting scene
  65521. * @returns the box mesh
  65522. */
  65523. static CreateTiledBox(name: string, options: {
  65524. pattern?: number;
  65525. width?: number;
  65526. height?: number;
  65527. depth?: number;
  65528. tileSize?: number;
  65529. tileWidth?: number;
  65530. tileHeight?: number;
  65531. alignHorizontal?: number;
  65532. alignVertical?: number;
  65533. faceUV?: Vector4[];
  65534. faceColors?: Color4[];
  65535. sideOrientation?: number;
  65536. updatable?: boolean;
  65537. }, scene?: Nullable<Scene>): Mesh;
  65538. }
  65539. }
  65540. declare module BABYLON {
  65541. /**
  65542. * Class containing static functions to help procedurally build meshes
  65543. */
  65544. export class TorusKnotBuilder {
  65545. /**
  65546. * Creates a torus knot mesh
  65547. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65548. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65549. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65550. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65552. * * 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
  65553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65554. * @param name defines the name of the mesh
  65555. * @param options defines the options used to create the mesh
  65556. * @param scene defines the hosting scene
  65557. * @returns the torus knot mesh
  65558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65559. */
  65560. static CreateTorusKnot(name: string, options: {
  65561. radius?: number;
  65562. tube?: number;
  65563. radialSegments?: number;
  65564. tubularSegments?: number;
  65565. p?: number;
  65566. q?: number;
  65567. updatable?: boolean;
  65568. sideOrientation?: number;
  65569. frontUVs?: Vector4;
  65570. backUVs?: Vector4;
  65571. }, scene: any): Mesh;
  65572. }
  65573. }
  65574. declare module BABYLON {
  65575. /**
  65576. * Polygon
  65577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65578. */
  65579. export class Polygon {
  65580. /**
  65581. * Creates a rectangle
  65582. * @param xmin bottom X coord
  65583. * @param ymin bottom Y coord
  65584. * @param xmax top X coord
  65585. * @param ymax top Y coord
  65586. * @returns points that make the resulting rectation
  65587. */
  65588. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65589. /**
  65590. * Creates a circle
  65591. * @param radius radius of circle
  65592. * @param cx scale in x
  65593. * @param cy scale in y
  65594. * @param numberOfSides number of sides that make up the circle
  65595. * @returns points that make the resulting circle
  65596. */
  65597. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65598. /**
  65599. * Creates a polygon from input string
  65600. * @param input Input polygon data
  65601. * @returns the parsed points
  65602. */
  65603. static Parse(input: string): Vector2[];
  65604. /**
  65605. * Starts building a polygon from x and y coordinates
  65606. * @param x x coordinate
  65607. * @param y y coordinate
  65608. * @returns the started path2
  65609. */
  65610. static StartingAt(x: number, y: number): Path2;
  65611. }
  65612. /**
  65613. * Builds a polygon
  65614. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65615. */
  65616. export class PolygonMeshBuilder {
  65617. private _points;
  65618. private _outlinepoints;
  65619. private _holes;
  65620. private _name;
  65621. private _scene;
  65622. private _epoints;
  65623. private _eholes;
  65624. private _addToepoint;
  65625. /**
  65626. * Babylon reference to the earcut plugin.
  65627. */
  65628. bjsEarcut: any;
  65629. /**
  65630. * Creates a PolygonMeshBuilder
  65631. * @param name name of the builder
  65632. * @param contours Path of the polygon
  65633. * @param scene scene to add to when creating the mesh
  65634. * @param earcutInjection can be used to inject your own earcut reference
  65635. */
  65636. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65637. /**
  65638. * Adds a whole within the polygon
  65639. * @param hole Array of points defining the hole
  65640. * @returns this
  65641. */
  65642. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65643. /**
  65644. * Creates the polygon
  65645. * @param updatable If the mesh should be updatable
  65646. * @param depth The depth of the mesh created
  65647. * @returns the created mesh
  65648. */
  65649. build(updatable?: boolean, depth?: number): Mesh;
  65650. /**
  65651. * Creates the polygon
  65652. * @param depth The depth of the mesh created
  65653. * @returns the created VertexData
  65654. */
  65655. buildVertexData(depth?: number): VertexData;
  65656. /**
  65657. * Adds a side to the polygon
  65658. * @param positions points that make the polygon
  65659. * @param normals normals of the polygon
  65660. * @param uvs uvs of the polygon
  65661. * @param indices indices of the polygon
  65662. * @param bounds bounds of the polygon
  65663. * @param points points of the polygon
  65664. * @param depth depth of the polygon
  65665. * @param flip flip of the polygon
  65666. */
  65667. private addSide;
  65668. }
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * Class containing static functions to help procedurally build meshes
  65673. */
  65674. export class PolygonBuilder {
  65675. /**
  65676. * Creates a polygon mesh
  65677. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65678. * * 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
  65679. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65681. * * 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)
  65682. * * Remember you can only change the shape positions, not their number when updating a polygon
  65683. * @param name defines the name of the mesh
  65684. * @param options defines the options used to create the mesh
  65685. * @param scene defines the hosting scene
  65686. * @param earcutInjection can be used to inject your own earcut reference
  65687. * @returns the polygon mesh
  65688. */
  65689. static CreatePolygon(name: string, options: {
  65690. shape: Vector3[];
  65691. holes?: Vector3[][];
  65692. depth?: number;
  65693. faceUV?: Vector4[];
  65694. faceColors?: Color4[];
  65695. updatable?: boolean;
  65696. sideOrientation?: number;
  65697. frontUVs?: Vector4;
  65698. backUVs?: Vector4;
  65699. wrap?: boolean;
  65700. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65701. /**
  65702. * Creates an extruded polygon mesh, with depth in the Y direction.
  65703. * * 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)
  65704. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65705. * @param name defines the name of the mesh
  65706. * @param options defines the options used to create the mesh
  65707. * @param scene defines the hosting scene
  65708. * @param earcutInjection can be used to inject your own earcut reference
  65709. * @returns the polygon mesh
  65710. */
  65711. static ExtrudePolygon(name: string, options: {
  65712. shape: Vector3[];
  65713. holes?: Vector3[][];
  65714. depth?: number;
  65715. faceUV?: Vector4[];
  65716. faceColors?: Color4[];
  65717. updatable?: boolean;
  65718. sideOrientation?: number;
  65719. frontUVs?: Vector4;
  65720. backUVs?: Vector4;
  65721. wrap?: boolean;
  65722. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65723. }
  65724. }
  65725. declare module BABYLON {
  65726. /**
  65727. * Class containing static functions to help procedurally build meshes
  65728. */
  65729. export class LatheBuilder {
  65730. /**
  65731. * Creates lathe mesh.
  65732. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65733. * * 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
  65734. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65735. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65736. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65737. * * 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
  65738. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65739. * * 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
  65740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65741. * * 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
  65742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65744. * @param name defines the name of the mesh
  65745. * @param options defines the options used to create the mesh
  65746. * @param scene defines the hosting scene
  65747. * @returns the lathe mesh
  65748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65749. */
  65750. static CreateLathe(name: string, options: {
  65751. shape: Vector3[];
  65752. radius?: number;
  65753. tessellation?: number;
  65754. clip?: number;
  65755. arc?: number;
  65756. closed?: boolean;
  65757. updatable?: boolean;
  65758. sideOrientation?: number;
  65759. frontUVs?: Vector4;
  65760. backUVs?: Vector4;
  65761. cap?: number;
  65762. invertUV?: boolean;
  65763. }, scene?: Nullable<Scene>): Mesh;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * Class containing static functions to help procedurally build meshes
  65769. */
  65770. export class TiledPlaneBuilder {
  65771. /**
  65772. * Creates a tiled plane mesh
  65773. * * The parameter `pattern` will, depending on value, do nothing or
  65774. * * * flip (reflect about central vertical) alternate tiles across and up
  65775. * * * flip every tile on alternate rows
  65776. * * * rotate (180 degs) alternate tiles across and up
  65777. * * * rotate every tile on alternate rows
  65778. * * * flip and rotate alternate tiles across and up
  65779. * * * flip and rotate every tile on alternate rows
  65780. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65781. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65782. * * 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
  65783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65784. * * 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)
  65785. * * 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)
  65786. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65787. * @param name defines the name of the mesh
  65788. * @param options defines the options used to create the mesh
  65789. * @param scene defines the hosting scene
  65790. * @returns the box mesh
  65791. */
  65792. static CreateTiledPlane(name: string, options: {
  65793. pattern?: number;
  65794. tileSize?: number;
  65795. tileWidth?: number;
  65796. tileHeight?: number;
  65797. size?: number;
  65798. width?: number;
  65799. height?: number;
  65800. alignHorizontal?: number;
  65801. alignVertical?: number;
  65802. sideOrientation?: number;
  65803. frontUVs?: Vector4;
  65804. backUVs?: Vector4;
  65805. updatable?: boolean;
  65806. }, scene?: Nullable<Scene>): Mesh;
  65807. }
  65808. }
  65809. declare module BABYLON {
  65810. /**
  65811. * Class containing static functions to help procedurally build meshes
  65812. */
  65813. export class TubeBuilder {
  65814. /**
  65815. * Creates a tube mesh.
  65816. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65817. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65818. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65819. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65820. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65821. * * 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)
  65822. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65823. * * 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
  65824. * * 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
  65825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65826. * * 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
  65827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65829. * @param name defines the name of the mesh
  65830. * @param options defines the options used to create the mesh
  65831. * @param scene defines the hosting scene
  65832. * @returns the tube mesh
  65833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65834. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65835. */
  65836. static CreateTube(name: string, options: {
  65837. path: Vector3[];
  65838. radius?: number;
  65839. tessellation?: number;
  65840. radiusFunction?: {
  65841. (i: number, distance: number): number;
  65842. };
  65843. cap?: number;
  65844. arc?: number;
  65845. updatable?: boolean;
  65846. sideOrientation?: number;
  65847. frontUVs?: Vector4;
  65848. backUVs?: Vector4;
  65849. instance?: Mesh;
  65850. invertUV?: boolean;
  65851. }, scene?: Nullable<Scene>): Mesh;
  65852. }
  65853. }
  65854. declare module BABYLON {
  65855. /**
  65856. * Class containing static functions to help procedurally build meshes
  65857. */
  65858. export class IcoSphereBuilder {
  65859. /**
  65860. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65861. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65862. * * 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`)
  65863. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65864. * * 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
  65865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65866. * * 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
  65867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65868. * @param name defines the name of the mesh
  65869. * @param options defines the options used to create the mesh
  65870. * @param scene defines the hosting scene
  65871. * @returns the icosahedron mesh
  65872. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65873. */
  65874. static CreateIcoSphere(name: string, options: {
  65875. radius?: number;
  65876. radiusX?: number;
  65877. radiusY?: number;
  65878. radiusZ?: number;
  65879. flat?: boolean;
  65880. subdivisions?: number;
  65881. sideOrientation?: number;
  65882. frontUVs?: Vector4;
  65883. backUVs?: Vector4;
  65884. updatable?: boolean;
  65885. }, scene?: Nullable<Scene>): Mesh;
  65886. }
  65887. }
  65888. declare module BABYLON {
  65889. /**
  65890. * Class containing static functions to help procedurally build meshes
  65891. */
  65892. export class DecalBuilder {
  65893. /**
  65894. * Creates a decal mesh.
  65895. * 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
  65896. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65897. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65898. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65899. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65900. * @param name defines the name of the mesh
  65901. * @param sourceMesh defines the mesh where the decal must be applied
  65902. * @param options defines the options used to create the mesh
  65903. * @param scene defines the hosting scene
  65904. * @returns the decal mesh
  65905. * @see https://doc.babylonjs.com/how_to/decals
  65906. */
  65907. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65908. position?: Vector3;
  65909. normal?: Vector3;
  65910. size?: Vector3;
  65911. angle?: number;
  65912. }): Mesh;
  65913. }
  65914. }
  65915. declare module BABYLON {
  65916. /**
  65917. * Class containing static functions to help procedurally build meshes
  65918. */
  65919. export class MeshBuilder {
  65920. /**
  65921. * Creates a box mesh
  65922. * * The parameter `size` sets the size (float) of each box side (default 1)
  65923. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65924. * * 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)
  65925. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65927. * * 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
  65928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65929. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65930. * @param name defines the name of the mesh
  65931. * @param options defines the options used to create the mesh
  65932. * @param scene defines the hosting scene
  65933. * @returns the box mesh
  65934. */
  65935. static CreateBox(name: string, options: {
  65936. size?: number;
  65937. width?: number;
  65938. height?: number;
  65939. depth?: number;
  65940. faceUV?: Vector4[];
  65941. faceColors?: Color4[];
  65942. sideOrientation?: number;
  65943. frontUVs?: Vector4;
  65944. backUVs?: Vector4;
  65945. wrap?: boolean;
  65946. topBaseAt?: number;
  65947. bottomBaseAt?: number;
  65948. updatable?: boolean;
  65949. }, scene?: Nullable<Scene>): Mesh;
  65950. /**
  65951. * Creates a tiled box mesh
  65952. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65954. * @param name defines the name of the mesh
  65955. * @param options defines the options used to create the mesh
  65956. * @param scene defines the hosting scene
  65957. * @returns the tiled box mesh
  65958. */
  65959. static CreateTiledBox(name: string, options: {
  65960. pattern?: number;
  65961. size?: number;
  65962. width?: number;
  65963. height?: number;
  65964. depth: number;
  65965. tileSize?: number;
  65966. tileWidth?: number;
  65967. tileHeight?: number;
  65968. faceUV?: Vector4[];
  65969. faceColors?: Color4[];
  65970. alignHorizontal?: number;
  65971. alignVertical?: number;
  65972. sideOrientation?: number;
  65973. updatable?: boolean;
  65974. }, scene?: Nullable<Scene>): Mesh;
  65975. /**
  65976. * Creates a sphere mesh
  65977. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65978. * * 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`)
  65979. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65980. * * 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
  65981. * * 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)
  65982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65983. * * 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
  65984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65985. * @param name defines the name of the mesh
  65986. * @param options defines the options used to create the mesh
  65987. * @param scene defines the hosting scene
  65988. * @returns the sphere mesh
  65989. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65990. */
  65991. static CreateSphere(name: string, options: {
  65992. segments?: number;
  65993. diameter?: number;
  65994. diameterX?: number;
  65995. diameterY?: number;
  65996. diameterZ?: number;
  65997. arc?: number;
  65998. slice?: number;
  65999. sideOrientation?: number;
  66000. frontUVs?: Vector4;
  66001. backUVs?: Vector4;
  66002. updatable?: boolean;
  66003. }, scene?: Nullable<Scene>): Mesh;
  66004. /**
  66005. * Creates a plane polygonal mesh. By default, this is a disc
  66006. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66007. * * 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
  66008. * * 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
  66009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66010. * * 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
  66011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66012. * @param name defines the name of the mesh
  66013. * @param options defines the options used to create the mesh
  66014. * @param scene defines the hosting scene
  66015. * @returns the plane polygonal mesh
  66016. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66017. */
  66018. static CreateDisc(name: string, options: {
  66019. radius?: number;
  66020. tessellation?: number;
  66021. arc?: number;
  66022. updatable?: boolean;
  66023. sideOrientation?: number;
  66024. frontUVs?: Vector4;
  66025. backUVs?: Vector4;
  66026. }, scene?: Nullable<Scene>): Mesh;
  66027. /**
  66028. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66029. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66030. * * 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`)
  66031. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66032. * * 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
  66033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66034. * * 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
  66035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66036. * @param name defines the name of the mesh
  66037. * @param options defines the options used to create the mesh
  66038. * @param scene defines the hosting scene
  66039. * @returns the icosahedron mesh
  66040. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66041. */
  66042. static CreateIcoSphere(name: string, options: {
  66043. radius?: number;
  66044. radiusX?: number;
  66045. radiusY?: number;
  66046. radiusZ?: number;
  66047. flat?: boolean;
  66048. subdivisions?: number;
  66049. sideOrientation?: number;
  66050. frontUVs?: Vector4;
  66051. backUVs?: Vector4;
  66052. updatable?: boolean;
  66053. }, scene?: Nullable<Scene>): Mesh;
  66054. /**
  66055. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66056. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66057. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66058. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66059. * * 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
  66060. * * 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
  66061. * * 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
  66062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66063. * * 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
  66064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66065. * * 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
  66066. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66067. * * 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
  66068. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66070. * @param name defines the name of the mesh
  66071. * @param options defines the options used to create the mesh
  66072. * @param scene defines the hosting scene
  66073. * @returns the ribbon mesh
  66074. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66076. */
  66077. static CreateRibbon(name: string, options: {
  66078. pathArray: Vector3[][];
  66079. closeArray?: boolean;
  66080. closePath?: boolean;
  66081. offset?: number;
  66082. updatable?: boolean;
  66083. sideOrientation?: number;
  66084. frontUVs?: Vector4;
  66085. backUVs?: Vector4;
  66086. instance?: Mesh;
  66087. invertUV?: boolean;
  66088. uvs?: Vector2[];
  66089. colors?: Color4[];
  66090. }, scene?: Nullable<Scene>): Mesh;
  66091. /**
  66092. * Creates a cylinder or a cone mesh
  66093. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66094. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66095. * * 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.
  66096. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66097. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66098. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66099. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66100. * * 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).
  66101. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66102. * * 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).
  66103. * * 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
  66104. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66105. * * 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
  66106. * * 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.
  66107. * * If `enclose` is false, a ring surface is one element.
  66108. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66109. * * 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
  66110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66111. * * 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
  66112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66113. * @param name defines the name of the mesh
  66114. * @param options defines the options used to create the mesh
  66115. * @param scene defines the hosting scene
  66116. * @returns the cylinder mesh
  66117. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66118. */
  66119. static CreateCylinder(name: string, options: {
  66120. height?: number;
  66121. diameterTop?: number;
  66122. diameterBottom?: number;
  66123. diameter?: number;
  66124. tessellation?: number;
  66125. subdivisions?: number;
  66126. arc?: number;
  66127. faceColors?: Color4[];
  66128. faceUV?: Vector4[];
  66129. updatable?: boolean;
  66130. hasRings?: boolean;
  66131. enclose?: boolean;
  66132. cap?: number;
  66133. sideOrientation?: number;
  66134. frontUVs?: Vector4;
  66135. backUVs?: Vector4;
  66136. }, scene?: Nullable<Scene>): Mesh;
  66137. /**
  66138. * Creates a torus mesh
  66139. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66140. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66141. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66143. * * 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
  66144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66145. * @param name defines the name of the mesh
  66146. * @param options defines the options used to create the mesh
  66147. * @param scene defines the hosting scene
  66148. * @returns the torus mesh
  66149. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66150. */
  66151. static CreateTorus(name: string, options: {
  66152. diameter?: number;
  66153. thickness?: number;
  66154. tessellation?: number;
  66155. updatable?: boolean;
  66156. sideOrientation?: number;
  66157. frontUVs?: Vector4;
  66158. backUVs?: Vector4;
  66159. }, scene?: Nullable<Scene>): Mesh;
  66160. /**
  66161. * Creates a torus knot mesh
  66162. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66163. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66164. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66165. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66167. * * 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
  66168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66169. * @param name defines the name of the mesh
  66170. * @param options defines the options used to create the mesh
  66171. * @param scene defines the hosting scene
  66172. * @returns the torus knot mesh
  66173. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66174. */
  66175. static CreateTorusKnot(name: string, options: {
  66176. radius?: number;
  66177. tube?: number;
  66178. radialSegments?: number;
  66179. tubularSegments?: number;
  66180. p?: number;
  66181. q?: number;
  66182. updatable?: boolean;
  66183. sideOrientation?: number;
  66184. frontUVs?: Vector4;
  66185. backUVs?: Vector4;
  66186. }, scene?: Nullable<Scene>): Mesh;
  66187. /**
  66188. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66189. * * 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
  66190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66191. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66192. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66193. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66194. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66195. * * 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
  66196. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66199. * @param name defines the name of the new line system
  66200. * @param options defines the options used to create the line system
  66201. * @param scene defines the hosting scene
  66202. * @returns a new line system mesh
  66203. */
  66204. static CreateLineSystem(name: string, options: {
  66205. lines: Vector3[][];
  66206. updatable?: boolean;
  66207. instance?: Nullable<LinesMesh>;
  66208. colors?: Nullable<Color4[][]>;
  66209. useVertexAlpha?: boolean;
  66210. }, scene: Nullable<Scene>): LinesMesh;
  66211. /**
  66212. * Creates a line mesh
  66213. * 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
  66214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66215. * * The parameter `points` is an array successive Vector3
  66216. * * 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
  66217. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66219. * * When updating an instance, remember that only point positions can change, not the number of points
  66220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66222. * @param name defines the name of the new line system
  66223. * @param options defines the options used to create the line system
  66224. * @param scene defines the hosting scene
  66225. * @returns a new line mesh
  66226. */
  66227. static CreateLines(name: string, options: {
  66228. points: Vector3[];
  66229. updatable?: boolean;
  66230. instance?: Nullable<LinesMesh>;
  66231. colors?: Color4[];
  66232. useVertexAlpha?: boolean;
  66233. }, scene?: Nullable<Scene>): LinesMesh;
  66234. /**
  66235. * Creates a dashed line mesh
  66236. * * 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
  66237. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66238. * * The parameter `points` is an array successive Vector3
  66239. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66240. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66241. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66242. * * 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
  66243. * * When updating an instance, remember that only point positions can change, not the number of points
  66244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66245. * @param name defines the name of the mesh
  66246. * @param options defines the options used to create the mesh
  66247. * @param scene defines the hosting scene
  66248. * @returns the dashed line mesh
  66249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66250. */
  66251. static CreateDashedLines(name: string, options: {
  66252. points: Vector3[];
  66253. dashSize?: number;
  66254. gapSize?: number;
  66255. dashNb?: number;
  66256. updatable?: boolean;
  66257. instance?: LinesMesh;
  66258. }, scene?: Nullable<Scene>): LinesMesh;
  66259. /**
  66260. * 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.
  66261. * * 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.
  66262. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66263. * * 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.
  66264. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66265. * * 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
  66266. * * 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
  66267. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66269. * * 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
  66270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66272. * @param name defines the name of the mesh
  66273. * @param options defines the options used to create the mesh
  66274. * @param scene defines the hosting scene
  66275. * @returns the extruded shape mesh
  66276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66278. */
  66279. static ExtrudeShape(name: string, options: {
  66280. shape: Vector3[];
  66281. path: Vector3[];
  66282. scale?: number;
  66283. rotation?: number;
  66284. cap?: number;
  66285. updatable?: boolean;
  66286. sideOrientation?: number;
  66287. frontUVs?: Vector4;
  66288. backUVs?: Vector4;
  66289. instance?: Mesh;
  66290. invertUV?: boolean;
  66291. }, scene?: Nullable<Scene>): Mesh;
  66292. /**
  66293. * Creates an custom extruded shape mesh.
  66294. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66295. * * 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.
  66296. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66297. * * 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
  66298. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66299. * * 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
  66300. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66301. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66302. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66303. * * 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
  66304. * * 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
  66305. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66307. * * 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
  66308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66310. * @param name defines the name of the mesh
  66311. * @param options defines the options used to create the mesh
  66312. * @param scene defines the hosting scene
  66313. * @returns the custom extruded shape mesh
  66314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66317. */
  66318. static ExtrudeShapeCustom(name: string, options: {
  66319. shape: Vector3[];
  66320. path: Vector3[];
  66321. scaleFunction?: any;
  66322. rotationFunction?: any;
  66323. ribbonCloseArray?: boolean;
  66324. ribbonClosePath?: boolean;
  66325. cap?: number;
  66326. updatable?: boolean;
  66327. sideOrientation?: number;
  66328. frontUVs?: Vector4;
  66329. backUVs?: Vector4;
  66330. instance?: Mesh;
  66331. invertUV?: boolean;
  66332. }, scene?: Nullable<Scene>): Mesh;
  66333. /**
  66334. * Creates lathe mesh.
  66335. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66336. * * 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
  66337. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66338. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66339. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66340. * * 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
  66341. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66342. * * 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
  66343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66344. * * 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
  66345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66347. * @param name defines the name of the mesh
  66348. * @param options defines the options used to create the mesh
  66349. * @param scene defines the hosting scene
  66350. * @returns the lathe mesh
  66351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66352. */
  66353. static CreateLathe(name: string, options: {
  66354. shape: Vector3[];
  66355. radius?: number;
  66356. tessellation?: number;
  66357. clip?: number;
  66358. arc?: number;
  66359. closed?: boolean;
  66360. updatable?: boolean;
  66361. sideOrientation?: number;
  66362. frontUVs?: Vector4;
  66363. backUVs?: Vector4;
  66364. cap?: number;
  66365. invertUV?: boolean;
  66366. }, scene?: Nullable<Scene>): Mesh;
  66367. /**
  66368. * Creates a tiled plane mesh
  66369. * * You can set a limited pattern arrangement with the tiles
  66370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66371. * * 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
  66372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66373. * @param name defines the name of the mesh
  66374. * @param options defines the options used to create the mesh
  66375. * @param scene defines the hosting scene
  66376. * @returns the plane mesh
  66377. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66378. */
  66379. static CreateTiledPlane(name: string, options: {
  66380. pattern?: number;
  66381. tileSize?: number;
  66382. tileWidth?: number;
  66383. tileHeight?: number;
  66384. size?: number;
  66385. width?: number;
  66386. height?: number;
  66387. alignHorizontal?: number;
  66388. alignVertical?: number;
  66389. sideOrientation?: number;
  66390. frontUVs?: Vector4;
  66391. backUVs?: Vector4;
  66392. updatable?: boolean;
  66393. }, scene?: Nullable<Scene>): Mesh;
  66394. /**
  66395. * Creates a plane mesh
  66396. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66397. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66398. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66400. * * 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
  66401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66402. * @param name defines the name of the mesh
  66403. * @param options defines the options used to create the mesh
  66404. * @param scene defines the hosting scene
  66405. * @returns the plane mesh
  66406. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66407. */
  66408. static CreatePlane(name: string, options: {
  66409. size?: number;
  66410. width?: number;
  66411. height?: number;
  66412. sideOrientation?: number;
  66413. frontUVs?: Vector4;
  66414. backUVs?: Vector4;
  66415. updatable?: boolean;
  66416. sourcePlane?: Plane;
  66417. }, scene?: Nullable<Scene>): Mesh;
  66418. /**
  66419. * Creates a ground mesh
  66420. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66421. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66423. * @param name defines the name of the mesh
  66424. * @param options defines the options used to create the mesh
  66425. * @param scene defines the hosting scene
  66426. * @returns the ground mesh
  66427. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66428. */
  66429. static CreateGround(name: string, options: {
  66430. width?: number;
  66431. height?: number;
  66432. subdivisions?: number;
  66433. subdivisionsX?: number;
  66434. subdivisionsY?: number;
  66435. updatable?: boolean;
  66436. }, scene?: Nullable<Scene>): Mesh;
  66437. /**
  66438. * Creates a tiled ground mesh
  66439. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66440. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66441. * * 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
  66442. * * 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
  66443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66444. * @param name defines the name of the mesh
  66445. * @param options defines the options used to create the mesh
  66446. * @param scene defines the hosting scene
  66447. * @returns the tiled ground mesh
  66448. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66449. */
  66450. static CreateTiledGround(name: string, options: {
  66451. xmin: number;
  66452. zmin: number;
  66453. xmax: number;
  66454. zmax: number;
  66455. subdivisions?: {
  66456. w: number;
  66457. h: number;
  66458. };
  66459. precision?: {
  66460. w: number;
  66461. h: number;
  66462. };
  66463. updatable?: boolean;
  66464. }, scene?: Nullable<Scene>): Mesh;
  66465. /**
  66466. * Creates a ground mesh from a height map
  66467. * * The parameter `url` sets the URL of the height map image resource.
  66468. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66469. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66470. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66471. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66472. * * 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.
  66473. * * 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).
  66474. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66476. * @param name defines the name of the mesh
  66477. * @param url defines the url to the height map
  66478. * @param options defines the options used to create the mesh
  66479. * @param scene defines the hosting scene
  66480. * @returns the ground mesh
  66481. * @see https://doc.babylonjs.com/babylon101/height_map
  66482. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66483. */
  66484. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66485. width?: number;
  66486. height?: number;
  66487. subdivisions?: number;
  66488. minHeight?: number;
  66489. maxHeight?: number;
  66490. colorFilter?: Color3;
  66491. alphaFilter?: number;
  66492. updatable?: boolean;
  66493. onReady?: (mesh: GroundMesh) => void;
  66494. }, scene?: Nullable<Scene>): GroundMesh;
  66495. /**
  66496. * Creates a polygon mesh
  66497. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66498. * * 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
  66499. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66501. * * 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)
  66502. * * Remember you can only change the shape positions, not their number when updating a polygon
  66503. * @param name defines the name of the mesh
  66504. * @param options defines the options used to create the mesh
  66505. * @param scene defines the hosting scene
  66506. * @param earcutInjection can be used to inject your own earcut reference
  66507. * @returns the polygon mesh
  66508. */
  66509. static CreatePolygon(name: string, options: {
  66510. shape: Vector3[];
  66511. holes?: Vector3[][];
  66512. depth?: number;
  66513. faceUV?: Vector4[];
  66514. faceColors?: Color4[];
  66515. updatable?: boolean;
  66516. sideOrientation?: number;
  66517. frontUVs?: Vector4;
  66518. backUVs?: Vector4;
  66519. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66520. /**
  66521. * Creates an extruded polygon mesh, with depth in the Y direction.
  66522. * * 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)
  66523. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66524. * @param name defines the name of the mesh
  66525. * @param options defines the options used to create the mesh
  66526. * @param scene defines the hosting scene
  66527. * @param earcutInjection can be used to inject your own earcut reference
  66528. * @returns the polygon mesh
  66529. */
  66530. static ExtrudePolygon(name: string, options: {
  66531. shape: Vector3[];
  66532. holes?: Vector3[][];
  66533. depth?: number;
  66534. faceUV?: Vector4[];
  66535. faceColors?: Color4[];
  66536. updatable?: boolean;
  66537. sideOrientation?: number;
  66538. frontUVs?: Vector4;
  66539. backUVs?: Vector4;
  66540. wrap?: boolean;
  66541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66542. /**
  66543. * Creates a tube mesh.
  66544. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66545. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66546. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66547. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66548. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66549. * * 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)
  66550. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66551. * * 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
  66552. * * 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
  66553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66554. * * 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
  66555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66557. * @param name defines the name of the mesh
  66558. * @param options defines the options used to create the mesh
  66559. * @param scene defines the hosting scene
  66560. * @returns the tube mesh
  66561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66562. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66563. */
  66564. static CreateTube(name: string, options: {
  66565. path: Vector3[];
  66566. radius?: number;
  66567. tessellation?: number;
  66568. radiusFunction?: {
  66569. (i: number, distance: number): number;
  66570. };
  66571. cap?: number;
  66572. arc?: number;
  66573. updatable?: boolean;
  66574. sideOrientation?: number;
  66575. frontUVs?: Vector4;
  66576. backUVs?: Vector4;
  66577. instance?: Mesh;
  66578. invertUV?: boolean;
  66579. }, scene?: Nullable<Scene>): Mesh;
  66580. /**
  66581. * Creates a polyhedron mesh
  66582. * * 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
  66583. * * The parameter `size` (positive float, default 1) sets the polygon size
  66584. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66585. * * 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`
  66586. * * 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
  66587. * * 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)`)
  66588. * * 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
  66589. * * 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
  66590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66591. * * 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
  66592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66593. * @param name defines the name of the mesh
  66594. * @param options defines the options used to create the mesh
  66595. * @param scene defines the hosting scene
  66596. * @returns the polyhedron mesh
  66597. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66598. */
  66599. static CreatePolyhedron(name: string, options: {
  66600. type?: number;
  66601. size?: number;
  66602. sizeX?: number;
  66603. sizeY?: number;
  66604. sizeZ?: number;
  66605. custom?: any;
  66606. faceUV?: Vector4[];
  66607. faceColors?: Color4[];
  66608. flat?: boolean;
  66609. updatable?: boolean;
  66610. sideOrientation?: number;
  66611. frontUVs?: Vector4;
  66612. backUVs?: Vector4;
  66613. }, scene?: Nullable<Scene>): Mesh;
  66614. /**
  66615. * Creates a decal mesh.
  66616. * 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
  66617. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66618. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66619. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66620. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66621. * @param name defines the name of the mesh
  66622. * @param sourceMesh defines the mesh where the decal must be applied
  66623. * @param options defines the options used to create the mesh
  66624. * @param scene defines the hosting scene
  66625. * @returns the decal mesh
  66626. * @see https://doc.babylonjs.com/how_to/decals
  66627. */
  66628. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66629. position?: Vector3;
  66630. normal?: Vector3;
  66631. size?: Vector3;
  66632. angle?: number;
  66633. }): Mesh;
  66634. /**
  66635. * Creates a Capsule Mesh
  66636. * @param name defines the name of the mesh.
  66637. * @param options the constructors options used to shape the mesh.
  66638. * @param scene defines the scene the mesh is scoped to.
  66639. * @returns the capsule mesh
  66640. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66641. */
  66642. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66643. }
  66644. }
  66645. declare module BABYLON {
  66646. /**
  66647. * A simplifier interface for future simplification implementations
  66648. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66649. */
  66650. export interface ISimplifier {
  66651. /**
  66652. * Simplification of a given mesh according to the given settings.
  66653. * Since this requires computation, it is assumed that the function runs async.
  66654. * @param settings The settings of the simplification, including quality and distance
  66655. * @param successCallback A callback that will be called after the mesh was simplified.
  66656. * @param errorCallback in case of an error, this callback will be called. optional.
  66657. */
  66658. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66659. }
  66660. /**
  66661. * Expected simplification settings.
  66662. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66663. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66664. */
  66665. export interface ISimplificationSettings {
  66666. /**
  66667. * Gets or sets the expected quality
  66668. */
  66669. quality: number;
  66670. /**
  66671. * Gets or sets the distance when this optimized version should be used
  66672. */
  66673. distance: number;
  66674. /**
  66675. * Gets an already optimized mesh
  66676. */
  66677. optimizeMesh?: boolean;
  66678. }
  66679. /**
  66680. * Class used to specify simplification options
  66681. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66682. */
  66683. export class SimplificationSettings implements ISimplificationSettings {
  66684. /** expected quality */
  66685. quality: number;
  66686. /** distance when this optimized version should be used */
  66687. distance: number;
  66688. /** already optimized mesh */
  66689. optimizeMesh?: boolean | undefined;
  66690. /**
  66691. * Creates a SimplificationSettings
  66692. * @param quality expected quality
  66693. * @param distance distance when this optimized version should be used
  66694. * @param optimizeMesh already optimized mesh
  66695. */
  66696. constructor(
  66697. /** expected quality */
  66698. quality: number,
  66699. /** distance when this optimized version should be used */
  66700. distance: number,
  66701. /** already optimized mesh */
  66702. optimizeMesh?: boolean | undefined);
  66703. }
  66704. /**
  66705. * Interface used to define a simplification task
  66706. */
  66707. export interface ISimplificationTask {
  66708. /**
  66709. * Array of settings
  66710. */
  66711. settings: Array<ISimplificationSettings>;
  66712. /**
  66713. * Simplification type
  66714. */
  66715. simplificationType: SimplificationType;
  66716. /**
  66717. * Mesh to simplify
  66718. */
  66719. mesh: Mesh;
  66720. /**
  66721. * Callback called on success
  66722. */
  66723. successCallback?: () => void;
  66724. /**
  66725. * Defines if parallel processing can be used
  66726. */
  66727. parallelProcessing: boolean;
  66728. }
  66729. /**
  66730. * Queue used to order the simplification tasks
  66731. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66732. */
  66733. export class SimplificationQueue {
  66734. private _simplificationArray;
  66735. /**
  66736. * Gets a boolean indicating that the process is still running
  66737. */
  66738. running: boolean;
  66739. /**
  66740. * Creates a new queue
  66741. */
  66742. constructor();
  66743. /**
  66744. * Adds a new simplification task
  66745. * @param task defines a task to add
  66746. */
  66747. addTask(task: ISimplificationTask): void;
  66748. /**
  66749. * Execute next task
  66750. */
  66751. executeNext(): void;
  66752. /**
  66753. * Execute a simplification task
  66754. * @param task defines the task to run
  66755. */
  66756. runSimplification(task: ISimplificationTask): void;
  66757. private getSimplifier;
  66758. }
  66759. /**
  66760. * The implemented types of simplification
  66761. * At the moment only Quadratic Error Decimation is implemented
  66762. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66763. */
  66764. export enum SimplificationType {
  66765. /** Quadratic error decimation */
  66766. QUADRATIC = 0
  66767. }
  66768. /**
  66769. * An implementation of the Quadratic Error simplification algorithm.
  66770. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66771. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66772. * @author RaananW
  66773. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66774. */
  66775. export class QuadraticErrorSimplification implements ISimplifier {
  66776. private _mesh;
  66777. private triangles;
  66778. private vertices;
  66779. private references;
  66780. private _reconstructedMesh;
  66781. /** Gets or sets the number pf sync interations */
  66782. syncIterations: number;
  66783. /** Gets or sets the aggressiveness of the simplifier */
  66784. aggressiveness: number;
  66785. /** Gets or sets the number of allowed iterations for decimation */
  66786. decimationIterations: number;
  66787. /** Gets or sets the espilon to use for bounding box computation */
  66788. boundingBoxEpsilon: number;
  66789. /**
  66790. * Creates a new QuadraticErrorSimplification
  66791. * @param _mesh defines the target mesh
  66792. */
  66793. constructor(_mesh: Mesh);
  66794. /**
  66795. * Simplification of a given mesh according to the given settings.
  66796. * Since this requires computation, it is assumed that the function runs async.
  66797. * @param settings The settings of the simplification, including quality and distance
  66798. * @param successCallback A callback that will be called after the mesh was simplified.
  66799. */
  66800. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66801. private runDecimation;
  66802. private initWithMesh;
  66803. private init;
  66804. private reconstructMesh;
  66805. private initDecimatedMesh;
  66806. private isFlipped;
  66807. private updateTriangles;
  66808. private identifyBorder;
  66809. private updateMesh;
  66810. private vertexError;
  66811. private calculateError;
  66812. }
  66813. }
  66814. declare module BABYLON {
  66815. interface Scene {
  66816. /** @hidden (Backing field) */
  66817. _simplificationQueue: SimplificationQueue;
  66818. /**
  66819. * Gets or sets the simplification queue attached to the scene
  66820. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66821. */
  66822. simplificationQueue: SimplificationQueue;
  66823. }
  66824. interface Mesh {
  66825. /**
  66826. * Simplify the mesh according to the given array of settings.
  66827. * Function will return immediately and will simplify async
  66828. * @param settings a collection of simplification settings
  66829. * @param parallelProcessing should all levels calculate parallel or one after the other
  66830. * @param simplificationType the type of simplification to run
  66831. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66832. * @returns the current mesh
  66833. */
  66834. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66835. }
  66836. /**
  66837. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66838. * created in a scene
  66839. */
  66840. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66841. /**
  66842. * The component name helpfull to identify the component in the list of scene components.
  66843. */
  66844. readonly name: string;
  66845. /**
  66846. * The scene the component belongs to.
  66847. */
  66848. scene: Scene;
  66849. /**
  66850. * Creates a new instance of the component for the given scene
  66851. * @param scene Defines the scene to register the component in
  66852. */
  66853. constructor(scene: Scene);
  66854. /**
  66855. * Registers the component in a given scene
  66856. */
  66857. register(): void;
  66858. /**
  66859. * Rebuilds the elements related to this component in case of
  66860. * context lost for instance.
  66861. */
  66862. rebuild(): void;
  66863. /**
  66864. * Disposes the component and the associated ressources
  66865. */
  66866. dispose(): void;
  66867. private _beforeCameraUpdate;
  66868. }
  66869. }
  66870. declare module BABYLON {
  66871. interface Mesh {
  66872. /**
  66873. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66874. */
  66875. thinInstanceEnablePicking: boolean;
  66876. /**
  66877. * Creates a new thin instance
  66878. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66879. * @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
  66880. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66881. */
  66882. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66883. /**
  66884. * Adds the transformation (matrix) of the current mesh as a thin instance
  66885. * @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
  66886. * @returns the thin instance index number
  66887. */
  66888. thinInstanceAddSelf(refresh: boolean): number;
  66889. /**
  66890. * Registers a custom attribute to be used with thin instances
  66891. * @param kind name of the attribute
  66892. * @param stride size in floats of the attribute
  66893. */
  66894. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66895. /**
  66896. * Sets the matrix of a thin instance
  66897. * @param index index of the thin instance
  66898. * @param matrix matrix to set
  66899. * @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
  66900. */
  66901. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66902. /**
  66903. * Sets the value of a custom attribute for a thin instance
  66904. * @param kind name of the attribute
  66905. * @param index index of the thin instance
  66906. * @param value value to set
  66907. * @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
  66908. */
  66909. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66910. /**
  66911. * 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.
  66912. */
  66913. thinInstanceCount: number;
  66914. /**
  66915. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66916. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66917. * @param buffer buffer to set
  66918. * @param stride size in floats of each value of the buffer
  66919. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66920. */
  66921. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66922. /**
  66923. * Gets the list of world matrices
  66924. * @return an array containing all the world matrices from the thin instances
  66925. */
  66926. thinInstanceGetWorldMatrices(): Matrix[];
  66927. /**
  66928. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66929. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66930. */
  66931. thinInstanceBufferUpdated(kind: string): void;
  66932. /**
  66933. * Applies a partial update to a buffer directly on the GPU
  66934. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  66935. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66936. * @param data the data to set in the GPU buffer
  66937. * @param offset the offset in the GPU buffer where to update the data
  66938. */
  66939. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66940. /**
  66941. * Refreshes the bounding info, taking into account all the thin instances defined
  66942. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66943. */
  66944. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66945. /** @hidden */
  66946. _thinInstanceInitializeUserStorage(): void;
  66947. /** @hidden */
  66948. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66949. /** @hidden */
  66950. _userThinInstanceBuffersStorage: {
  66951. data: {
  66952. [key: string]: Float32Array;
  66953. };
  66954. sizes: {
  66955. [key: string]: number;
  66956. };
  66957. vertexBuffers: {
  66958. [key: string]: Nullable<VertexBuffer>;
  66959. };
  66960. strides: {
  66961. [key: string]: number;
  66962. };
  66963. };
  66964. }
  66965. }
  66966. declare module BABYLON {
  66967. /**
  66968. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66969. */
  66970. export interface INavigationEnginePlugin {
  66971. /**
  66972. * plugin name
  66973. */
  66974. name: string;
  66975. /**
  66976. * Creates a navigation mesh
  66977. * @param meshes array of all the geometry used to compute the navigatio mesh
  66978. * @param parameters bunch of parameters used to filter geometry
  66979. */
  66980. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66981. /**
  66982. * Create a navigation mesh debug mesh
  66983. * @param scene is where the mesh will be added
  66984. * @returns debug display mesh
  66985. */
  66986. createDebugNavMesh(scene: Scene): Mesh;
  66987. /**
  66988. * Get a navigation mesh constrained position, closest to the parameter position
  66989. * @param position world position
  66990. * @returns the closest point to position constrained by the navigation mesh
  66991. */
  66992. getClosestPoint(position: Vector3): Vector3;
  66993. /**
  66994. * Get a navigation mesh constrained position, closest to the parameter position
  66995. * @param position world position
  66996. * @param result output the closest point to position constrained by the navigation mesh
  66997. */
  66998. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66999. /**
  67000. * Get a navigation mesh constrained position, within a particular radius
  67001. * @param position world position
  67002. * @param maxRadius the maximum distance to the constrained world position
  67003. * @returns the closest point to position constrained by the navigation mesh
  67004. */
  67005. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67006. /**
  67007. * Get a navigation mesh constrained position, within a particular radius
  67008. * @param position world position
  67009. * @param maxRadius the maximum distance to the constrained world position
  67010. * @param result output the closest point to position constrained by the navigation mesh
  67011. */
  67012. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67013. /**
  67014. * Compute the final position from a segment made of destination-position
  67015. * @param position world position
  67016. * @param destination world position
  67017. * @returns the resulting point along the navmesh
  67018. */
  67019. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67020. /**
  67021. * Compute the final position from a segment made of destination-position
  67022. * @param position world position
  67023. * @param destination world position
  67024. * @param result output the resulting point along the navmesh
  67025. */
  67026. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67027. /**
  67028. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67029. * @param start world position
  67030. * @param end world position
  67031. * @returns array containing world position composing the path
  67032. */
  67033. computePath(start: Vector3, end: Vector3): Vector3[];
  67034. /**
  67035. * If this plugin is supported
  67036. * @returns true if plugin is supported
  67037. */
  67038. isSupported(): boolean;
  67039. /**
  67040. * Create a new Crowd so you can add agents
  67041. * @param maxAgents the maximum agent count in the crowd
  67042. * @param maxAgentRadius the maximum radius an agent can have
  67043. * @param scene to attach the crowd to
  67044. * @returns the crowd you can add agents to
  67045. */
  67046. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67047. /**
  67048. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67049. * The queries will try to find a solution within those bounds
  67050. * default is (1,1,1)
  67051. * @param extent x,y,z value that define the extent around the queries point of reference
  67052. */
  67053. setDefaultQueryExtent(extent: Vector3): void;
  67054. /**
  67055. * Get the Bounding box extent specified by setDefaultQueryExtent
  67056. * @returns the box extent values
  67057. */
  67058. getDefaultQueryExtent(): Vector3;
  67059. /**
  67060. * build the navmesh from a previously saved state using getNavmeshData
  67061. * @param data the Uint8Array returned by getNavmeshData
  67062. */
  67063. buildFromNavmeshData(data: Uint8Array): void;
  67064. /**
  67065. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67066. * @returns data the Uint8Array that can be saved and reused
  67067. */
  67068. getNavmeshData(): Uint8Array;
  67069. /**
  67070. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67071. * @param result output the box extent values
  67072. */
  67073. getDefaultQueryExtentToRef(result: Vector3): void;
  67074. /**
  67075. * Release all resources
  67076. */
  67077. dispose(): void;
  67078. }
  67079. /**
  67080. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67081. */
  67082. export interface ICrowd {
  67083. /**
  67084. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67085. * You can attach anything to that node. The node position is updated in the scene update tick.
  67086. * @param pos world position that will be constrained by the navigation mesh
  67087. * @param parameters agent parameters
  67088. * @param transform hooked to the agent that will be update by the scene
  67089. * @returns agent index
  67090. */
  67091. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67092. /**
  67093. * Returns the agent position in world space
  67094. * @param index agent index returned by addAgent
  67095. * @returns world space position
  67096. */
  67097. getAgentPosition(index: number): Vector3;
  67098. /**
  67099. * Gets the agent position result in world space
  67100. * @param index agent index returned by addAgent
  67101. * @param result output world space position
  67102. */
  67103. getAgentPositionToRef(index: number, result: Vector3): void;
  67104. /**
  67105. * Gets the agent velocity in world space
  67106. * @param index agent index returned by addAgent
  67107. * @returns world space velocity
  67108. */
  67109. getAgentVelocity(index: number): Vector3;
  67110. /**
  67111. * Gets the agent velocity result in world space
  67112. * @param index agent index returned by addAgent
  67113. * @param result output world space velocity
  67114. */
  67115. getAgentVelocityToRef(index: number, result: Vector3): void;
  67116. /**
  67117. * remove a particular agent previously created
  67118. * @param index agent index returned by addAgent
  67119. */
  67120. removeAgent(index: number): void;
  67121. /**
  67122. * get the list of all agents attached to this crowd
  67123. * @returns list of agent indices
  67124. */
  67125. getAgents(): number[];
  67126. /**
  67127. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67128. * @param deltaTime in seconds
  67129. */
  67130. update(deltaTime: number): void;
  67131. /**
  67132. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67133. * @param index agent index returned by addAgent
  67134. * @param destination targeted world position
  67135. */
  67136. agentGoto(index: number, destination: Vector3): void;
  67137. /**
  67138. * Teleport the agent to a new position
  67139. * @param index agent index returned by addAgent
  67140. * @param destination targeted world position
  67141. */
  67142. agentTeleport(index: number, destination: Vector3): void;
  67143. /**
  67144. * Update agent parameters
  67145. * @param index agent index returned by addAgent
  67146. * @param parameters agent parameters
  67147. */
  67148. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67149. /**
  67150. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67151. * The queries will try to find a solution within those bounds
  67152. * default is (1,1,1)
  67153. * @param extent x,y,z value that define the extent around the queries point of reference
  67154. */
  67155. setDefaultQueryExtent(extent: Vector3): void;
  67156. /**
  67157. * Get the Bounding box extent specified by setDefaultQueryExtent
  67158. * @returns the box extent values
  67159. */
  67160. getDefaultQueryExtent(): Vector3;
  67161. /**
  67162. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67163. * @param result output the box extent values
  67164. */
  67165. getDefaultQueryExtentToRef(result: Vector3): void;
  67166. /**
  67167. * Release all resources
  67168. */
  67169. dispose(): void;
  67170. }
  67171. /**
  67172. * Configures an agent
  67173. */
  67174. export interface IAgentParameters {
  67175. /**
  67176. * Agent radius. [Limit: >= 0]
  67177. */
  67178. radius: number;
  67179. /**
  67180. * Agent height. [Limit: > 0]
  67181. */
  67182. height: number;
  67183. /**
  67184. * Maximum allowed acceleration. [Limit: >= 0]
  67185. */
  67186. maxAcceleration: number;
  67187. /**
  67188. * Maximum allowed speed. [Limit: >= 0]
  67189. */
  67190. maxSpeed: number;
  67191. /**
  67192. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67193. */
  67194. collisionQueryRange: number;
  67195. /**
  67196. * The path visibility optimization range. [Limit: > 0]
  67197. */
  67198. pathOptimizationRange: number;
  67199. /**
  67200. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67201. */
  67202. separationWeight: number;
  67203. }
  67204. /**
  67205. * Configures the navigation mesh creation
  67206. */
  67207. export interface INavMeshParameters {
  67208. /**
  67209. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67210. */
  67211. cs: number;
  67212. /**
  67213. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67214. */
  67215. ch: number;
  67216. /**
  67217. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67218. */
  67219. walkableSlopeAngle: number;
  67220. /**
  67221. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67222. * be considered walkable. [Limit: >= 3] [Units: vx]
  67223. */
  67224. walkableHeight: number;
  67225. /**
  67226. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67227. */
  67228. walkableClimb: number;
  67229. /**
  67230. * The distance to erode/shrink the walkable area of the heightfield away from
  67231. * obstructions. [Limit: >=0] [Units: vx]
  67232. */
  67233. walkableRadius: number;
  67234. /**
  67235. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67236. */
  67237. maxEdgeLen: number;
  67238. /**
  67239. * The maximum distance a simplfied contour's border edges should deviate
  67240. * the original raw contour. [Limit: >=0] [Units: vx]
  67241. */
  67242. maxSimplificationError: number;
  67243. /**
  67244. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67245. */
  67246. minRegionArea: number;
  67247. /**
  67248. * Any regions with a span count smaller than this value will, if possible,
  67249. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67250. */
  67251. mergeRegionArea: number;
  67252. /**
  67253. * The maximum number of vertices allowed for polygons generated during the
  67254. * contour to polygon conversion process. [Limit: >= 3]
  67255. */
  67256. maxVertsPerPoly: number;
  67257. /**
  67258. * Sets the sampling distance to use when generating the detail mesh.
  67259. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67260. */
  67261. detailSampleDist: number;
  67262. /**
  67263. * The maximum distance the detail mesh surface should deviate from heightfield
  67264. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67265. */
  67266. detailSampleMaxError: number;
  67267. }
  67268. }
  67269. declare module BABYLON {
  67270. /**
  67271. * RecastJS navigation plugin
  67272. */
  67273. export class RecastJSPlugin implements INavigationEnginePlugin {
  67274. /**
  67275. * Reference to the Recast library
  67276. */
  67277. bjsRECAST: any;
  67278. /**
  67279. * plugin name
  67280. */
  67281. name: string;
  67282. /**
  67283. * the first navmesh created. We might extend this to support multiple navmeshes
  67284. */
  67285. navMesh: any;
  67286. /**
  67287. * Initializes the recastJS plugin
  67288. * @param recastInjection can be used to inject your own recast reference
  67289. */
  67290. constructor(recastInjection?: any);
  67291. /**
  67292. * Creates a navigation mesh
  67293. * @param meshes array of all the geometry used to compute the navigatio mesh
  67294. * @param parameters bunch of parameters used to filter geometry
  67295. */
  67296. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67297. /**
  67298. * Create a navigation mesh debug mesh
  67299. * @param scene is where the mesh will be added
  67300. * @returns debug display mesh
  67301. */
  67302. createDebugNavMesh(scene: Scene): Mesh;
  67303. /**
  67304. * Get a navigation mesh constrained position, closest to the parameter position
  67305. * @param position world position
  67306. * @returns the closest point to position constrained by the navigation mesh
  67307. */
  67308. getClosestPoint(position: Vector3): Vector3;
  67309. /**
  67310. * Get a navigation mesh constrained position, closest to the parameter position
  67311. * @param position world position
  67312. * @param result output the closest point to position constrained by the navigation mesh
  67313. */
  67314. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67315. /**
  67316. * Get a navigation mesh constrained position, within a particular radius
  67317. * @param position world position
  67318. * @param maxRadius the maximum distance to the constrained world position
  67319. * @returns the closest point to position constrained by the navigation mesh
  67320. */
  67321. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67322. /**
  67323. * Get a navigation mesh constrained position, within a particular radius
  67324. * @param position world position
  67325. * @param maxRadius the maximum distance to the constrained world position
  67326. * @param result output the closest point to position constrained by the navigation mesh
  67327. */
  67328. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67329. /**
  67330. * Compute the final position from a segment made of destination-position
  67331. * @param position world position
  67332. * @param destination world position
  67333. * @returns the resulting point along the navmesh
  67334. */
  67335. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67336. /**
  67337. * Compute the final position from a segment made of destination-position
  67338. * @param position world position
  67339. * @param destination world position
  67340. * @param result output the resulting point along the navmesh
  67341. */
  67342. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67343. /**
  67344. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67345. * @param start world position
  67346. * @param end world position
  67347. * @returns array containing world position composing the path
  67348. */
  67349. computePath(start: Vector3, end: Vector3): Vector3[];
  67350. /**
  67351. * Create a new Crowd so you can add agents
  67352. * @param maxAgents the maximum agent count in the crowd
  67353. * @param maxAgentRadius the maximum radius an agent can have
  67354. * @param scene to attach the crowd to
  67355. * @returns the crowd you can add agents to
  67356. */
  67357. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67358. /**
  67359. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67360. * The queries will try to find a solution within those bounds
  67361. * default is (1,1,1)
  67362. * @param extent x,y,z value that define the extent around the queries point of reference
  67363. */
  67364. setDefaultQueryExtent(extent: Vector3): void;
  67365. /**
  67366. * Get the Bounding box extent specified by setDefaultQueryExtent
  67367. * @returns the box extent values
  67368. */
  67369. getDefaultQueryExtent(): Vector3;
  67370. /**
  67371. * build the navmesh from a previously saved state using getNavmeshData
  67372. * @param data the Uint8Array returned by getNavmeshData
  67373. */
  67374. buildFromNavmeshData(data: Uint8Array): void;
  67375. /**
  67376. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67377. * @returns data the Uint8Array that can be saved and reused
  67378. */
  67379. getNavmeshData(): Uint8Array;
  67380. /**
  67381. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67382. * @param result output the box extent values
  67383. */
  67384. getDefaultQueryExtentToRef(result: Vector3): void;
  67385. /**
  67386. * Disposes
  67387. */
  67388. dispose(): void;
  67389. /**
  67390. * If this plugin is supported
  67391. * @returns true if plugin is supported
  67392. */
  67393. isSupported(): boolean;
  67394. }
  67395. /**
  67396. * Recast detour crowd implementation
  67397. */
  67398. export class RecastJSCrowd implements ICrowd {
  67399. /**
  67400. * Recast/detour plugin
  67401. */
  67402. bjsRECASTPlugin: RecastJSPlugin;
  67403. /**
  67404. * Link to the detour crowd
  67405. */
  67406. recastCrowd: any;
  67407. /**
  67408. * One transform per agent
  67409. */
  67410. transforms: TransformNode[];
  67411. /**
  67412. * All agents created
  67413. */
  67414. agents: number[];
  67415. /**
  67416. * Link to the scene is kept to unregister the crowd from the scene
  67417. */
  67418. private _scene;
  67419. /**
  67420. * Observer for crowd updates
  67421. */
  67422. private _onBeforeAnimationsObserver;
  67423. /**
  67424. * Constructor
  67425. * @param plugin recastJS plugin
  67426. * @param maxAgents the maximum agent count in the crowd
  67427. * @param maxAgentRadius the maximum radius an agent can have
  67428. * @param scene to attach the crowd to
  67429. * @returns the crowd you can add agents to
  67430. */
  67431. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67432. /**
  67433. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67434. * You can attach anything to that node. The node position is updated in the scene update tick.
  67435. * @param pos world position that will be constrained by the navigation mesh
  67436. * @param parameters agent parameters
  67437. * @param transform hooked to the agent that will be update by the scene
  67438. * @returns agent index
  67439. */
  67440. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67441. /**
  67442. * Returns the agent position in world space
  67443. * @param index agent index returned by addAgent
  67444. * @returns world space position
  67445. */
  67446. getAgentPosition(index: number): Vector3;
  67447. /**
  67448. * Returns the agent position result in world space
  67449. * @param index agent index returned by addAgent
  67450. * @param result output world space position
  67451. */
  67452. getAgentPositionToRef(index: number, result: Vector3): void;
  67453. /**
  67454. * Returns the agent velocity in world space
  67455. * @param index agent index returned by addAgent
  67456. * @returns world space velocity
  67457. */
  67458. getAgentVelocity(index: number): Vector3;
  67459. /**
  67460. * Returns the agent velocity result in world space
  67461. * @param index agent index returned by addAgent
  67462. * @param result output world space velocity
  67463. */
  67464. getAgentVelocityToRef(index: number, result: Vector3): void;
  67465. /**
  67466. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67467. * @param index agent index returned by addAgent
  67468. * @param destination targeted world position
  67469. */
  67470. agentGoto(index: number, destination: Vector3): void;
  67471. /**
  67472. * Teleport the agent to a new position
  67473. * @param index agent index returned by addAgent
  67474. * @param destination targeted world position
  67475. */
  67476. agentTeleport(index: number, destination: Vector3): void;
  67477. /**
  67478. * Update agent parameters
  67479. * @param index agent index returned by addAgent
  67480. * @param parameters agent parameters
  67481. */
  67482. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67483. /**
  67484. * remove a particular agent previously created
  67485. * @param index agent index returned by addAgent
  67486. */
  67487. removeAgent(index: number): void;
  67488. /**
  67489. * get the list of all agents attached to this crowd
  67490. * @returns list of agent indices
  67491. */
  67492. getAgents(): number[];
  67493. /**
  67494. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67495. * @param deltaTime in seconds
  67496. */
  67497. update(deltaTime: number): void;
  67498. /**
  67499. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67500. * The queries will try to find a solution within those bounds
  67501. * default is (1,1,1)
  67502. * @param extent x,y,z value that define the extent around the queries point of reference
  67503. */
  67504. setDefaultQueryExtent(extent: Vector3): void;
  67505. /**
  67506. * Get the Bounding box extent specified by setDefaultQueryExtent
  67507. * @returns the box extent values
  67508. */
  67509. getDefaultQueryExtent(): Vector3;
  67510. /**
  67511. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67512. * @param result output the box extent values
  67513. */
  67514. getDefaultQueryExtentToRef(result: Vector3): void;
  67515. /**
  67516. * Release all resources
  67517. */
  67518. dispose(): void;
  67519. }
  67520. }
  67521. declare module BABYLON {
  67522. /**
  67523. * Class used to enable access to IndexedDB
  67524. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67525. */
  67526. export class Database implements IOfflineProvider {
  67527. private _callbackManifestChecked;
  67528. private _currentSceneUrl;
  67529. private _db;
  67530. private _enableSceneOffline;
  67531. private _enableTexturesOffline;
  67532. private _manifestVersionFound;
  67533. private _mustUpdateRessources;
  67534. private _hasReachedQuota;
  67535. private _isSupported;
  67536. private _idbFactory;
  67537. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67538. private static IsUASupportingBlobStorage;
  67539. /**
  67540. * Gets a boolean indicating if Database storate is enabled (off by default)
  67541. */
  67542. static IDBStorageEnabled: boolean;
  67543. /**
  67544. * Gets a boolean indicating if scene must be saved in the database
  67545. */
  67546. get enableSceneOffline(): boolean;
  67547. /**
  67548. * Gets a boolean indicating if textures must be saved in the database
  67549. */
  67550. get enableTexturesOffline(): boolean;
  67551. /**
  67552. * Creates a new Database
  67553. * @param urlToScene defines the url to load the scene
  67554. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67555. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67556. */
  67557. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67558. private static _ParseURL;
  67559. private static _ReturnFullUrlLocation;
  67560. private _checkManifestFile;
  67561. /**
  67562. * Open the database and make it available
  67563. * @param successCallback defines the callback to call on success
  67564. * @param errorCallback defines the callback to call on error
  67565. */
  67566. open(successCallback: () => void, errorCallback: () => void): void;
  67567. /**
  67568. * Loads an image from the database
  67569. * @param url defines the url to load from
  67570. * @param image defines the target DOM image
  67571. */
  67572. loadImage(url: string, image: HTMLImageElement): void;
  67573. private _loadImageFromDBAsync;
  67574. private _saveImageIntoDBAsync;
  67575. private _checkVersionFromDB;
  67576. private _loadVersionFromDBAsync;
  67577. private _saveVersionIntoDBAsync;
  67578. /**
  67579. * Loads a file from database
  67580. * @param url defines the URL to load from
  67581. * @param sceneLoaded defines a callback to call on success
  67582. * @param progressCallBack defines a callback to call when progress changed
  67583. * @param errorCallback defines a callback to call on error
  67584. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67585. */
  67586. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67587. private _loadFileAsync;
  67588. private _saveFileAsync;
  67589. /**
  67590. * Validates if xhr data is correct
  67591. * @param xhr defines the request to validate
  67592. * @param dataType defines the expected data type
  67593. * @returns true if data is correct
  67594. */
  67595. private static _ValidateXHRData;
  67596. }
  67597. }
  67598. declare module BABYLON {
  67599. /** @hidden */
  67600. export var gpuUpdateParticlesPixelShader: {
  67601. name: string;
  67602. shader: string;
  67603. };
  67604. }
  67605. declare module BABYLON {
  67606. /** @hidden */
  67607. export var gpuUpdateParticlesVertexShader: {
  67608. name: string;
  67609. shader: string;
  67610. };
  67611. }
  67612. declare module BABYLON {
  67613. /** @hidden */
  67614. export var clipPlaneFragmentDeclaration2: {
  67615. name: string;
  67616. shader: string;
  67617. };
  67618. }
  67619. declare module BABYLON {
  67620. /** @hidden */
  67621. export var gpuRenderParticlesPixelShader: {
  67622. name: string;
  67623. shader: string;
  67624. };
  67625. }
  67626. declare module BABYLON {
  67627. /** @hidden */
  67628. export var clipPlaneVertexDeclaration2: {
  67629. name: string;
  67630. shader: string;
  67631. };
  67632. }
  67633. declare module BABYLON {
  67634. /** @hidden */
  67635. export var gpuRenderParticlesVertexShader: {
  67636. name: string;
  67637. shader: string;
  67638. };
  67639. }
  67640. declare module BABYLON {
  67641. /**
  67642. * This represents a GPU particle system in Babylon
  67643. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67644. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67645. */
  67646. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67647. /**
  67648. * The layer mask we are rendering the particles through.
  67649. */
  67650. layerMask: number;
  67651. private _capacity;
  67652. private _activeCount;
  67653. private _currentActiveCount;
  67654. private _accumulatedCount;
  67655. private _renderEffect;
  67656. private _updateEffect;
  67657. private _buffer0;
  67658. private _buffer1;
  67659. private _spriteBuffer;
  67660. private _updateVAO;
  67661. private _renderVAO;
  67662. private _targetIndex;
  67663. private _sourceBuffer;
  67664. private _targetBuffer;
  67665. private _currentRenderId;
  67666. private _started;
  67667. private _stopped;
  67668. private _timeDelta;
  67669. private _randomTexture;
  67670. private _randomTexture2;
  67671. private _attributesStrideSize;
  67672. private _updateEffectOptions;
  67673. private _randomTextureSize;
  67674. private _actualFrame;
  67675. private _customEffect;
  67676. private readonly _rawTextureWidth;
  67677. /**
  67678. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67679. */
  67680. static get IsSupported(): boolean;
  67681. /**
  67682. * An event triggered when the system is disposed.
  67683. */
  67684. onDisposeObservable: Observable<IParticleSystem>;
  67685. /**
  67686. * Gets the maximum number of particles active at the same time.
  67687. * @returns The max number of active particles.
  67688. */
  67689. getCapacity(): number;
  67690. /**
  67691. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67692. * to override the particles.
  67693. */
  67694. forceDepthWrite: boolean;
  67695. /**
  67696. * Gets or set the number of active particles
  67697. */
  67698. get activeParticleCount(): number;
  67699. set activeParticleCount(value: number);
  67700. private _preWarmDone;
  67701. /**
  67702. * Specifies if the particles are updated in emitter local space or world space.
  67703. */
  67704. isLocal: boolean;
  67705. /** Gets or sets a matrix to use to compute projection */
  67706. defaultProjectionMatrix: Matrix;
  67707. /**
  67708. * Is this system ready to be used/rendered
  67709. * @return true if the system is ready
  67710. */
  67711. isReady(): boolean;
  67712. /**
  67713. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67714. * @returns True if it has been started, otherwise false.
  67715. */
  67716. isStarted(): boolean;
  67717. /**
  67718. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67719. * @returns True if it has been stopped, otherwise false.
  67720. */
  67721. isStopped(): boolean;
  67722. /**
  67723. * Gets a boolean indicating that the system is stopping
  67724. * @returns true if the system is currently stopping
  67725. */
  67726. isStopping(): boolean;
  67727. /**
  67728. * Gets the number of particles active at the same time.
  67729. * @returns The number of active particles.
  67730. */
  67731. getActiveCount(): number;
  67732. /**
  67733. * Starts the particle system and begins to emit
  67734. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67735. */
  67736. start(delay?: number): void;
  67737. /**
  67738. * Stops the particle system.
  67739. */
  67740. stop(): void;
  67741. /**
  67742. * Remove all active particles
  67743. */
  67744. reset(): void;
  67745. /**
  67746. * Returns the string "GPUParticleSystem"
  67747. * @returns a string containing the class name
  67748. */
  67749. getClassName(): string;
  67750. /**
  67751. * Gets the custom effect used to render the particles
  67752. * @param blendMode Blend mode for which the effect should be retrieved
  67753. * @returns The effect
  67754. */
  67755. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67756. /**
  67757. * Sets the custom effect used to render the particles
  67758. * @param effect The effect to set
  67759. * @param blendMode Blend mode for which the effect should be set
  67760. */
  67761. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67762. /** @hidden */
  67763. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67764. /**
  67765. * Observable that will be called just before the particles are drawn
  67766. */
  67767. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67768. /**
  67769. * Gets the name of the particle vertex shader
  67770. */
  67771. get vertexShaderName(): string;
  67772. private _colorGradientsTexture;
  67773. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67774. /**
  67775. * Adds a new color gradient
  67776. * @param gradient defines the gradient to use (between 0 and 1)
  67777. * @param color1 defines the color to affect to the specified gradient
  67778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67779. * @returns the current particle system
  67780. */
  67781. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67782. private _refreshColorGradient;
  67783. /** Force the system to rebuild all gradients that need to be resync */
  67784. forceRefreshGradients(): void;
  67785. /**
  67786. * Remove a specific color gradient
  67787. * @param gradient defines the gradient to remove
  67788. * @returns the current particle system
  67789. */
  67790. removeColorGradient(gradient: number): GPUParticleSystem;
  67791. private _angularSpeedGradientsTexture;
  67792. private _sizeGradientsTexture;
  67793. private _velocityGradientsTexture;
  67794. private _limitVelocityGradientsTexture;
  67795. private _dragGradientsTexture;
  67796. private _addFactorGradient;
  67797. /**
  67798. * Adds a new size gradient
  67799. * @param gradient defines the gradient to use (between 0 and 1)
  67800. * @param factor defines the size factor to affect to the specified gradient
  67801. * @returns the current particle system
  67802. */
  67803. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67804. /**
  67805. * Remove a specific size gradient
  67806. * @param gradient defines the gradient to remove
  67807. * @returns the current particle system
  67808. */
  67809. removeSizeGradient(gradient: number): GPUParticleSystem;
  67810. private _refreshFactorGradient;
  67811. /**
  67812. * Adds a new angular speed gradient
  67813. * @param gradient defines the gradient to use (between 0 and 1)
  67814. * @param factor defines the angular speed to affect to the specified gradient
  67815. * @returns the current particle system
  67816. */
  67817. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67818. /**
  67819. * Remove a specific angular speed gradient
  67820. * @param gradient defines the gradient to remove
  67821. * @returns the current particle system
  67822. */
  67823. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67824. /**
  67825. * Adds a new velocity gradient
  67826. * @param gradient defines the gradient to use (between 0 and 1)
  67827. * @param factor defines the velocity to affect to the specified gradient
  67828. * @returns the current particle system
  67829. */
  67830. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67831. /**
  67832. * Remove a specific velocity gradient
  67833. * @param gradient defines the gradient to remove
  67834. * @returns the current particle system
  67835. */
  67836. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67837. /**
  67838. * Adds a new limit velocity gradient
  67839. * @param gradient defines the gradient to use (between 0 and 1)
  67840. * @param factor defines the limit velocity value to affect to the specified gradient
  67841. * @returns the current particle system
  67842. */
  67843. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67844. /**
  67845. * Remove a specific limit velocity gradient
  67846. * @param gradient defines the gradient to remove
  67847. * @returns the current particle system
  67848. */
  67849. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67850. /**
  67851. * Adds a new drag gradient
  67852. * @param gradient defines the gradient to use (between 0 and 1)
  67853. * @param factor defines the drag value to affect to the specified gradient
  67854. * @returns the current particle system
  67855. */
  67856. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67857. /**
  67858. * Remove a specific drag gradient
  67859. * @param gradient defines the gradient to remove
  67860. * @returns the current particle system
  67861. */
  67862. removeDragGradient(gradient: number): GPUParticleSystem;
  67863. /**
  67864. * Not supported by GPUParticleSystem
  67865. * @param gradient defines the gradient to use (between 0 and 1)
  67866. * @param factor defines the emit rate value to affect to the specified gradient
  67867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67868. * @returns the current particle system
  67869. */
  67870. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67871. /**
  67872. * Not supported by GPUParticleSystem
  67873. * @param gradient defines the gradient to remove
  67874. * @returns the current particle system
  67875. */
  67876. removeEmitRateGradient(gradient: number): IParticleSystem;
  67877. /**
  67878. * Not supported by GPUParticleSystem
  67879. * @param gradient defines the gradient to use (between 0 and 1)
  67880. * @param factor defines the start size value to affect to the specified gradient
  67881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67882. * @returns the current particle system
  67883. */
  67884. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67885. /**
  67886. * Not supported by GPUParticleSystem
  67887. * @param gradient defines the gradient to remove
  67888. * @returns the current particle system
  67889. */
  67890. removeStartSizeGradient(gradient: number): IParticleSystem;
  67891. /**
  67892. * Not supported by GPUParticleSystem
  67893. * @param gradient defines the gradient to use (between 0 and 1)
  67894. * @param min defines the color remap minimal range
  67895. * @param max defines the color remap maximal range
  67896. * @returns the current particle system
  67897. */
  67898. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67899. /**
  67900. * Not supported by GPUParticleSystem
  67901. * @param gradient defines the gradient to remove
  67902. * @returns the current particle system
  67903. */
  67904. removeColorRemapGradient(): IParticleSystem;
  67905. /**
  67906. * Not supported by GPUParticleSystem
  67907. * @param gradient defines the gradient to use (between 0 and 1)
  67908. * @param min defines the alpha remap minimal range
  67909. * @param max defines the alpha remap maximal range
  67910. * @returns the current particle system
  67911. */
  67912. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67913. /**
  67914. * Not supported by GPUParticleSystem
  67915. * @param gradient defines the gradient to remove
  67916. * @returns the current particle system
  67917. */
  67918. removeAlphaRemapGradient(): IParticleSystem;
  67919. /**
  67920. * Not supported by GPUParticleSystem
  67921. * @param gradient defines the gradient to use (between 0 and 1)
  67922. * @param color defines the color to affect to the specified gradient
  67923. * @returns the current particle system
  67924. */
  67925. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67926. /**
  67927. * Not supported by GPUParticleSystem
  67928. * @param gradient defines the gradient to remove
  67929. * @returns the current particle system
  67930. */
  67931. removeRampGradient(): IParticleSystem;
  67932. /**
  67933. * Not supported by GPUParticleSystem
  67934. * @returns the list of ramp gradients
  67935. */
  67936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67937. /**
  67938. * Not supported by GPUParticleSystem
  67939. * Gets or sets a boolean indicating that ramp gradients must be used
  67940. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67941. */
  67942. get useRampGradients(): boolean;
  67943. set useRampGradients(value: boolean);
  67944. /**
  67945. * Not supported by GPUParticleSystem
  67946. * @param gradient defines the gradient to use (between 0 and 1)
  67947. * @param factor defines the life time factor to affect to the specified gradient
  67948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67949. * @returns the current particle system
  67950. */
  67951. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67952. /**
  67953. * Not supported by GPUParticleSystem
  67954. * @param gradient defines the gradient to remove
  67955. * @returns the current particle system
  67956. */
  67957. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67958. /**
  67959. * Instantiates a GPU particle system.
  67960. * 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.
  67961. * @param name The name of the particle system
  67962. * @param options The options used to create the system
  67963. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67964. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67965. * @param customEffect a custom effect used to change the way particles are rendered by default
  67966. */
  67967. constructor(name: string, options: Partial<{
  67968. capacity: number;
  67969. randomTextureSize: number;
  67970. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67971. protected _reset(): void;
  67972. private _createUpdateVAO;
  67973. private _createRenderVAO;
  67974. private _initialize;
  67975. /** @hidden */
  67976. _recreateUpdateEffect(): void;
  67977. private _getEffect;
  67978. /**
  67979. * Fill the defines array according to the current settings of the particle system
  67980. * @param defines Array to be updated
  67981. * @param blendMode blend mode to take into account when updating the array
  67982. */
  67983. fillDefines(defines: Array<string>, blendMode?: number): void;
  67984. /**
  67985. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67986. * @param uniforms Uniforms array to fill
  67987. * @param attributes Attributes array to fill
  67988. * @param samplers Samplers array to fill
  67989. */
  67990. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67991. /** @hidden */
  67992. _recreateRenderEffect(): Effect;
  67993. /**
  67994. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67995. * @param preWarm defines if we are in the pre-warmimg phase
  67996. */
  67997. animate(preWarm?: boolean): void;
  67998. private _createFactorGradientTexture;
  67999. private _createSizeGradientTexture;
  68000. private _createAngularSpeedGradientTexture;
  68001. private _createVelocityGradientTexture;
  68002. private _createLimitVelocityGradientTexture;
  68003. private _createDragGradientTexture;
  68004. private _createColorGradientTexture;
  68005. /**
  68006. * Renders the particle system in its current state
  68007. * @param preWarm defines if the system should only update the particles but not render them
  68008. * @returns the current number of particles
  68009. */
  68010. render(preWarm?: boolean): number;
  68011. /**
  68012. * Rebuilds the particle system
  68013. */
  68014. rebuild(): void;
  68015. private _releaseBuffers;
  68016. private _releaseVAOs;
  68017. /**
  68018. * Disposes the particle system and free the associated resources
  68019. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68020. */
  68021. dispose(disposeTexture?: boolean): void;
  68022. /**
  68023. * Clones the particle system.
  68024. * @param name The name of the cloned object
  68025. * @param newEmitter The new emitter to use
  68026. * @returns the cloned particle system
  68027. */
  68028. clone(name: string, newEmitter: any): GPUParticleSystem;
  68029. /**
  68030. * Serializes the particle system to a JSON object
  68031. * @param serializeTexture defines if the texture must be serialized as well
  68032. * @returns the JSON object
  68033. */
  68034. serialize(serializeTexture?: boolean): any;
  68035. /**
  68036. * Parses a JSON object to create a GPU particle system.
  68037. * @param parsedParticleSystem The JSON object to parse
  68038. * @param sceneOrEngine The scene or the engine to create the particle system in
  68039. * @param rootUrl The root url to use to load external dependencies like texture
  68040. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68041. * @returns the parsed GPU particle system
  68042. */
  68043. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /**
  68048. * Represents a set of particle systems working together to create a specific effect
  68049. */
  68050. export class ParticleSystemSet implements IDisposable {
  68051. /**
  68052. * Gets or sets base Assets URL
  68053. */
  68054. static BaseAssetsUrl: string;
  68055. private _emitterCreationOptions;
  68056. private _emitterNode;
  68057. /**
  68058. * Gets the particle system list
  68059. */
  68060. systems: IParticleSystem[];
  68061. /**
  68062. * Gets the emitter node used with this set
  68063. */
  68064. get emitterNode(): Nullable<TransformNode>;
  68065. /**
  68066. * Creates a new emitter mesh as a sphere
  68067. * @param options defines the options used to create the sphere
  68068. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68069. * @param scene defines the hosting scene
  68070. */
  68071. setEmitterAsSphere(options: {
  68072. diameter: number;
  68073. segments: number;
  68074. color: Color3;
  68075. }, renderingGroupId: number, scene: Scene): void;
  68076. /**
  68077. * Starts all particle systems of the set
  68078. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68079. */
  68080. start(emitter?: AbstractMesh): void;
  68081. /**
  68082. * Release all associated resources
  68083. */
  68084. dispose(): void;
  68085. /**
  68086. * Serialize the set into a JSON compatible object
  68087. * @param serializeTexture defines if the texture must be serialized as well
  68088. * @returns a JSON compatible representation of the set
  68089. */
  68090. serialize(serializeTexture?: boolean): any;
  68091. /**
  68092. * Parse a new ParticleSystemSet from a serialized source
  68093. * @param data defines a JSON compatible representation of the set
  68094. * @param scene defines the hosting scene
  68095. * @param gpu defines if we want GPU particles or CPU particles
  68096. * @returns a new ParticleSystemSet
  68097. */
  68098. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /**
  68103. * This class is made for on one-liner static method to help creating particle system set.
  68104. */
  68105. export class ParticleHelper {
  68106. /**
  68107. * Gets or sets base Assets URL
  68108. */
  68109. static BaseAssetsUrl: string;
  68110. /** Define the Url to load snippets */
  68111. static SnippetUrl: string;
  68112. /**
  68113. * Create a default particle system that you can tweak
  68114. * @param emitter defines the emitter to use
  68115. * @param capacity defines the system capacity (default is 500 particles)
  68116. * @param scene defines the hosting scene
  68117. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68118. * @returns the new Particle system
  68119. */
  68120. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68121. /**
  68122. * This is the main static method (one-liner) of this helper to create different particle systems
  68123. * @param type This string represents the type to the particle system to create
  68124. * @param scene The scene where the particle system should live
  68125. * @param gpu If the system will use gpu
  68126. * @returns the ParticleSystemSet created
  68127. */
  68128. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68129. /**
  68130. * Static function used to export a particle system to a ParticleSystemSet variable.
  68131. * Please note that the emitter shape is not exported
  68132. * @param systems defines the particle systems to export
  68133. * @returns the created particle system set
  68134. */
  68135. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68136. /**
  68137. * Creates a particle system from a snippet saved in a remote file
  68138. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68139. * @param url defines the url to load from
  68140. * @param scene defines the hosting scene
  68141. * @param gpu If the system will use gpu
  68142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68143. * @returns a promise that will resolve to the new particle system
  68144. */
  68145. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68146. /**
  68147. * Creates a particle system from a snippet saved by the particle system editor
  68148. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68149. * @param scene defines the hosting scene
  68150. * @param gpu If the system will use gpu
  68151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68152. * @returns a promise that will resolve to the new particle system
  68153. */
  68154. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68155. }
  68156. }
  68157. declare module BABYLON {
  68158. interface Engine {
  68159. /**
  68160. * Create an effect to use with particle systems.
  68161. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68162. * the particle system for which you want to create a custom effect in the last parameter
  68163. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68164. * @param uniformsNames defines a list of attribute names
  68165. * @param samplers defines an array of string used to represent textures
  68166. * @param defines defines the string containing the defines to use to compile the shaders
  68167. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68168. * @param onCompiled defines a function to call when the effect creation is successful
  68169. * @param onError defines a function to call when the effect creation has failed
  68170. * @param particleSystem the particle system you want to create the effect for
  68171. * @returns the new Effect
  68172. */
  68173. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68174. }
  68175. interface Mesh {
  68176. /**
  68177. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68178. * @returns an array of IParticleSystem
  68179. */
  68180. getEmittedParticleSystems(): IParticleSystem[];
  68181. /**
  68182. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68183. * @returns an array of IParticleSystem
  68184. */
  68185. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /** Defines the 4 color options */
  68190. export enum PointColor {
  68191. /** color value */
  68192. Color = 2,
  68193. /** uv value */
  68194. UV = 1,
  68195. /** random value */
  68196. Random = 0,
  68197. /** stated value */
  68198. Stated = 3
  68199. }
  68200. /**
  68201. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68202. * 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.
  68203. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68204. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68205. *
  68206. * Full documentation here : TO BE ENTERED
  68207. */
  68208. export class PointsCloudSystem implements IDisposable {
  68209. /**
  68210. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68211. * Example : var p = SPS.particles[i];
  68212. */
  68213. particles: CloudPoint[];
  68214. /**
  68215. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68216. */
  68217. nbParticles: number;
  68218. /**
  68219. * This a counter for your own usage. It's not set by any SPS functions.
  68220. */
  68221. counter: number;
  68222. /**
  68223. * The PCS name. This name is also given to the underlying mesh.
  68224. */
  68225. name: string;
  68226. /**
  68227. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68228. */
  68229. mesh: Mesh;
  68230. /**
  68231. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68232. * Please read :
  68233. */
  68234. vars: any;
  68235. /**
  68236. * @hidden
  68237. */
  68238. _size: number;
  68239. private _scene;
  68240. private _promises;
  68241. private _positions;
  68242. private _indices;
  68243. private _normals;
  68244. private _colors;
  68245. private _uvs;
  68246. private _indices32;
  68247. private _positions32;
  68248. private _colors32;
  68249. private _uvs32;
  68250. private _updatable;
  68251. private _isVisibilityBoxLocked;
  68252. private _alwaysVisible;
  68253. private _groups;
  68254. private _groupCounter;
  68255. private _computeParticleColor;
  68256. private _computeParticleTexture;
  68257. private _computeParticleRotation;
  68258. private _computeBoundingBox;
  68259. private _isReady;
  68260. /**
  68261. * Creates a PCS (Points Cloud System) object
  68262. * @param name (String) is the PCS name, this will be the underlying mesh name
  68263. * @param pointSize (number) is the size for each point
  68264. * @param scene (Scene) is the scene in which the PCS is added
  68265. * @param options defines the options of the PCS e.g.
  68266. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68267. */
  68268. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68269. updatable?: boolean;
  68270. });
  68271. /**
  68272. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68273. * If no points were added to the PCS, the returned mesh is just a single point.
  68274. * @returns a promise for the created mesh
  68275. */
  68276. buildMeshAsync(): Promise<Mesh>;
  68277. /**
  68278. * @hidden
  68279. */
  68280. private _buildMesh;
  68281. private _addParticle;
  68282. private _randomUnitVector;
  68283. private _getColorIndicesForCoord;
  68284. private _setPointsColorOrUV;
  68285. private _colorFromTexture;
  68286. private _calculateDensity;
  68287. /**
  68288. * Adds points to the PCS in random positions within a unit sphere
  68289. * @param nb (positive integer) the number of particles to be created from this model
  68290. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68291. * @returns the number of groups in the system
  68292. */
  68293. addPoints(nb: number, pointFunction?: any): number;
  68294. /**
  68295. * Adds points to the PCS from the surface of the model shape
  68296. * @param mesh is any Mesh object that will be used as a surface model for the points
  68297. * @param nb (positive integer) the number of particles to be created from this model
  68298. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68299. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68300. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68301. * @returns the number of groups in the system
  68302. */
  68303. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68304. /**
  68305. * Adds points to the PCS inside the model shape
  68306. * @param mesh is any Mesh object that will be used as a surface model for the points
  68307. * @param nb (positive integer) the number of particles to be created from this model
  68308. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68309. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68310. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68311. * @returns the number of groups in the system
  68312. */
  68313. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68314. /**
  68315. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68316. * This method calls `updateParticle()` for each particle of the SPS.
  68317. * For an animated SPS, it is usually called within the render loop.
  68318. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68319. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68320. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68321. * @returns the PCS.
  68322. */
  68323. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68324. /**
  68325. * Disposes the PCS.
  68326. */
  68327. dispose(): void;
  68328. /**
  68329. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68330. * doc :
  68331. * @returns the PCS.
  68332. */
  68333. refreshVisibleSize(): PointsCloudSystem;
  68334. /**
  68335. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68336. * @param size the size (float) of the visibility box
  68337. * note : this doesn't lock the PCS mesh bounding box.
  68338. * doc :
  68339. */
  68340. setVisibilityBox(size: number): void;
  68341. /**
  68342. * Gets whether the PCS is always visible or not
  68343. * doc :
  68344. */
  68345. get isAlwaysVisible(): boolean;
  68346. /**
  68347. * Sets the PCS as always visible or not
  68348. * doc :
  68349. */
  68350. set isAlwaysVisible(val: boolean);
  68351. /**
  68352. * Tells to `setParticles()` to compute the particle rotations or not
  68353. * Default value : false. The PCS is faster when it's set to false
  68354. * Note : particle rotations are only applied to parent particles
  68355. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68356. */
  68357. set computeParticleRotation(val: boolean);
  68358. /**
  68359. * Tells to `setParticles()` to compute the particle colors or not.
  68360. * Default value : true. The PCS is faster when it's set to false.
  68361. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68362. */
  68363. set computeParticleColor(val: boolean);
  68364. set computeParticleTexture(val: boolean);
  68365. /**
  68366. * Gets if `setParticles()` computes the particle colors or not.
  68367. * Default value : false. The PCS is faster when it's set to false.
  68368. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68369. */
  68370. get computeParticleColor(): boolean;
  68371. /**
  68372. * Gets if `setParticles()` computes the particle textures or not.
  68373. * Default value : false. The PCS is faster when it's set to false.
  68374. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68375. */
  68376. get computeParticleTexture(): boolean;
  68377. /**
  68378. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68379. */
  68380. set computeBoundingBox(val: boolean);
  68381. /**
  68382. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68383. */
  68384. get computeBoundingBox(): boolean;
  68385. /**
  68386. * This function does nothing. It may be overwritten to set all the particle first values.
  68387. * The PCS doesn't call this function, you may have to call it by your own.
  68388. * doc :
  68389. */
  68390. initParticles(): void;
  68391. /**
  68392. * This function does nothing. It may be overwritten to recycle a particle
  68393. * The PCS doesn't call this function, you can to call it
  68394. * doc :
  68395. * @param particle The particle to recycle
  68396. * @returns the recycled particle
  68397. */
  68398. recycleParticle(particle: CloudPoint): CloudPoint;
  68399. /**
  68400. * Updates a particle : this function should be overwritten by the user.
  68401. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68402. * doc :
  68403. * @example : just set a particle position or velocity and recycle conditions
  68404. * @param particle The particle to update
  68405. * @returns the updated particle
  68406. */
  68407. updateParticle(particle: CloudPoint): CloudPoint;
  68408. /**
  68409. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68410. * This does nothing and may be overwritten by the user.
  68411. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68412. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68413. * @param update the boolean update value actually passed to setParticles()
  68414. */
  68415. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68416. /**
  68417. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68418. * This will be passed three parameters.
  68419. * This does nothing and may be overwritten by the user.
  68420. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68421. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68422. * @param update the boolean update value actually passed to setParticles()
  68423. */
  68424. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68425. }
  68426. }
  68427. declare module BABYLON {
  68428. /**
  68429. * Represents one particle of a points cloud system.
  68430. */
  68431. export class CloudPoint {
  68432. /**
  68433. * particle global index
  68434. */
  68435. idx: number;
  68436. /**
  68437. * The color of the particle
  68438. */
  68439. color: Nullable<Color4>;
  68440. /**
  68441. * The world space position of the particle.
  68442. */
  68443. position: Vector3;
  68444. /**
  68445. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68446. */
  68447. rotation: Vector3;
  68448. /**
  68449. * The world space rotation quaternion of the particle.
  68450. */
  68451. rotationQuaternion: Nullable<Quaternion>;
  68452. /**
  68453. * The uv of the particle.
  68454. */
  68455. uv: Nullable<Vector2>;
  68456. /**
  68457. * The current speed of the particle.
  68458. */
  68459. velocity: Vector3;
  68460. /**
  68461. * The pivot point in the particle local space.
  68462. */
  68463. pivot: Vector3;
  68464. /**
  68465. * Must the particle be translated from its pivot point in its local space ?
  68466. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68467. * Default : false
  68468. */
  68469. translateFromPivot: boolean;
  68470. /**
  68471. * Index of this particle in the global "positions" array (Internal use)
  68472. * @hidden
  68473. */
  68474. _pos: number;
  68475. /**
  68476. * @hidden Index of this particle in the global "indices" array (Internal use)
  68477. */
  68478. _ind: number;
  68479. /**
  68480. * Group this particle belongs to
  68481. */
  68482. _group: PointsGroup;
  68483. /**
  68484. * Group id of this particle
  68485. */
  68486. groupId: number;
  68487. /**
  68488. * Index of the particle in its group id (Internal use)
  68489. */
  68490. idxInGroup: number;
  68491. /**
  68492. * @hidden Particle BoundingInfo object (Internal use)
  68493. */
  68494. _boundingInfo: BoundingInfo;
  68495. /**
  68496. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68497. */
  68498. _pcs: PointsCloudSystem;
  68499. /**
  68500. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68501. */
  68502. _stillInvisible: boolean;
  68503. /**
  68504. * @hidden Last computed particle rotation matrix
  68505. */
  68506. _rotationMatrix: number[];
  68507. /**
  68508. * Parent particle Id, if any.
  68509. * Default null.
  68510. */
  68511. parentId: Nullable<number>;
  68512. /**
  68513. * @hidden Internal global position in the PCS.
  68514. */
  68515. _globalPosition: Vector3;
  68516. /**
  68517. * Creates a Point Cloud object.
  68518. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68519. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68520. * @param group (PointsGroup) is the group the particle belongs to
  68521. * @param groupId (integer) is the group identifier in the PCS.
  68522. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68523. * @param pcs defines the PCS it is associated to
  68524. */
  68525. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68526. /**
  68527. * get point size
  68528. */
  68529. get size(): Vector3;
  68530. /**
  68531. * Set point size
  68532. */
  68533. set size(scale: Vector3);
  68534. /**
  68535. * Legacy support, changed quaternion to rotationQuaternion
  68536. */
  68537. get quaternion(): Nullable<Quaternion>;
  68538. /**
  68539. * Legacy support, changed quaternion to rotationQuaternion
  68540. */
  68541. set quaternion(q: Nullable<Quaternion>);
  68542. /**
  68543. * Returns a boolean. True if the particle intersects a mesh, else false
  68544. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68545. * @param target is the object (point or mesh) what the intersection is computed against
  68546. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68547. * @returns true if it intersects
  68548. */
  68549. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68550. /**
  68551. * get the rotation matrix of the particle
  68552. * @hidden
  68553. */
  68554. getRotationMatrix(m: Matrix): void;
  68555. }
  68556. /**
  68557. * Represents a group of points in a points cloud system
  68558. * * PCS internal tool, don't use it manually.
  68559. */
  68560. export class PointsGroup {
  68561. /**
  68562. * The group id
  68563. * @hidden
  68564. */
  68565. groupID: number;
  68566. /**
  68567. * image data for group (internal use)
  68568. * @hidden
  68569. */
  68570. _groupImageData: Nullable<ArrayBufferView>;
  68571. /**
  68572. * Image Width (internal use)
  68573. * @hidden
  68574. */
  68575. _groupImgWidth: number;
  68576. /**
  68577. * Image Height (internal use)
  68578. * @hidden
  68579. */
  68580. _groupImgHeight: number;
  68581. /**
  68582. * Custom position function (internal use)
  68583. * @hidden
  68584. */
  68585. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68586. /**
  68587. * density per facet for surface points
  68588. * @hidden
  68589. */
  68590. _groupDensity: number[];
  68591. /**
  68592. * Only when points are colored by texture carries pointer to texture list array
  68593. * @hidden
  68594. */
  68595. _textureNb: number;
  68596. /**
  68597. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68598. * PCS internal tool, don't use it manually.
  68599. * @hidden
  68600. */
  68601. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68602. }
  68603. }
  68604. declare module BABYLON {
  68605. interface Scene {
  68606. /** @hidden (Backing field) */
  68607. _physicsEngine: Nullable<IPhysicsEngine>;
  68608. /** @hidden */
  68609. _physicsTimeAccumulator: number;
  68610. /**
  68611. * Gets the current physics engine
  68612. * @returns a IPhysicsEngine or null if none attached
  68613. */
  68614. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68615. /**
  68616. * Enables physics to the current scene
  68617. * @param gravity defines the scene's gravity for the physics engine
  68618. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68619. * @return a boolean indicating if the physics engine was initialized
  68620. */
  68621. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68622. /**
  68623. * Disables and disposes the physics engine associated with the scene
  68624. */
  68625. disablePhysicsEngine(): void;
  68626. /**
  68627. * Gets a boolean indicating if there is an active physics engine
  68628. * @returns a boolean indicating if there is an active physics engine
  68629. */
  68630. isPhysicsEnabled(): boolean;
  68631. /**
  68632. * Deletes a physics compound impostor
  68633. * @param compound defines the compound to delete
  68634. */
  68635. deleteCompoundImpostor(compound: any): void;
  68636. /**
  68637. * An event triggered when physic simulation is about to be run
  68638. */
  68639. onBeforePhysicsObservable: Observable<Scene>;
  68640. /**
  68641. * An event triggered when physic simulation has been done
  68642. */
  68643. onAfterPhysicsObservable: Observable<Scene>;
  68644. }
  68645. interface AbstractMesh {
  68646. /** @hidden */
  68647. _physicsImpostor: Nullable<PhysicsImpostor>;
  68648. /**
  68649. * Gets or sets impostor used for physic simulation
  68650. * @see https://doc.babylonjs.com/features/physics_engine
  68651. */
  68652. physicsImpostor: Nullable<PhysicsImpostor>;
  68653. /**
  68654. * Gets the current physics impostor
  68655. * @see https://doc.babylonjs.com/features/physics_engine
  68656. * @returns a physics impostor or null
  68657. */
  68658. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68659. /** Apply a physic impulse to the mesh
  68660. * @param force defines the force to apply
  68661. * @param contactPoint defines where to apply the force
  68662. * @returns the current mesh
  68663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68664. */
  68665. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68666. /**
  68667. * Creates a physic joint between two meshes
  68668. * @param otherMesh defines the other mesh to use
  68669. * @param pivot1 defines the pivot to use on this mesh
  68670. * @param pivot2 defines the pivot to use on the other mesh
  68671. * @param options defines additional options (can be plugin dependent)
  68672. * @returns the current mesh
  68673. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68674. */
  68675. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68676. /** @hidden */
  68677. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68678. }
  68679. /**
  68680. * Defines the physics engine scene component responsible to manage a physics engine
  68681. */
  68682. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68683. /**
  68684. * The component name helpful to identify the component in the list of scene components.
  68685. */
  68686. readonly name: string;
  68687. /**
  68688. * The scene the component belongs to.
  68689. */
  68690. scene: Scene;
  68691. /**
  68692. * Creates a new instance of the component for the given scene
  68693. * @param scene Defines the scene to register the component in
  68694. */
  68695. constructor(scene: Scene);
  68696. /**
  68697. * Registers the component in a given scene
  68698. */
  68699. register(): void;
  68700. /**
  68701. * Rebuilds the elements related to this component in case of
  68702. * context lost for instance.
  68703. */
  68704. rebuild(): void;
  68705. /**
  68706. * Disposes the component and the associated ressources
  68707. */
  68708. dispose(): void;
  68709. }
  68710. }
  68711. declare module BABYLON {
  68712. /**
  68713. * A helper for physics simulations
  68714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68715. */
  68716. export class PhysicsHelper {
  68717. private _scene;
  68718. private _physicsEngine;
  68719. /**
  68720. * Initializes the Physics helper
  68721. * @param scene Babylon.js scene
  68722. */
  68723. constructor(scene: Scene);
  68724. /**
  68725. * Applies a radial explosion impulse
  68726. * @param origin the origin of the explosion
  68727. * @param radiusOrEventOptions the radius or the options of radial explosion
  68728. * @param strength the explosion strength
  68729. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68730. * @returns A physics radial explosion event, or null
  68731. */
  68732. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68733. /**
  68734. * Applies a radial explosion force
  68735. * @param origin the origin of the explosion
  68736. * @param radiusOrEventOptions the radius or the options of radial explosion
  68737. * @param strength the explosion strength
  68738. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68739. * @returns A physics radial explosion event, or null
  68740. */
  68741. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68742. /**
  68743. * Creates a gravitational field
  68744. * @param origin the origin of the explosion
  68745. * @param radiusOrEventOptions the radius or the options of radial explosion
  68746. * @param strength the explosion strength
  68747. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68748. * @returns A physics gravitational field event, or null
  68749. */
  68750. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68751. /**
  68752. * Creates a physics updraft event
  68753. * @param origin the origin of the updraft
  68754. * @param radiusOrEventOptions the radius or the options of the updraft
  68755. * @param strength the strength of the updraft
  68756. * @param height the height of the updraft
  68757. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68758. * @returns A physics updraft event, or null
  68759. */
  68760. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68761. /**
  68762. * Creates a physics vortex event
  68763. * @param origin the of the vortex
  68764. * @param radiusOrEventOptions the radius or the options of the vortex
  68765. * @param strength the strength of the vortex
  68766. * @param height the height of the vortex
  68767. * @returns a Physics vortex event, or null
  68768. * A physics vortex event or null
  68769. */
  68770. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68771. }
  68772. /**
  68773. * Represents a physics radial explosion event
  68774. */
  68775. class PhysicsRadialExplosionEvent {
  68776. private _scene;
  68777. private _options;
  68778. private _sphere;
  68779. private _dataFetched;
  68780. /**
  68781. * Initializes a radial explosioin event
  68782. * @param _scene BabylonJS scene
  68783. * @param _options The options for the vortex event
  68784. */
  68785. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68786. /**
  68787. * Returns the data related to the radial explosion event (sphere).
  68788. * @returns The radial explosion event data
  68789. */
  68790. getData(): PhysicsRadialExplosionEventData;
  68791. /**
  68792. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68793. * @param impostor A physics imposter
  68794. * @param origin the origin of the explosion
  68795. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68796. */
  68797. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68798. /**
  68799. * Triggers affecterd impostors callbacks
  68800. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68801. */
  68802. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68803. /**
  68804. * Disposes the sphere.
  68805. * @param force Specifies if the sphere should be disposed by force
  68806. */
  68807. dispose(force?: boolean): void;
  68808. /*** Helpers ***/
  68809. private _prepareSphere;
  68810. private _intersectsWithSphere;
  68811. }
  68812. /**
  68813. * Represents a gravitational field event
  68814. */
  68815. class PhysicsGravitationalFieldEvent {
  68816. private _physicsHelper;
  68817. private _scene;
  68818. private _origin;
  68819. private _options;
  68820. private _tickCallback;
  68821. private _sphere;
  68822. private _dataFetched;
  68823. /**
  68824. * Initializes the physics gravitational field event
  68825. * @param _physicsHelper A physics helper
  68826. * @param _scene BabylonJS scene
  68827. * @param _origin The origin position of the gravitational field event
  68828. * @param _options The options for the vortex event
  68829. */
  68830. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68831. /**
  68832. * Returns the data related to the gravitational field event (sphere).
  68833. * @returns A gravitational field event
  68834. */
  68835. getData(): PhysicsGravitationalFieldEventData;
  68836. /**
  68837. * Enables the gravitational field.
  68838. */
  68839. enable(): void;
  68840. /**
  68841. * Disables the gravitational field.
  68842. */
  68843. disable(): void;
  68844. /**
  68845. * Disposes the sphere.
  68846. * @param force The force to dispose from the gravitational field event
  68847. */
  68848. dispose(force?: boolean): void;
  68849. private _tick;
  68850. }
  68851. /**
  68852. * Represents a physics updraft event
  68853. */
  68854. class PhysicsUpdraftEvent {
  68855. private _scene;
  68856. private _origin;
  68857. private _options;
  68858. private _physicsEngine;
  68859. private _originTop;
  68860. private _originDirection;
  68861. private _tickCallback;
  68862. private _cylinder;
  68863. private _cylinderPosition;
  68864. private _dataFetched;
  68865. /**
  68866. * Initializes the physics updraft event
  68867. * @param _scene BabylonJS scene
  68868. * @param _origin The origin position of the updraft
  68869. * @param _options The options for the updraft event
  68870. */
  68871. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68872. /**
  68873. * Returns the data related to the updraft event (cylinder).
  68874. * @returns A physics updraft event
  68875. */
  68876. getData(): PhysicsUpdraftEventData;
  68877. /**
  68878. * Enables the updraft.
  68879. */
  68880. enable(): void;
  68881. /**
  68882. * Disables the updraft.
  68883. */
  68884. disable(): void;
  68885. /**
  68886. * Disposes the cylinder.
  68887. * @param force Specifies if the updraft should be disposed by force
  68888. */
  68889. dispose(force?: boolean): void;
  68890. private getImpostorHitData;
  68891. private _tick;
  68892. /*** Helpers ***/
  68893. private _prepareCylinder;
  68894. private _intersectsWithCylinder;
  68895. }
  68896. /**
  68897. * Represents a physics vortex event
  68898. */
  68899. class PhysicsVortexEvent {
  68900. private _scene;
  68901. private _origin;
  68902. private _options;
  68903. private _physicsEngine;
  68904. private _originTop;
  68905. private _tickCallback;
  68906. private _cylinder;
  68907. private _cylinderPosition;
  68908. private _dataFetched;
  68909. /**
  68910. * Initializes the physics vortex event
  68911. * @param _scene The BabylonJS scene
  68912. * @param _origin The origin position of the vortex
  68913. * @param _options The options for the vortex event
  68914. */
  68915. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68916. /**
  68917. * Returns the data related to the vortex event (cylinder).
  68918. * @returns The physics vortex event data
  68919. */
  68920. getData(): PhysicsVortexEventData;
  68921. /**
  68922. * Enables the vortex.
  68923. */
  68924. enable(): void;
  68925. /**
  68926. * Disables the cortex.
  68927. */
  68928. disable(): void;
  68929. /**
  68930. * Disposes the sphere.
  68931. * @param force
  68932. */
  68933. dispose(force?: boolean): void;
  68934. private getImpostorHitData;
  68935. private _tick;
  68936. /*** Helpers ***/
  68937. private _prepareCylinder;
  68938. private _intersectsWithCylinder;
  68939. }
  68940. /**
  68941. * Options fot the radial explosion event
  68942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68943. */
  68944. export class PhysicsRadialExplosionEventOptions {
  68945. /**
  68946. * The radius of the sphere for the radial explosion.
  68947. */
  68948. radius: number;
  68949. /**
  68950. * The strenth of the explosion.
  68951. */
  68952. strength: number;
  68953. /**
  68954. * The strenght of the force in correspondence to the distance of the affected object
  68955. */
  68956. falloff: PhysicsRadialImpulseFalloff;
  68957. /**
  68958. * Sphere options for the radial explosion.
  68959. */
  68960. sphere: {
  68961. segments: number;
  68962. diameter: number;
  68963. };
  68964. /**
  68965. * Sphere options for the radial explosion.
  68966. */
  68967. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68968. }
  68969. /**
  68970. * Options fot the updraft event
  68971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68972. */
  68973. export class PhysicsUpdraftEventOptions {
  68974. /**
  68975. * The radius of the cylinder for the vortex
  68976. */
  68977. radius: number;
  68978. /**
  68979. * The strenth of the updraft.
  68980. */
  68981. strength: number;
  68982. /**
  68983. * The height of the cylinder for the updraft.
  68984. */
  68985. height: number;
  68986. /**
  68987. * The mode for the the updraft.
  68988. */
  68989. updraftMode: PhysicsUpdraftMode;
  68990. }
  68991. /**
  68992. * Options fot the vortex event
  68993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68994. */
  68995. export class PhysicsVortexEventOptions {
  68996. /**
  68997. * The radius of the cylinder for the vortex
  68998. */
  68999. radius: number;
  69000. /**
  69001. * The strenth of the vortex.
  69002. */
  69003. strength: number;
  69004. /**
  69005. * The height of the cylinder for the vortex.
  69006. */
  69007. height: number;
  69008. /**
  69009. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69010. */
  69011. centripetalForceThreshold: number;
  69012. /**
  69013. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69014. */
  69015. centripetalForceMultiplier: number;
  69016. /**
  69017. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69018. */
  69019. centrifugalForceMultiplier: number;
  69020. /**
  69021. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69022. */
  69023. updraftForceMultiplier: number;
  69024. }
  69025. /**
  69026. * The strenght of the force in correspondence to the distance of the affected object
  69027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69028. */
  69029. export enum PhysicsRadialImpulseFalloff {
  69030. /** Defines that impulse is constant in strength across it's whole radius */
  69031. Constant = 0,
  69032. /** Defines that impulse gets weaker if it's further from the origin */
  69033. Linear = 1
  69034. }
  69035. /**
  69036. * The strength of the force in correspondence to the distance of the affected object
  69037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69038. */
  69039. export enum PhysicsUpdraftMode {
  69040. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69041. Center = 0,
  69042. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69043. Perpendicular = 1
  69044. }
  69045. /**
  69046. * Interface for a physics hit data
  69047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69048. */
  69049. export interface PhysicsHitData {
  69050. /**
  69051. * The force applied at the contact point
  69052. */
  69053. force: Vector3;
  69054. /**
  69055. * The contact point
  69056. */
  69057. contactPoint: Vector3;
  69058. /**
  69059. * The distance from the origin to the contact point
  69060. */
  69061. distanceFromOrigin: number;
  69062. }
  69063. /**
  69064. * Interface for radial explosion event data
  69065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69066. */
  69067. export interface PhysicsRadialExplosionEventData {
  69068. /**
  69069. * A sphere used for the radial explosion event
  69070. */
  69071. sphere: Mesh;
  69072. }
  69073. /**
  69074. * Interface for gravitational field event data
  69075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69076. */
  69077. export interface PhysicsGravitationalFieldEventData {
  69078. /**
  69079. * A sphere mesh used for the gravitational field event
  69080. */
  69081. sphere: Mesh;
  69082. }
  69083. /**
  69084. * Interface for updraft event data
  69085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69086. */
  69087. export interface PhysicsUpdraftEventData {
  69088. /**
  69089. * A cylinder used for the updraft event
  69090. */
  69091. cylinder: Mesh;
  69092. }
  69093. /**
  69094. * Interface for vortex event data
  69095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69096. */
  69097. export interface PhysicsVortexEventData {
  69098. /**
  69099. * A cylinder used for the vortex event
  69100. */
  69101. cylinder: Mesh;
  69102. }
  69103. /**
  69104. * Interface for an affected physics impostor
  69105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69106. */
  69107. export interface PhysicsAffectedImpostorWithData {
  69108. /**
  69109. * The impostor affected by the effect
  69110. */
  69111. impostor: PhysicsImpostor;
  69112. /**
  69113. * The data about the hit/horce from the explosion
  69114. */
  69115. hitData: PhysicsHitData;
  69116. }
  69117. }
  69118. declare module BABYLON {
  69119. /** @hidden */
  69120. export var blackAndWhitePixelShader: {
  69121. name: string;
  69122. shader: string;
  69123. };
  69124. }
  69125. declare module BABYLON {
  69126. /**
  69127. * Post process used to render in black and white
  69128. */
  69129. export class BlackAndWhitePostProcess extends PostProcess {
  69130. /**
  69131. * Linear about to convert he result to black and white (default: 1)
  69132. */
  69133. degree: number;
  69134. /**
  69135. * Gets a string identifying the name of the class
  69136. * @returns "BlackAndWhitePostProcess" string
  69137. */
  69138. getClassName(): string;
  69139. /**
  69140. * Creates a black and white post process
  69141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69142. * @param name The name of the effect.
  69143. * @param options The required width/height ratio to downsize to before computing the render pass.
  69144. * @param camera The camera to apply the render pass to.
  69145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69146. * @param engine The engine which the post process will be applied. (default: current engine)
  69147. * @param reusable If the post process can be reused on the same frame. (default: false)
  69148. */
  69149. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69150. /** @hidden */
  69151. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69152. }
  69153. }
  69154. declare module BABYLON {
  69155. /**
  69156. * This represents a set of one or more post processes in Babylon.
  69157. * A post process can be used to apply a shader to a texture after it is rendered.
  69158. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69159. */
  69160. export class PostProcessRenderEffect {
  69161. private _postProcesses;
  69162. private _getPostProcesses;
  69163. private _singleInstance;
  69164. private _cameras;
  69165. private _indicesForCamera;
  69166. /**
  69167. * Name of the effect
  69168. * @hidden
  69169. */
  69170. _name: string;
  69171. /**
  69172. * Instantiates a post process render effect.
  69173. * A post process can be used to apply a shader to a texture after it is rendered.
  69174. * @param engine The engine the effect is tied to
  69175. * @param name The name of the effect
  69176. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69177. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69178. */
  69179. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69180. /**
  69181. * Checks if all the post processes in the effect are supported.
  69182. */
  69183. get isSupported(): boolean;
  69184. /**
  69185. * Updates the current state of the effect
  69186. * @hidden
  69187. */
  69188. _update(): void;
  69189. /**
  69190. * Attaches the effect on cameras
  69191. * @param cameras The camera to attach to.
  69192. * @hidden
  69193. */
  69194. _attachCameras(cameras: Camera): void;
  69195. /**
  69196. * Attaches the effect on cameras
  69197. * @param cameras The camera to attach to.
  69198. * @hidden
  69199. */
  69200. _attachCameras(cameras: Camera[]): void;
  69201. /**
  69202. * Detaches the effect on cameras
  69203. * @param cameras The camera to detatch from.
  69204. * @hidden
  69205. */
  69206. _detachCameras(cameras: Camera): void;
  69207. /**
  69208. * Detatches the effect on cameras
  69209. * @param cameras The camera to detatch from.
  69210. * @hidden
  69211. */
  69212. _detachCameras(cameras: Camera[]): void;
  69213. /**
  69214. * Enables the effect on given cameras
  69215. * @param cameras The camera to enable.
  69216. * @hidden
  69217. */
  69218. _enable(cameras: Camera): void;
  69219. /**
  69220. * Enables the effect on given cameras
  69221. * @param cameras The camera to enable.
  69222. * @hidden
  69223. */
  69224. _enable(cameras: Nullable<Camera[]>): void;
  69225. /**
  69226. * Disables the effect on the given cameras
  69227. * @param cameras The camera to disable.
  69228. * @hidden
  69229. */
  69230. _disable(cameras: Camera): void;
  69231. /**
  69232. * Disables the effect on the given cameras
  69233. * @param cameras The camera to disable.
  69234. * @hidden
  69235. */
  69236. _disable(cameras: Nullable<Camera[]>): void;
  69237. /**
  69238. * Gets a list of the post processes contained in the effect.
  69239. * @param camera The camera to get the post processes on.
  69240. * @returns The list of the post processes in the effect.
  69241. */
  69242. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69243. }
  69244. }
  69245. declare module BABYLON {
  69246. /** @hidden */
  69247. export var extractHighlightsPixelShader: {
  69248. name: string;
  69249. shader: string;
  69250. };
  69251. }
  69252. declare module BABYLON {
  69253. /**
  69254. * 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.
  69255. */
  69256. export class ExtractHighlightsPostProcess extends PostProcess {
  69257. /**
  69258. * The luminance threshold, pixels below this value will be set to black.
  69259. */
  69260. threshold: number;
  69261. /** @hidden */
  69262. _exposure: number;
  69263. /**
  69264. * Post process which has the input texture to be used when performing highlight extraction
  69265. * @hidden
  69266. */
  69267. _inputPostProcess: Nullable<PostProcess>;
  69268. /**
  69269. * Gets a string identifying the name of the class
  69270. * @returns "ExtractHighlightsPostProcess" string
  69271. */
  69272. getClassName(): string;
  69273. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69274. }
  69275. }
  69276. declare module BABYLON {
  69277. /** @hidden */
  69278. export var bloomMergePixelShader: {
  69279. name: string;
  69280. shader: string;
  69281. };
  69282. }
  69283. declare module BABYLON {
  69284. /**
  69285. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69286. */
  69287. export class BloomMergePostProcess extends PostProcess {
  69288. /** Weight of the bloom to be added to the original input. */
  69289. weight: number;
  69290. /**
  69291. * Gets a string identifying the name of the class
  69292. * @returns "BloomMergePostProcess" string
  69293. */
  69294. getClassName(): string;
  69295. /**
  69296. * Creates a new instance of @see BloomMergePostProcess
  69297. * @param name The name of the effect.
  69298. * @param originalFromInput Post process which's input will be used for the merge.
  69299. * @param blurred Blurred highlights post process which's output will be used.
  69300. * @param weight Weight of the bloom to be added to the original input.
  69301. * @param options The required width/height ratio to downsize to before computing the render pass.
  69302. * @param camera The camera to apply the render pass to.
  69303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69304. * @param engine The engine which the post process will be applied. (default: current engine)
  69305. * @param reusable If the post process can be reused on the same frame. (default: false)
  69306. * @param textureType Type of textures used when performing the post process. (default: 0)
  69307. * @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)
  69308. */
  69309. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69310. /** Weight of the bloom to be added to the original input. */
  69311. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69312. }
  69313. }
  69314. declare module BABYLON {
  69315. /**
  69316. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69317. */
  69318. export class BloomEffect extends PostProcessRenderEffect {
  69319. private bloomScale;
  69320. /**
  69321. * @hidden Internal
  69322. */
  69323. _effects: Array<PostProcess>;
  69324. /**
  69325. * @hidden Internal
  69326. */
  69327. _downscale: ExtractHighlightsPostProcess;
  69328. private _blurX;
  69329. private _blurY;
  69330. private _merge;
  69331. /**
  69332. * The luminance threshold to find bright areas of the image to bloom.
  69333. */
  69334. get threshold(): number;
  69335. set threshold(value: number);
  69336. /**
  69337. * The strength of the bloom.
  69338. */
  69339. get weight(): number;
  69340. set weight(value: number);
  69341. /**
  69342. * Specifies the size of the bloom blur kernel, relative to the final output size
  69343. */
  69344. get kernel(): number;
  69345. set kernel(value: number);
  69346. /**
  69347. * Creates a new instance of @see BloomEffect
  69348. * @param scene The scene the effect belongs to.
  69349. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69350. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69351. * @param bloomWeight The the strength of bloom.
  69352. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69353. * @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)
  69354. */
  69355. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69356. /**
  69357. * Disposes each of the internal effects for a given camera.
  69358. * @param camera The camera to dispose the effect on.
  69359. */
  69360. disposeEffects(camera: Camera): void;
  69361. /**
  69362. * @hidden Internal
  69363. */
  69364. _updateEffects(): void;
  69365. /**
  69366. * Internal
  69367. * @returns if all the contained post processes are ready.
  69368. * @hidden
  69369. */
  69370. _isReady(): boolean;
  69371. }
  69372. }
  69373. declare module BABYLON {
  69374. /** @hidden */
  69375. export var chromaticAberrationPixelShader: {
  69376. name: string;
  69377. shader: string;
  69378. };
  69379. }
  69380. declare module BABYLON {
  69381. /**
  69382. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69383. */
  69384. export class ChromaticAberrationPostProcess extends PostProcess {
  69385. /**
  69386. * The amount of seperation of rgb channels (default: 30)
  69387. */
  69388. aberrationAmount: number;
  69389. /**
  69390. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69391. */
  69392. radialIntensity: number;
  69393. /**
  69394. * 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))
  69395. */
  69396. direction: Vector2;
  69397. /**
  69398. * 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))
  69399. */
  69400. centerPosition: Vector2;
  69401. /** The width of the screen to apply the effect on */
  69402. screenWidth: number;
  69403. /** The height of the screen to apply the effect on */
  69404. screenHeight: number;
  69405. /**
  69406. * Gets a string identifying the name of the class
  69407. * @returns "ChromaticAberrationPostProcess" string
  69408. */
  69409. getClassName(): string;
  69410. /**
  69411. * Creates a new instance ChromaticAberrationPostProcess
  69412. * @param name The name of the effect.
  69413. * @param screenWidth The width of the screen to apply the effect on.
  69414. * @param screenHeight The height of the screen to apply the effect on.
  69415. * @param options The required width/height ratio to downsize to before computing the render pass.
  69416. * @param camera The camera to apply the render pass to.
  69417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69418. * @param engine The engine which the post process will be applied. (default: current engine)
  69419. * @param reusable If the post process can be reused on the same frame. (default: false)
  69420. * @param textureType Type of textures used when performing the post process. (default: 0)
  69421. * @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)
  69422. */
  69423. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69424. /** @hidden */
  69425. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69426. }
  69427. }
  69428. declare module BABYLON {
  69429. /** @hidden */
  69430. export var circleOfConfusionPixelShader: {
  69431. name: string;
  69432. shader: string;
  69433. };
  69434. }
  69435. declare module BABYLON {
  69436. /**
  69437. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69438. */
  69439. export class CircleOfConfusionPostProcess extends PostProcess {
  69440. /**
  69441. * 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.
  69442. */
  69443. lensSize: number;
  69444. /**
  69445. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69446. */
  69447. fStop: number;
  69448. /**
  69449. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69450. */
  69451. focusDistance: number;
  69452. /**
  69453. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69454. */
  69455. focalLength: number;
  69456. /**
  69457. * Gets a string identifying the name of the class
  69458. * @returns "CircleOfConfusionPostProcess" string
  69459. */
  69460. getClassName(): string;
  69461. private _depthTexture;
  69462. /**
  69463. * Creates a new instance CircleOfConfusionPostProcess
  69464. * @param name The name of the effect.
  69465. * @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.
  69466. * @param options The required width/height ratio to downsize to before computing the render pass.
  69467. * @param camera The camera to apply the render pass to.
  69468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69469. * @param engine The engine which the post process will be applied. (default: current engine)
  69470. * @param reusable If the post process can be reused on the same frame. (default: false)
  69471. * @param textureType Type of textures used when performing the post process. (default: 0)
  69472. * @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)
  69473. */
  69474. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69475. /**
  69476. * 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.
  69477. */
  69478. set depthTexture(value: RenderTargetTexture);
  69479. }
  69480. }
  69481. declare module BABYLON {
  69482. /** @hidden */
  69483. export var colorCorrectionPixelShader: {
  69484. name: string;
  69485. shader: string;
  69486. };
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. *
  69491. * This post-process allows the modification of rendered colors by using
  69492. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69493. *
  69494. * The object needs to be provided an url to a texture containing the color
  69495. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69496. * Use an image editing software to tweak the LUT to match your needs.
  69497. *
  69498. * For an example of a color LUT, see here:
  69499. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69500. * For explanations on color grading, see here:
  69501. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69502. *
  69503. */
  69504. export class ColorCorrectionPostProcess extends PostProcess {
  69505. private _colorTableTexture;
  69506. /**
  69507. * Gets the color table url used to create the LUT texture
  69508. */
  69509. colorTableUrl: string;
  69510. /**
  69511. * Gets a string identifying the name of the class
  69512. * @returns "ColorCorrectionPostProcess" string
  69513. */
  69514. getClassName(): string;
  69515. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69516. /** @hidden */
  69517. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69518. }
  69519. }
  69520. declare module BABYLON {
  69521. /** @hidden */
  69522. export var convolutionPixelShader: {
  69523. name: string;
  69524. shader: string;
  69525. };
  69526. }
  69527. declare module BABYLON {
  69528. /**
  69529. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69530. * input texture to perform effects such as edge detection or sharpening
  69531. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69532. */
  69533. export class ConvolutionPostProcess extends PostProcess {
  69534. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69535. kernel: number[];
  69536. /**
  69537. * Gets a string identifying the name of the class
  69538. * @returns "ConvolutionPostProcess" string
  69539. */
  69540. getClassName(): string;
  69541. /**
  69542. * Creates a new instance ConvolutionPostProcess
  69543. * @param name The name of the effect.
  69544. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69545. * @param options The required width/height ratio to downsize to before computing the render pass.
  69546. * @param camera The camera to apply the render pass to.
  69547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69548. * @param engine The engine which the post process will be applied. (default: current engine)
  69549. * @param reusable If the post process can be reused on the same frame. (default: false)
  69550. * @param textureType Type of textures used when performing the post process. (default: 0)
  69551. */
  69552. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69553. /** @hidden */
  69554. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69555. /**
  69556. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69557. */
  69558. static EdgeDetect0Kernel: number[];
  69559. /**
  69560. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69561. */
  69562. static EdgeDetect1Kernel: number[];
  69563. /**
  69564. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69565. */
  69566. static EdgeDetect2Kernel: number[];
  69567. /**
  69568. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69569. */
  69570. static SharpenKernel: number[];
  69571. /**
  69572. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69573. */
  69574. static EmbossKernel: number[];
  69575. /**
  69576. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69577. */
  69578. static GaussianKernel: number[];
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69584. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69585. * based on samples that have a large difference in distance than the center pixel.
  69586. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69587. */
  69588. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69589. /**
  69590. * The direction the blur should be applied
  69591. */
  69592. direction: Vector2;
  69593. /**
  69594. * Gets a string identifying the name of the class
  69595. * @returns "DepthOfFieldBlurPostProcess" string
  69596. */
  69597. getClassName(): string;
  69598. /**
  69599. * Creates a new instance CircleOfConfusionPostProcess
  69600. * @param name The name of the effect.
  69601. * @param scene The scene the effect belongs to.
  69602. * @param direction The direction the blur should be applied.
  69603. * @param kernel The size of the kernel used to blur.
  69604. * @param options The required width/height ratio to downsize to before computing the render pass.
  69605. * @param camera The camera to apply the render pass to.
  69606. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69607. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69609. * @param engine The engine which the post process will be applied. (default: current engine)
  69610. * @param reusable If the post process can be reused on the same frame. (default: false)
  69611. * @param textureType Type of textures used when performing the post process. (default: 0)
  69612. * @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)
  69613. */
  69614. 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);
  69615. }
  69616. }
  69617. declare module BABYLON {
  69618. /** @hidden */
  69619. export var depthOfFieldMergePixelShader: {
  69620. name: string;
  69621. shader: string;
  69622. };
  69623. }
  69624. declare module BABYLON {
  69625. /**
  69626. * Options to be set when merging outputs from the default pipeline.
  69627. */
  69628. export class DepthOfFieldMergePostProcessOptions {
  69629. /**
  69630. * The original image to merge on top of
  69631. */
  69632. originalFromInput: PostProcess;
  69633. /**
  69634. * Parameters to perform the merge of the depth of field effect
  69635. */
  69636. depthOfField?: {
  69637. circleOfConfusion: PostProcess;
  69638. blurSteps: Array<PostProcess>;
  69639. };
  69640. /**
  69641. * Parameters to perform the merge of bloom effect
  69642. */
  69643. bloom?: {
  69644. blurred: PostProcess;
  69645. weight: number;
  69646. };
  69647. }
  69648. /**
  69649. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69650. */
  69651. export class DepthOfFieldMergePostProcess extends PostProcess {
  69652. private blurSteps;
  69653. /**
  69654. * Gets a string identifying the name of the class
  69655. * @returns "DepthOfFieldMergePostProcess" string
  69656. */
  69657. getClassName(): string;
  69658. /**
  69659. * Creates a new instance of DepthOfFieldMergePostProcess
  69660. * @param name The name of the effect.
  69661. * @param originalFromInput Post process which's input will be used for the merge.
  69662. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69663. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69664. * @param options The required width/height ratio to downsize to before computing the render pass.
  69665. * @param camera The camera to apply the render pass to.
  69666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69667. * @param engine The engine which the post process will be applied. (default: current engine)
  69668. * @param reusable If the post process can be reused on the same frame. (default: false)
  69669. * @param textureType Type of textures used when performing the post process. (default: 0)
  69670. * @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)
  69671. */
  69672. 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);
  69673. /**
  69674. * Updates the effect with the current post process compile time values and recompiles the shader.
  69675. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69676. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69677. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69678. * @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
  69679. * @param onCompiled Called when the shader has been compiled.
  69680. * @param onError Called if there is an error when compiling a shader.
  69681. */
  69682. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * Specifies the level of max blur that should be applied when using the depth of field effect
  69688. */
  69689. export enum DepthOfFieldEffectBlurLevel {
  69690. /**
  69691. * Subtle blur
  69692. */
  69693. Low = 0,
  69694. /**
  69695. * Medium blur
  69696. */
  69697. Medium = 1,
  69698. /**
  69699. * Large blur
  69700. */
  69701. High = 2
  69702. }
  69703. /**
  69704. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69705. */
  69706. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69707. private _circleOfConfusion;
  69708. /**
  69709. * @hidden Internal, blurs from high to low
  69710. */
  69711. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69712. private _depthOfFieldBlurY;
  69713. private _dofMerge;
  69714. /**
  69715. * @hidden Internal post processes in depth of field effect
  69716. */
  69717. _effects: Array<PostProcess>;
  69718. /**
  69719. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69720. */
  69721. set focalLength(value: number);
  69722. get focalLength(): number;
  69723. /**
  69724. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69725. */
  69726. set fStop(value: number);
  69727. get fStop(): number;
  69728. /**
  69729. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69730. */
  69731. set focusDistance(value: number);
  69732. get focusDistance(): number;
  69733. /**
  69734. * 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.
  69735. */
  69736. set lensSize(value: number);
  69737. get lensSize(): number;
  69738. /**
  69739. * Creates a new instance DepthOfFieldEffect
  69740. * @param scene The scene the effect belongs to.
  69741. * @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.
  69742. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69743. * @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)
  69744. */
  69745. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69746. /**
  69747. * Get the current class name of the current effet
  69748. * @returns "DepthOfFieldEffect"
  69749. */
  69750. getClassName(): string;
  69751. /**
  69752. * 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.
  69753. */
  69754. set depthTexture(value: RenderTargetTexture);
  69755. /**
  69756. * Disposes each of the internal effects for a given camera.
  69757. * @param camera The camera to dispose the effect on.
  69758. */
  69759. disposeEffects(camera: Camera): void;
  69760. /**
  69761. * @hidden Internal
  69762. */
  69763. _updateEffects(): void;
  69764. /**
  69765. * Internal
  69766. * @returns if all the contained post processes are ready.
  69767. * @hidden
  69768. */
  69769. _isReady(): boolean;
  69770. }
  69771. }
  69772. declare module BABYLON {
  69773. /** @hidden */
  69774. export var displayPassPixelShader: {
  69775. name: string;
  69776. shader: string;
  69777. };
  69778. }
  69779. declare module BABYLON {
  69780. /**
  69781. * DisplayPassPostProcess which produces an output the same as it's input
  69782. */
  69783. export class DisplayPassPostProcess extends PostProcess {
  69784. /**
  69785. * Gets a string identifying the name of the class
  69786. * @returns "DisplayPassPostProcess" string
  69787. */
  69788. getClassName(): string;
  69789. /**
  69790. * Creates the DisplayPassPostProcess
  69791. * @param name The name of the effect.
  69792. * @param options The required width/height ratio to downsize to before computing the render pass.
  69793. * @param camera The camera to apply the render pass to.
  69794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69795. * @param engine The engine which the post process will be applied. (default: current engine)
  69796. * @param reusable If the post process can be reused on the same frame. (default: false)
  69797. */
  69798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69799. /** @hidden */
  69800. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69801. }
  69802. }
  69803. declare module BABYLON {
  69804. /** @hidden */
  69805. export var filterPixelShader: {
  69806. name: string;
  69807. shader: string;
  69808. };
  69809. }
  69810. declare module BABYLON {
  69811. /**
  69812. * Applies a kernel filter to the image
  69813. */
  69814. export class FilterPostProcess extends PostProcess {
  69815. /** The matrix to be applied to the image */
  69816. kernelMatrix: Matrix;
  69817. /**
  69818. * Gets a string identifying the name of the class
  69819. * @returns "FilterPostProcess" string
  69820. */
  69821. getClassName(): string;
  69822. /**
  69823. *
  69824. * @param name The name of the effect.
  69825. * @param kernelMatrix The matrix to be applied to the image
  69826. * @param options The required width/height ratio to downsize to before computing the render pass.
  69827. * @param camera The camera to apply the render pass to.
  69828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69829. * @param engine The engine which the post process will be applied. (default: current engine)
  69830. * @param reusable If the post process can be reused on the same frame. (default: false)
  69831. */
  69832. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69833. /** @hidden */
  69834. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69835. }
  69836. }
  69837. declare module BABYLON {
  69838. /** @hidden */
  69839. export var fxaaPixelShader: {
  69840. name: string;
  69841. shader: string;
  69842. };
  69843. }
  69844. declare module BABYLON {
  69845. /** @hidden */
  69846. export var fxaaVertexShader: {
  69847. name: string;
  69848. shader: string;
  69849. };
  69850. }
  69851. declare module BABYLON {
  69852. /**
  69853. * Fxaa post process
  69854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69855. */
  69856. export class FxaaPostProcess extends PostProcess {
  69857. /**
  69858. * Gets a string identifying the name of the class
  69859. * @returns "FxaaPostProcess" string
  69860. */
  69861. getClassName(): string;
  69862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69863. private _getDefines;
  69864. /** @hidden */
  69865. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69866. }
  69867. }
  69868. declare module BABYLON {
  69869. /** @hidden */
  69870. export var grainPixelShader: {
  69871. name: string;
  69872. shader: string;
  69873. };
  69874. }
  69875. declare module BABYLON {
  69876. /**
  69877. * The GrainPostProcess adds noise to the image at mid luminance levels
  69878. */
  69879. export class GrainPostProcess extends PostProcess {
  69880. /**
  69881. * The intensity of the grain added (default: 30)
  69882. */
  69883. intensity: number;
  69884. /**
  69885. * If the grain should be randomized on every frame
  69886. */
  69887. animated: boolean;
  69888. /**
  69889. * Gets a string identifying the name of the class
  69890. * @returns "GrainPostProcess" string
  69891. */
  69892. getClassName(): string;
  69893. /**
  69894. * Creates a new instance of @see GrainPostProcess
  69895. * @param name The name of the effect.
  69896. * @param options The required width/height ratio to downsize to before computing the render pass.
  69897. * @param camera The camera to apply the render pass to.
  69898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69899. * @param engine The engine which the post process will be applied. (default: current engine)
  69900. * @param reusable If the post process can be reused on the same frame. (default: false)
  69901. * @param textureType Type of textures used when performing the post process. (default: 0)
  69902. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69903. */
  69904. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69905. /** @hidden */
  69906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69907. }
  69908. }
  69909. declare module BABYLON {
  69910. /** @hidden */
  69911. export var highlightsPixelShader: {
  69912. name: string;
  69913. shader: string;
  69914. };
  69915. }
  69916. declare module BABYLON {
  69917. /**
  69918. * Extracts highlights from the image
  69919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69920. */
  69921. export class HighlightsPostProcess extends PostProcess {
  69922. /**
  69923. * Gets a string identifying the name of the class
  69924. * @returns "HighlightsPostProcess" string
  69925. */
  69926. getClassName(): string;
  69927. /**
  69928. * Extracts highlights from the image
  69929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69930. * @param name The name of the effect.
  69931. * @param options The required width/height ratio to downsize to before computing the render pass.
  69932. * @param camera The camera to apply the render pass to.
  69933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69934. * @param engine The engine which the post process will be applied. (default: current engine)
  69935. * @param reusable If the post process can be reused on the same frame. (default: false)
  69936. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69937. */
  69938. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69939. }
  69940. }
  69941. declare module BABYLON {
  69942. /** @hidden */
  69943. export var mrtFragmentDeclaration: {
  69944. name: string;
  69945. shader: string;
  69946. };
  69947. }
  69948. declare module BABYLON {
  69949. /** @hidden */
  69950. export var geometryPixelShader: {
  69951. name: string;
  69952. shader: string;
  69953. };
  69954. }
  69955. declare module BABYLON {
  69956. /** @hidden */
  69957. export var geometryVertexShader: {
  69958. name: string;
  69959. shader: string;
  69960. };
  69961. }
  69962. declare module BABYLON {
  69963. /** @hidden */
  69964. interface ISavedTransformationMatrix {
  69965. world: Matrix;
  69966. viewProjection: Matrix;
  69967. }
  69968. /**
  69969. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69970. */
  69971. export class GeometryBufferRenderer {
  69972. /**
  69973. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69974. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69975. */
  69976. static readonly POSITION_TEXTURE_TYPE: number;
  69977. /**
  69978. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69979. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69980. */
  69981. static readonly VELOCITY_TEXTURE_TYPE: number;
  69982. /**
  69983. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69984. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69985. */
  69986. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69987. /**
  69988. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69989. * in order to compute objects velocities when enableVelocity is set to "true"
  69990. * @hidden
  69991. */
  69992. _previousTransformationMatrices: {
  69993. [index: number]: ISavedTransformationMatrix;
  69994. };
  69995. /**
  69996. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69997. * in order to compute objects velocities when enableVelocity is set to "true"
  69998. * @hidden
  69999. */
  70000. _previousBonesTransformationMatrices: {
  70001. [index: number]: Float32Array;
  70002. };
  70003. /**
  70004. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70005. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70006. */
  70007. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70008. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70009. renderTransparentMeshes: boolean;
  70010. private _scene;
  70011. private _resizeObserver;
  70012. private _multiRenderTarget;
  70013. private _ratio;
  70014. private _enablePosition;
  70015. private _enableVelocity;
  70016. private _enableReflectivity;
  70017. private _positionIndex;
  70018. private _velocityIndex;
  70019. private _reflectivityIndex;
  70020. protected _effect: Effect;
  70021. protected _cachedDefines: string;
  70022. /**
  70023. * Set the render list (meshes to be rendered) used in the G buffer.
  70024. */
  70025. set renderList(meshes: Mesh[]);
  70026. /**
  70027. * Gets wether or not G buffer are supported by the running hardware.
  70028. * This requires draw buffer supports
  70029. */
  70030. get isSupported(): boolean;
  70031. /**
  70032. * Returns the index of the given texture type in the G-Buffer textures array
  70033. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70034. * @returns the index of the given texture type in the G-Buffer textures array
  70035. */
  70036. getTextureIndex(textureType: number): number;
  70037. /**
  70038. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70039. */
  70040. get enablePosition(): boolean;
  70041. /**
  70042. * Sets whether or not objects positions are enabled for the G buffer.
  70043. */
  70044. set enablePosition(enable: boolean);
  70045. /**
  70046. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70047. */
  70048. get enableVelocity(): boolean;
  70049. /**
  70050. * Sets wether or not objects velocities are enabled for the G buffer.
  70051. */
  70052. set enableVelocity(enable: boolean);
  70053. /**
  70054. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70055. */
  70056. get enableReflectivity(): boolean;
  70057. /**
  70058. * Sets wether or not objects roughness are enabled for the G buffer.
  70059. */
  70060. set enableReflectivity(enable: boolean);
  70061. /**
  70062. * Gets the scene associated with the buffer.
  70063. */
  70064. get scene(): Scene;
  70065. /**
  70066. * Gets the ratio used by the buffer during its creation.
  70067. * How big is the buffer related to the main canvas.
  70068. */
  70069. get ratio(): number;
  70070. /** @hidden */
  70071. static _SceneComponentInitialization: (scene: Scene) => void;
  70072. /**
  70073. * Creates a new G Buffer for the scene
  70074. * @param scene The scene the buffer belongs to
  70075. * @param ratio How big is the buffer related to the main canvas.
  70076. */
  70077. constructor(scene: Scene, ratio?: number);
  70078. /**
  70079. * Checks wether everything is ready to render a submesh to the G buffer.
  70080. * @param subMesh the submesh to check readiness for
  70081. * @param useInstances is the mesh drawn using instance or not
  70082. * @returns true if ready otherwise false
  70083. */
  70084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70085. /**
  70086. * Gets the current underlying G Buffer.
  70087. * @returns the buffer
  70088. */
  70089. getGBuffer(): MultiRenderTarget;
  70090. /**
  70091. * Gets the number of samples used to render the buffer (anti aliasing).
  70092. */
  70093. get samples(): number;
  70094. /**
  70095. * Sets the number of samples used to render the buffer (anti aliasing).
  70096. */
  70097. set samples(value: number);
  70098. /**
  70099. * Disposes the renderer and frees up associated resources.
  70100. */
  70101. dispose(): void;
  70102. protected _createRenderTargets(): void;
  70103. private _copyBonesTransformationMatrices;
  70104. }
  70105. }
  70106. declare module BABYLON {
  70107. interface Scene {
  70108. /** @hidden (Backing field) */
  70109. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70110. /**
  70111. * Gets or Sets the current geometry buffer associated to the scene.
  70112. */
  70113. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70114. /**
  70115. * Enables a GeometryBufferRender and associates it with the scene
  70116. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70117. * @returns the GeometryBufferRenderer
  70118. */
  70119. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70120. /**
  70121. * Disables the GeometryBufferRender associated with the scene
  70122. */
  70123. disableGeometryBufferRenderer(): void;
  70124. }
  70125. /**
  70126. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70127. * in several rendering techniques.
  70128. */
  70129. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70130. /**
  70131. * The component name helpful to identify the component in the list of scene components.
  70132. */
  70133. readonly name: string;
  70134. /**
  70135. * The scene the component belongs to.
  70136. */
  70137. scene: Scene;
  70138. /**
  70139. * Creates a new instance of the component for the given scene
  70140. * @param scene Defines the scene to register the component in
  70141. */
  70142. constructor(scene: Scene);
  70143. /**
  70144. * Registers the component in a given scene
  70145. */
  70146. register(): void;
  70147. /**
  70148. * Rebuilds the elements related to this component in case of
  70149. * context lost for instance.
  70150. */
  70151. rebuild(): void;
  70152. /**
  70153. * Disposes the component and the associated ressources
  70154. */
  70155. dispose(): void;
  70156. private _gatherRenderTargets;
  70157. }
  70158. }
  70159. declare module BABYLON {
  70160. /** @hidden */
  70161. export var motionBlurPixelShader: {
  70162. name: string;
  70163. shader: string;
  70164. };
  70165. }
  70166. declare module BABYLON {
  70167. /**
  70168. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70169. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70170. * As an example, all you have to do is to create the post-process:
  70171. * var mb = new BABYLON.MotionBlurPostProcess(
  70172. * 'mb', // The name of the effect.
  70173. * scene, // The scene containing the objects to blur according to their velocity.
  70174. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70175. * camera // The camera to apply the render pass to.
  70176. * );
  70177. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70178. */
  70179. export class MotionBlurPostProcess extends PostProcess {
  70180. /**
  70181. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70182. */
  70183. motionStrength: number;
  70184. /**
  70185. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70186. */
  70187. get motionBlurSamples(): number;
  70188. /**
  70189. * Sets the number of iterations to be used for motion blur quality
  70190. */
  70191. set motionBlurSamples(samples: number);
  70192. private _motionBlurSamples;
  70193. private _geometryBufferRenderer;
  70194. /**
  70195. * Gets a string identifying the name of the class
  70196. * @returns "MotionBlurPostProcess" string
  70197. */
  70198. getClassName(): string;
  70199. /**
  70200. * Creates a new instance MotionBlurPostProcess
  70201. * @param name The name of the effect.
  70202. * @param scene The scene containing the objects to blur according to their velocity.
  70203. * @param options The required width/height ratio to downsize to before computing the render pass.
  70204. * @param camera The camera to apply the render pass to.
  70205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70206. * @param engine The engine which the post process will be applied. (default: current engine)
  70207. * @param reusable If the post process can be reused on the same frame. (default: false)
  70208. * @param textureType Type of textures used when performing the post process. (default: 0)
  70209. * @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)
  70210. */
  70211. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70212. /**
  70213. * Excludes the given skinned mesh from computing bones velocities.
  70214. * 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.
  70215. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70216. */
  70217. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70218. /**
  70219. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70220. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70221. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70222. */
  70223. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70224. /**
  70225. * Disposes the post process.
  70226. * @param camera The camera to dispose the post process on.
  70227. */
  70228. dispose(camera?: Camera): void;
  70229. /** @hidden */
  70230. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70231. }
  70232. }
  70233. declare module BABYLON {
  70234. /** @hidden */
  70235. export var refractionPixelShader: {
  70236. name: string;
  70237. shader: string;
  70238. };
  70239. }
  70240. declare module BABYLON {
  70241. /**
  70242. * Post process which applies a refractin texture
  70243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70244. */
  70245. export class RefractionPostProcess extends PostProcess {
  70246. private _refTexture;
  70247. private _ownRefractionTexture;
  70248. /** the base color of the refraction (used to taint the rendering) */
  70249. color: Color3;
  70250. /** simulated refraction depth */
  70251. depth: number;
  70252. /** the coefficient of the base color (0 to remove base color tainting) */
  70253. colorLevel: number;
  70254. /** Gets the url used to load the refraction texture */
  70255. refractionTextureUrl: string;
  70256. /**
  70257. * Gets or sets the refraction texture
  70258. * Please note that you are responsible for disposing the texture if you set it manually
  70259. */
  70260. get refractionTexture(): Texture;
  70261. set refractionTexture(value: Texture);
  70262. /**
  70263. * Gets a string identifying the name of the class
  70264. * @returns "RefractionPostProcess" string
  70265. */
  70266. getClassName(): string;
  70267. /**
  70268. * Initializes the RefractionPostProcess
  70269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70270. * @param name The name of the effect.
  70271. * @param refractionTextureUrl Url of the refraction texture to use
  70272. * @param color the base color of the refraction (used to taint the rendering)
  70273. * @param depth simulated refraction depth
  70274. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70275. * @param camera The camera to apply the render pass to.
  70276. * @param options The required width/height ratio to downsize to before computing the render pass.
  70277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70278. * @param engine The engine which the post process will be applied. (default: current engine)
  70279. * @param reusable If the post process can be reused on the same frame. (default: false)
  70280. */
  70281. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70282. /**
  70283. * Disposes of the post process
  70284. * @param camera Camera to dispose post process on
  70285. */
  70286. dispose(camera: Camera): void;
  70287. /** @hidden */
  70288. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. /** @hidden */
  70293. export var sharpenPixelShader: {
  70294. name: string;
  70295. shader: string;
  70296. };
  70297. }
  70298. declare module BABYLON {
  70299. /**
  70300. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70301. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70302. */
  70303. export class SharpenPostProcess extends PostProcess {
  70304. /**
  70305. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70306. */
  70307. colorAmount: number;
  70308. /**
  70309. * How much sharpness should be applied (default: 0.3)
  70310. */
  70311. edgeAmount: number;
  70312. /**
  70313. * Gets a string identifying the name of the class
  70314. * @returns "SharpenPostProcess" string
  70315. */
  70316. getClassName(): string;
  70317. /**
  70318. * Creates a new instance ConvolutionPostProcess
  70319. * @param name The name of the effect.
  70320. * @param options The required width/height ratio to downsize to before computing the render pass.
  70321. * @param camera The camera to apply the render pass to.
  70322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70323. * @param engine The engine which the post process will be applied. (default: current engine)
  70324. * @param reusable If the post process can be reused on the same frame. (default: false)
  70325. * @param textureType Type of textures used when performing the post process. (default: 0)
  70326. * @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)
  70327. */
  70328. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70329. /** @hidden */
  70330. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70331. }
  70332. }
  70333. declare module BABYLON {
  70334. /**
  70335. * PostProcessRenderPipeline
  70336. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70337. */
  70338. export class PostProcessRenderPipeline {
  70339. private engine;
  70340. private _renderEffects;
  70341. private _renderEffectsForIsolatedPass;
  70342. /**
  70343. * List of inspectable custom properties (used by the Inspector)
  70344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70345. */
  70346. inspectableCustomProperties: IInspectable[];
  70347. /**
  70348. * @hidden
  70349. */
  70350. protected _cameras: Camera[];
  70351. /** @hidden */
  70352. _name: string;
  70353. /**
  70354. * Gets pipeline name
  70355. */
  70356. get name(): string;
  70357. /** Gets the list of attached cameras */
  70358. get cameras(): Camera[];
  70359. /**
  70360. * Initializes a PostProcessRenderPipeline
  70361. * @param engine engine to add the pipeline to
  70362. * @param name name of the pipeline
  70363. */
  70364. constructor(engine: Engine, name: string);
  70365. /**
  70366. * Gets the class name
  70367. * @returns "PostProcessRenderPipeline"
  70368. */
  70369. getClassName(): string;
  70370. /**
  70371. * If all the render effects in the pipeline are supported
  70372. */
  70373. get isSupported(): boolean;
  70374. /**
  70375. * Adds an effect to the pipeline
  70376. * @param renderEffect the effect to add
  70377. */
  70378. addEffect(renderEffect: PostProcessRenderEffect): void;
  70379. /** @hidden */
  70380. _rebuild(): void;
  70381. /** @hidden */
  70382. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70383. /** @hidden */
  70384. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70385. /** @hidden */
  70386. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70387. /** @hidden */
  70388. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70389. /** @hidden */
  70390. _attachCameras(cameras: Camera, unique: boolean): void;
  70391. /** @hidden */
  70392. _attachCameras(cameras: Camera[], unique: boolean): void;
  70393. /** @hidden */
  70394. _detachCameras(cameras: Camera): void;
  70395. /** @hidden */
  70396. _detachCameras(cameras: Nullable<Camera[]>): void;
  70397. /** @hidden */
  70398. _update(): void;
  70399. /** @hidden */
  70400. _reset(): void;
  70401. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70402. /**
  70403. * Sets the required values to the prepass renderer.
  70404. * @param prePassRenderer defines the prepass renderer to setup.
  70405. * @returns true if the pre pass is needed.
  70406. */
  70407. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70408. /**
  70409. * Disposes of the pipeline
  70410. */
  70411. dispose(): void;
  70412. }
  70413. }
  70414. declare module BABYLON {
  70415. /**
  70416. * PostProcessRenderPipelineManager class
  70417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70418. */
  70419. export class PostProcessRenderPipelineManager {
  70420. private _renderPipelines;
  70421. /**
  70422. * Initializes a PostProcessRenderPipelineManager
  70423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70424. */
  70425. constructor();
  70426. /**
  70427. * Gets the list of supported render pipelines
  70428. */
  70429. get supportedPipelines(): PostProcessRenderPipeline[];
  70430. /**
  70431. * Adds a pipeline to the manager
  70432. * @param renderPipeline The pipeline to add
  70433. */
  70434. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70435. /**
  70436. * Attaches a camera to the pipeline
  70437. * @param renderPipelineName The name of the pipeline to attach to
  70438. * @param cameras the camera to attach
  70439. * @param unique if the camera can be attached multiple times to the pipeline
  70440. */
  70441. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70442. /**
  70443. * Detaches a camera from the pipeline
  70444. * @param renderPipelineName The name of the pipeline to detach from
  70445. * @param cameras the camera to detach
  70446. */
  70447. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70448. /**
  70449. * Enables an effect by name on a pipeline
  70450. * @param renderPipelineName the name of the pipeline to enable the effect in
  70451. * @param renderEffectName the name of the effect to enable
  70452. * @param cameras the cameras that the effect should be enabled on
  70453. */
  70454. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70455. /**
  70456. * Disables an effect by name on a pipeline
  70457. * @param renderPipelineName the name of the pipeline to disable the effect in
  70458. * @param renderEffectName the name of the effect to disable
  70459. * @param cameras the cameras that the effect should be disabled on
  70460. */
  70461. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70462. /**
  70463. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70464. */
  70465. update(): void;
  70466. /** @hidden */
  70467. _rebuild(): void;
  70468. /**
  70469. * Disposes of the manager and pipelines
  70470. */
  70471. dispose(): void;
  70472. }
  70473. }
  70474. declare module BABYLON {
  70475. interface Scene {
  70476. /** @hidden (Backing field) */
  70477. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70478. /**
  70479. * Gets the postprocess render pipeline manager
  70480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70481. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70482. */
  70483. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70484. }
  70485. /**
  70486. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70487. */
  70488. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70489. /**
  70490. * The component name helpfull to identify the component in the list of scene components.
  70491. */
  70492. readonly name: string;
  70493. /**
  70494. * The scene the component belongs to.
  70495. */
  70496. scene: Scene;
  70497. /**
  70498. * Creates a new instance of the component for the given scene
  70499. * @param scene Defines the scene to register the component in
  70500. */
  70501. constructor(scene: Scene);
  70502. /**
  70503. * Registers the component in a given scene
  70504. */
  70505. register(): void;
  70506. /**
  70507. * Rebuilds the elements related to this component in case of
  70508. * context lost for instance.
  70509. */
  70510. rebuild(): void;
  70511. /**
  70512. * Disposes the component and the associated ressources
  70513. */
  70514. dispose(): void;
  70515. private _gatherRenderTargets;
  70516. }
  70517. }
  70518. declare module BABYLON {
  70519. /**
  70520. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70521. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70522. */
  70523. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70524. private _scene;
  70525. private _camerasToBeAttached;
  70526. /**
  70527. * ID of the sharpen post process,
  70528. */
  70529. private readonly SharpenPostProcessId;
  70530. /**
  70531. * @ignore
  70532. * ID of the image processing post process;
  70533. */
  70534. readonly ImageProcessingPostProcessId: string;
  70535. /**
  70536. * @ignore
  70537. * ID of the Fast Approximate Anti-Aliasing post process;
  70538. */
  70539. readonly FxaaPostProcessId: string;
  70540. /**
  70541. * ID of the chromatic aberration post process,
  70542. */
  70543. private readonly ChromaticAberrationPostProcessId;
  70544. /**
  70545. * ID of the grain post process
  70546. */
  70547. private readonly GrainPostProcessId;
  70548. /**
  70549. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70550. */
  70551. sharpen: SharpenPostProcess;
  70552. private _sharpenEffect;
  70553. private bloom;
  70554. /**
  70555. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70556. */
  70557. depthOfField: DepthOfFieldEffect;
  70558. /**
  70559. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70560. */
  70561. fxaa: FxaaPostProcess;
  70562. /**
  70563. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70564. */
  70565. imageProcessing: ImageProcessingPostProcess;
  70566. /**
  70567. * Chromatic aberration post process which will shift rgb colors in the image
  70568. */
  70569. chromaticAberration: ChromaticAberrationPostProcess;
  70570. private _chromaticAberrationEffect;
  70571. /**
  70572. * Grain post process which add noise to the image
  70573. */
  70574. grain: GrainPostProcess;
  70575. private _grainEffect;
  70576. /**
  70577. * Glow post process which adds a glow to emissive areas of the image
  70578. */
  70579. private _glowLayer;
  70580. /**
  70581. * Animations which can be used to tweak settings over a period of time
  70582. */
  70583. animations: Animation[];
  70584. private _imageProcessingConfigurationObserver;
  70585. private _sharpenEnabled;
  70586. private _bloomEnabled;
  70587. private _depthOfFieldEnabled;
  70588. private _depthOfFieldBlurLevel;
  70589. private _fxaaEnabled;
  70590. private _imageProcessingEnabled;
  70591. private _defaultPipelineTextureType;
  70592. private _bloomScale;
  70593. private _chromaticAberrationEnabled;
  70594. private _grainEnabled;
  70595. private _buildAllowed;
  70596. /**
  70597. * Gets active scene
  70598. */
  70599. get scene(): Scene;
  70600. /**
  70601. * Enable or disable the sharpen process from the pipeline
  70602. */
  70603. set sharpenEnabled(enabled: boolean);
  70604. get sharpenEnabled(): boolean;
  70605. private _resizeObserver;
  70606. private _hardwareScaleLevel;
  70607. private _bloomKernel;
  70608. /**
  70609. * Specifies the size of the bloom blur kernel, relative to the final output size
  70610. */
  70611. get bloomKernel(): number;
  70612. set bloomKernel(value: number);
  70613. /**
  70614. * Specifies the weight of the bloom in the final rendering
  70615. */
  70616. private _bloomWeight;
  70617. /**
  70618. * Specifies the luma threshold for the area that will be blurred by the bloom
  70619. */
  70620. private _bloomThreshold;
  70621. private _hdr;
  70622. /**
  70623. * The strength of the bloom.
  70624. */
  70625. set bloomWeight(value: number);
  70626. get bloomWeight(): number;
  70627. /**
  70628. * The strength of the bloom.
  70629. */
  70630. set bloomThreshold(value: number);
  70631. get bloomThreshold(): number;
  70632. /**
  70633. * The scale of the bloom, lower value will provide better performance.
  70634. */
  70635. set bloomScale(value: number);
  70636. get bloomScale(): number;
  70637. /**
  70638. * Enable or disable the bloom from the pipeline
  70639. */
  70640. set bloomEnabled(enabled: boolean);
  70641. get bloomEnabled(): boolean;
  70642. private _rebuildBloom;
  70643. /**
  70644. * If the depth of field is enabled.
  70645. */
  70646. get depthOfFieldEnabled(): boolean;
  70647. set depthOfFieldEnabled(enabled: boolean);
  70648. /**
  70649. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70650. */
  70651. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70652. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70653. /**
  70654. * If the anti aliasing is enabled.
  70655. */
  70656. set fxaaEnabled(enabled: boolean);
  70657. get fxaaEnabled(): boolean;
  70658. private _samples;
  70659. /**
  70660. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70661. */
  70662. set samples(sampleCount: number);
  70663. get samples(): number;
  70664. /**
  70665. * If image processing is enabled.
  70666. */
  70667. set imageProcessingEnabled(enabled: boolean);
  70668. get imageProcessingEnabled(): boolean;
  70669. /**
  70670. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70671. */
  70672. set glowLayerEnabled(enabled: boolean);
  70673. get glowLayerEnabled(): boolean;
  70674. /**
  70675. * Gets the glow layer (or null if not defined)
  70676. */
  70677. get glowLayer(): Nullable<GlowLayer>;
  70678. /**
  70679. * Enable or disable the chromaticAberration process from the pipeline
  70680. */
  70681. set chromaticAberrationEnabled(enabled: boolean);
  70682. get chromaticAberrationEnabled(): boolean;
  70683. /**
  70684. * Enable or disable the grain process from the pipeline
  70685. */
  70686. set grainEnabled(enabled: boolean);
  70687. get grainEnabled(): boolean;
  70688. /**
  70689. * @constructor
  70690. * @param name - The rendering pipeline name (default: "")
  70691. * @param hdr - If high dynamic range textures should be used (default: true)
  70692. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70693. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70694. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70695. */
  70696. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70697. /**
  70698. * Get the class name
  70699. * @returns "DefaultRenderingPipeline"
  70700. */
  70701. getClassName(): string;
  70702. /**
  70703. * Force the compilation of the entire pipeline.
  70704. */
  70705. prepare(): void;
  70706. private _hasCleared;
  70707. private _prevPostProcess;
  70708. private _prevPrevPostProcess;
  70709. private _setAutoClearAndTextureSharing;
  70710. private _depthOfFieldSceneObserver;
  70711. private _buildPipeline;
  70712. private _disposePostProcesses;
  70713. /**
  70714. * Adds a camera to the pipeline
  70715. * @param camera the camera to be added
  70716. */
  70717. addCamera(camera: Camera): void;
  70718. /**
  70719. * Removes a camera from the pipeline
  70720. * @param camera the camera to remove
  70721. */
  70722. removeCamera(camera: Camera): void;
  70723. /**
  70724. * Dispose of the pipeline and stop all post processes
  70725. */
  70726. dispose(): void;
  70727. /**
  70728. * Serialize the rendering pipeline (Used when exporting)
  70729. * @returns the serialized object
  70730. */
  70731. serialize(): any;
  70732. /**
  70733. * Parse the serialized pipeline
  70734. * @param source Source pipeline.
  70735. * @param scene The scene to load the pipeline to.
  70736. * @param rootUrl The URL of the serialized pipeline.
  70737. * @returns An instantiated pipeline from the serialized object.
  70738. */
  70739. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /** @hidden */
  70744. export var lensHighlightsPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module BABYLON {
  70750. /** @hidden */
  70751. export var depthOfFieldPixelShader: {
  70752. name: string;
  70753. shader: string;
  70754. };
  70755. }
  70756. declare module BABYLON {
  70757. /**
  70758. * BABYLON.JS Chromatic Aberration GLSL Shader
  70759. * Author: Olivier Guyot
  70760. * Separates very slightly R, G and B colors on the edges of the screen
  70761. * Inspired by Francois Tarlier & Martins Upitis
  70762. */
  70763. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70764. /**
  70765. * @ignore
  70766. * The chromatic aberration PostProcess id in the pipeline
  70767. */
  70768. LensChromaticAberrationEffect: string;
  70769. /**
  70770. * @ignore
  70771. * The highlights enhancing PostProcess id in the pipeline
  70772. */
  70773. HighlightsEnhancingEffect: string;
  70774. /**
  70775. * @ignore
  70776. * The depth-of-field PostProcess id in the pipeline
  70777. */
  70778. LensDepthOfFieldEffect: string;
  70779. private _scene;
  70780. private _depthTexture;
  70781. private _grainTexture;
  70782. private _chromaticAberrationPostProcess;
  70783. private _highlightsPostProcess;
  70784. private _depthOfFieldPostProcess;
  70785. private _edgeBlur;
  70786. private _grainAmount;
  70787. private _chromaticAberration;
  70788. private _distortion;
  70789. private _highlightsGain;
  70790. private _highlightsThreshold;
  70791. private _dofDistance;
  70792. private _dofAperture;
  70793. private _dofDarken;
  70794. private _dofPentagon;
  70795. private _blurNoise;
  70796. /**
  70797. * @constructor
  70798. *
  70799. * Effect parameters are as follow:
  70800. * {
  70801. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70802. * edge_blur: number; // from 0 to x (1 for realism)
  70803. * distortion: number; // from 0 to x (1 for realism)
  70804. * grain_amount: number; // from 0 to 1
  70805. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70806. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70807. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70808. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70809. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70810. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70811. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70812. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70813. * }
  70814. * Note: if an effect parameter is unset, effect is disabled
  70815. *
  70816. * @param name The rendering pipeline name
  70817. * @param parameters - An object containing all parameters (see above)
  70818. * @param scene The scene linked to this pipeline
  70819. * @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)
  70820. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70821. */
  70822. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70823. /**
  70824. * Get the class name
  70825. * @returns "LensRenderingPipeline"
  70826. */
  70827. getClassName(): string;
  70828. /**
  70829. * Gets associated scene
  70830. */
  70831. get scene(): Scene;
  70832. /**
  70833. * Gets or sets the edge blur
  70834. */
  70835. get edgeBlur(): number;
  70836. set edgeBlur(value: number);
  70837. /**
  70838. * Gets or sets the grain amount
  70839. */
  70840. get grainAmount(): number;
  70841. set grainAmount(value: number);
  70842. /**
  70843. * Gets or sets the chromatic aberration amount
  70844. */
  70845. get chromaticAberration(): number;
  70846. set chromaticAberration(value: number);
  70847. /**
  70848. * Gets or sets the depth of field aperture
  70849. */
  70850. get dofAperture(): number;
  70851. set dofAperture(value: number);
  70852. /**
  70853. * Gets or sets the edge distortion
  70854. */
  70855. get edgeDistortion(): number;
  70856. set edgeDistortion(value: number);
  70857. /**
  70858. * Gets or sets the depth of field distortion
  70859. */
  70860. get dofDistortion(): number;
  70861. set dofDistortion(value: number);
  70862. /**
  70863. * Gets or sets the darken out of focus amount
  70864. */
  70865. get darkenOutOfFocus(): number;
  70866. set darkenOutOfFocus(value: number);
  70867. /**
  70868. * Gets or sets a boolean indicating if blur noise is enabled
  70869. */
  70870. get blurNoise(): boolean;
  70871. set blurNoise(value: boolean);
  70872. /**
  70873. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70874. */
  70875. get pentagonBokeh(): boolean;
  70876. set pentagonBokeh(value: boolean);
  70877. /**
  70878. * Gets or sets the highlight grain amount
  70879. */
  70880. get highlightsGain(): number;
  70881. set highlightsGain(value: number);
  70882. /**
  70883. * Gets or sets the highlight threshold
  70884. */
  70885. get highlightsThreshold(): number;
  70886. set highlightsThreshold(value: number);
  70887. /**
  70888. * Sets the amount of blur at the edges
  70889. * @param amount blur amount
  70890. */
  70891. setEdgeBlur(amount: number): void;
  70892. /**
  70893. * Sets edge blur to 0
  70894. */
  70895. disableEdgeBlur(): void;
  70896. /**
  70897. * Sets the amout of grain
  70898. * @param amount Amount of grain
  70899. */
  70900. setGrainAmount(amount: number): void;
  70901. /**
  70902. * Set grain amount to 0
  70903. */
  70904. disableGrain(): void;
  70905. /**
  70906. * Sets the chromatic aberration amount
  70907. * @param amount amount of chromatic aberration
  70908. */
  70909. setChromaticAberration(amount: number): void;
  70910. /**
  70911. * Sets chromatic aberration amount to 0
  70912. */
  70913. disableChromaticAberration(): void;
  70914. /**
  70915. * Sets the EdgeDistortion amount
  70916. * @param amount amount of EdgeDistortion
  70917. */
  70918. setEdgeDistortion(amount: number): void;
  70919. /**
  70920. * Sets edge distortion to 0
  70921. */
  70922. disableEdgeDistortion(): void;
  70923. /**
  70924. * Sets the FocusDistance amount
  70925. * @param amount amount of FocusDistance
  70926. */
  70927. setFocusDistance(amount: number): void;
  70928. /**
  70929. * Disables depth of field
  70930. */
  70931. disableDepthOfField(): void;
  70932. /**
  70933. * Sets the Aperture amount
  70934. * @param amount amount of Aperture
  70935. */
  70936. setAperture(amount: number): void;
  70937. /**
  70938. * Sets the DarkenOutOfFocus amount
  70939. * @param amount amount of DarkenOutOfFocus
  70940. */
  70941. setDarkenOutOfFocus(amount: number): void;
  70942. private _pentagonBokehIsEnabled;
  70943. /**
  70944. * Creates a pentagon bokeh effect
  70945. */
  70946. enablePentagonBokeh(): void;
  70947. /**
  70948. * Disables the pentagon bokeh effect
  70949. */
  70950. disablePentagonBokeh(): void;
  70951. /**
  70952. * Enables noise blur
  70953. */
  70954. enableNoiseBlur(): void;
  70955. /**
  70956. * Disables noise blur
  70957. */
  70958. disableNoiseBlur(): void;
  70959. /**
  70960. * Sets the HighlightsGain amount
  70961. * @param amount amount of HighlightsGain
  70962. */
  70963. setHighlightsGain(amount: number): void;
  70964. /**
  70965. * Sets the HighlightsThreshold amount
  70966. * @param amount amount of HighlightsThreshold
  70967. */
  70968. setHighlightsThreshold(amount: number): void;
  70969. /**
  70970. * Disables highlights
  70971. */
  70972. disableHighlights(): void;
  70973. /**
  70974. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70975. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70976. */
  70977. dispose(disableDepthRender?: boolean): void;
  70978. private _createChromaticAberrationPostProcess;
  70979. private _createHighlightsPostProcess;
  70980. private _createDepthOfFieldPostProcess;
  70981. private _createGrainTexture;
  70982. }
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * Contains all parameters needed for the prepass to perform
  70987. * screen space subsurface scattering
  70988. */
  70989. export class SSAO2Configuration implements PrePassEffectConfiguration {
  70990. /**
  70991. * Is subsurface enabled
  70992. */
  70993. enabled: boolean;
  70994. /**
  70995. * Name of the configuration
  70996. */
  70997. name: string;
  70998. /**
  70999. * Textures that should be present in the MRT for this effect to work
  71000. */
  71001. readonly texturesRequired: number[];
  71002. /**
  71003. * Builds a ssao2 configuration object
  71004. * @param scene The scene
  71005. */
  71006. constructor();
  71007. /**
  71008. * Disposes the configuration
  71009. */
  71010. dispose(): void;
  71011. }
  71012. }
  71013. declare module BABYLON {
  71014. /** @hidden */
  71015. export var ssao2PixelShader: {
  71016. name: string;
  71017. shader: string;
  71018. };
  71019. }
  71020. declare module BABYLON {
  71021. /** @hidden */
  71022. export var ssaoCombinePixelShader: {
  71023. name: string;
  71024. shader: string;
  71025. };
  71026. }
  71027. declare module BABYLON {
  71028. /**
  71029. * Render pipeline to produce ssao effect
  71030. */
  71031. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71032. /**
  71033. * @ignore
  71034. * The PassPostProcess id in the pipeline that contains the original scene color
  71035. */
  71036. SSAOOriginalSceneColorEffect: string;
  71037. /**
  71038. * @ignore
  71039. * The SSAO PostProcess id in the pipeline
  71040. */
  71041. SSAORenderEffect: string;
  71042. /**
  71043. * @ignore
  71044. * The horizontal blur PostProcess id in the pipeline
  71045. */
  71046. SSAOBlurHRenderEffect: string;
  71047. /**
  71048. * @ignore
  71049. * The vertical blur PostProcess id in the pipeline
  71050. */
  71051. SSAOBlurVRenderEffect: string;
  71052. /**
  71053. * @ignore
  71054. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71055. */
  71056. SSAOCombineRenderEffect: string;
  71057. /**
  71058. * The output strength of the SSAO post-process. Default value is 1.0.
  71059. */
  71060. totalStrength: number;
  71061. /**
  71062. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71063. */
  71064. maxZ: number;
  71065. /**
  71066. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71067. */
  71068. minZAspect: number;
  71069. private _samples;
  71070. /**
  71071. * Number of samples used for the SSAO calculations. Default value is 8
  71072. */
  71073. set samples(n: number);
  71074. get samples(): number;
  71075. private _textureSamples;
  71076. /**
  71077. * Number of samples to use for antialiasing
  71078. */
  71079. set textureSamples(n: number);
  71080. get textureSamples(): number;
  71081. /**
  71082. * Force rendering the geometry through geometry buffer
  71083. */
  71084. private _forceGeometryBuffer;
  71085. /**
  71086. * Ratio object used for SSAO ratio and blur ratio
  71087. */
  71088. private _ratio;
  71089. /**
  71090. * Dynamically generated sphere sampler.
  71091. */
  71092. private _sampleSphere;
  71093. private _ssao2PrePassConfiguration;
  71094. /**
  71095. * Blur filter offsets
  71096. */
  71097. private _samplerOffsets;
  71098. private _expensiveBlur;
  71099. /**
  71100. * If bilateral blur should be used
  71101. */
  71102. set expensiveBlur(b: boolean);
  71103. get expensiveBlur(): boolean;
  71104. /**
  71105. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71106. */
  71107. radius: number;
  71108. /**
  71109. * The base color of the SSAO post-process
  71110. * The final result is "base + ssao" between [0, 1]
  71111. */
  71112. base: number;
  71113. /**
  71114. * Support test.
  71115. */
  71116. static get IsSupported(): boolean;
  71117. private _scene;
  71118. private _randomTexture;
  71119. private _originalColorPostProcess;
  71120. private _ssaoPostProcess;
  71121. private _blurHPostProcess;
  71122. private _blurVPostProcess;
  71123. private _ssaoCombinePostProcess;
  71124. private _prePassRenderer;
  71125. /**
  71126. * Gets active scene
  71127. */
  71128. get scene(): Scene;
  71129. /**
  71130. * @constructor
  71131. * @param name The rendering pipeline name
  71132. * @param scene The scene linked to this pipeline
  71133. * @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 }
  71134. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71135. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71136. */
  71137. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71138. /**
  71139. * Get the class name
  71140. * @returns "SSAO2RenderingPipeline"
  71141. */
  71142. getClassName(): string;
  71143. /**
  71144. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71145. */
  71146. dispose(disableGeometryBufferRenderer?: boolean): void;
  71147. private _createBlurPostProcess;
  71148. /** @hidden */
  71149. _rebuild(): void;
  71150. private _bits;
  71151. private _radicalInverse_VdC;
  71152. private _hammersley;
  71153. private _hemisphereSample_uniform;
  71154. private _generateHemisphere;
  71155. private _getDefinesForSSAO;
  71156. private _createSSAOPostProcess;
  71157. private _createSSAOCombinePostProcess;
  71158. private _createRandomTexture;
  71159. /**
  71160. * Serialize the rendering pipeline (Used when exporting)
  71161. * @returns the serialized object
  71162. */
  71163. serialize(): any;
  71164. /**
  71165. * Parse the serialized pipeline
  71166. * @param source Source pipeline.
  71167. * @param scene The scene to load the pipeline to.
  71168. * @param rootUrl The URL of the serialized pipeline.
  71169. * @returns An instantiated pipeline from the serialized object.
  71170. */
  71171. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71172. /**
  71173. * Sets the required values to the prepass renderer.
  71174. * @param prePassRenderer defines the prepass renderer to setup
  71175. * @returns true if the pre pass is needed.
  71176. */
  71177. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71178. }
  71179. }
  71180. declare module BABYLON {
  71181. /** @hidden */
  71182. export var ssaoPixelShader: {
  71183. name: string;
  71184. shader: string;
  71185. };
  71186. }
  71187. declare module BABYLON {
  71188. /**
  71189. * Render pipeline to produce ssao effect
  71190. */
  71191. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71192. /**
  71193. * @ignore
  71194. * The PassPostProcess id in the pipeline that contains the original scene color
  71195. */
  71196. SSAOOriginalSceneColorEffect: string;
  71197. /**
  71198. * @ignore
  71199. * The SSAO PostProcess id in the pipeline
  71200. */
  71201. SSAORenderEffect: string;
  71202. /**
  71203. * @ignore
  71204. * The horizontal blur PostProcess id in the pipeline
  71205. */
  71206. SSAOBlurHRenderEffect: string;
  71207. /**
  71208. * @ignore
  71209. * The vertical blur PostProcess id in the pipeline
  71210. */
  71211. SSAOBlurVRenderEffect: string;
  71212. /**
  71213. * @ignore
  71214. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71215. */
  71216. SSAOCombineRenderEffect: string;
  71217. /**
  71218. * The output strength of the SSAO post-process. Default value is 1.0.
  71219. */
  71220. totalStrength: number;
  71221. /**
  71222. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71223. */
  71224. radius: number;
  71225. /**
  71226. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71227. * Must not be equal to fallOff and superior to fallOff.
  71228. * Default value is 0.0075
  71229. */
  71230. area: number;
  71231. /**
  71232. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71233. * Must not be equal to area and inferior to area.
  71234. * Default value is 0.000001
  71235. */
  71236. fallOff: number;
  71237. /**
  71238. * The base color of the SSAO post-process
  71239. * The final result is "base + ssao" between [0, 1]
  71240. */
  71241. base: number;
  71242. private _scene;
  71243. private _depthTexture;
  71244. private _randomTexture;
  71245. private _originalColorPostProcess;
  71246. private _ssaoPostProcess;
  71247. private _blurHPostProcess;
  71248. private _blurVPostProcess;
  71249. private _ssaoCombinePostProcess;
  71250. private _firstUpdate;
  71251. /**
  71252. * Gets active scene
  71253. */
  71254. get scene(): Scene;
  71255. /**
  71256. * @constructor
  71257. * @param name - The rendering pipeline name
  71258. * @param scene - The scene linked to this pipeline
  71259. * @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 }
  71260. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71261. */
  71262. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71263. /**
  71264. * Get the class name
  71265. * @returns "SSAORenderingPipeline"
  71266. */
  71267. getClassName(): string;
  71268. /**
  71269. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71270. */
  71271. dispose(disableDepthRender?: boolean): void;
  71272. private _createBlurPostProcess;
  71273. /** @hidden */
  71274. _rebuild(): void;
  71275. private _createSSAOPostProcess;
  71276. private _createSSAOCombinePostProcess;
  71277. private _createRandomTexture;
  71278. }
  71279. }
  71280. declare module BABYLON {
  71281. /** @hidden */
  71282. export var screenSpaceReflectionPixelShader: {
  71283. name: string;
  71284. shader: string;
  71285. };
  71286. }
  71287. declare module BABYLON {
  71288. /**
  71289. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71290. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71291. */
  71292. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71293. /**
  71294. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71295. */
  71296. threshold: number;
  71297. /**
  71298. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71299. */
  71300. strength: number;
  71301. /**
  71302. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71303. */
  71304. reflectionSpecularFalloffExponent: number;
  71305. /**
  71306. * 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]
  71307. */
  71308. step: number;
  71309. /**
  71310. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71311. */
  71312. roughnessFactor: number;
  71313. private _geometryBufferRenderer;
  71314. private _enableSmoothReflections;
  71315. private _reflectionSamples;
  71316. private _smoothSteps;
  71317. /**
  71318. * Gets a string identifying the name of the class
  71319. * @returns "ScreenSpaceReflectionPostProcess" string
  71320. */
  71321. getClassName(): string;
  71322. /**
  71323. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71324. * @param name The name of the effect.
  71325. * @param scene The scene containing the objects to calculate reflections.
  71326. * @param options The required width/height ratio to downsize to before computing the render pass.
  71327. * @param camera The camera to apply the render pass to.
  71328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71329. * @param engine The engine which the post process will be applied. (default: current engine)
  71330. * @param reusable If the post process can be reused on the same frame. (default: false)
  71331. * @param textureType Type of textures used when performing the post process. (default: 0)
  71332. * @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)
  71333. */
  71334. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71335. /**
  71336. * Gets wether or not smoothing reflections is enabled.
  71337. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71338. */
  71339. get enableSmoothReflections(): boolean;
  71340. /**
  71341. * Sets wether or not smoothing reflections is enabled.
  71342. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71343. */
  71344. set enableSmoothReflections(enabled: boolean);
  71345. /**
  71346. * Gets the number of samples taken while computing reflections. More samples count is high,
  71347. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71348. */
  71349. get reflectionSamples(): number;
  71350. /**
  71351. * Sets the number of samples taken while computing reflections. More samples count is high,
  71352. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71353. */
  71354. set reflectionSamples(samples: number);
  71355. /**
  71356. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71357. * more the post-process will require GPU power and can generate a drop in FPS.
  71358. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71359. */
  71360. get smoothSteps(): number;
  71361. set smoothSteps(steps: number);
  71362. private _updateEffectDefines;
  71363. /** @hidden */
  71364. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71365. }
  71366. }
  71367. declare module BABYLON {
  71368. /** @hidden */
  71369. export var standardPixelShader: {
  71370. name: string;
  71371. shader: string;
  71372. };
  71373. }
  71374. declare module BABYLON {
  71375. /**
  71376. * Standard rendering pipeline
  71377. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71378. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71379. */
  71380. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71381. /**
  71382. * Public members
  71383. */
  71384. /**
  71385. * Post-process which contains the original scene color before the pipeline applies all the effects
  71386. */
  71387. originalPostProcess: Nullable<PostProcess>;
  71388. /**
  71389. * Post-process used to down scale an image x4
  71390. */
  71391. downSampleX4PostProcess: Nullable<PostProcess>;
  71392. /**
  71393. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71394. */
  71395. brightPassPostProcess: Nullable<PostProcess>;
  71396. /**
  71397. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71398. */
  71399. blurHPostProcesses: PostProcess[];
  71400. /**
  71401. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71402. */
  71403. blurVPostProcesses: PostProcess[];
  71404. /**
  71405. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71406. */
  71407. textureAdderPostProcess: Nullable<PostProcess>;
  71408. /**
  71409. * Post-process used to create volumetric lighting effect
  71410. */
  71411. volumetricLightPostProcess: Nullable<PostProcess>;
  71412. /**
  71413. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71414. */
  71415. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71416. /**
  71417. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71418. */
  71419. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71420. /**
  71421. * Post-process used to merge the volumetric light effect and the real scene color
  71422. */
  71423. volumetricLightMergePostProces: Nullable<PostProcess>;
  71424. /**
  71425. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71426. */
  71427. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71428. /**
  71429. * Base post-process used to calculate the average luminance of the final image for HDR
  71430. */
  71431. luminancePostProcess: Nullable<PostProcess>;
  71432. /**
  71433. * Post-processes used to create down sample post-processes in order to get
  71434. * the average luminance of the final image for HDR
  71435. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71436. */
  71437. luminanceDownSamplePostProcesses: PostProcess[];
  71438. /**
  71439. * Post-process used to create a HDR effect (light adaptation)
  71440. */
  71441. hdrPostProcess: Nullable<PostProcess>;
  71442. /**
  71443. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71444. */
  71445. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71446. /**
  71447. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71448. */
  71449. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71450. /**
  71451. * Post-process used to merge the final HDR post-process and the real scene color
  71452. */
  71453. hdrFinalPostProcess: Nullable<PostProcess>;
  71454. /**
  71455. * Post-process used to create a lens flare effect
  71456. */
  71457. lensFlarePostProcess: Nullable<PostProcess>;
  71458. /**
  71459. * Post-process that merges the result of the lens flare post-process and the real scene color
  71460. */
  71461. lensFlareComposePostProcess: Nullable<PostProcess>;
  71462. /**
  71463. * Post-process used to create a motion blur effect
  71464. */
  71465. motionBlurPostProcess: Nullable<PostProcess>;
  71466. /**
  71467. * Post-process used to create a depth of field effect
  71468. */
  71469. depthOfFieldPostProcess: Nullable<PostProcess>;
  71470. /**
  71471. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71472. */
  71473. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71474. /**
  71475. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71476. */
  71477. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71478. /**
  71479. * Represents the brightness threshold in order to configure the illuminated surfaces
  71480. */
  71481. brightThreshold: number;
  71482. /**
  71483. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71484. */
  71485. blurWidth: number;
  71486. /**
  71487. * Sets if the blur for highlighted surfaces must be only horizontal
  71488. */
  71489. horizontalBlur: boolean;
  71490. /**
  71491. * Gets the overall exposure used by the pipeline
  71492. */
  71493. get exposure(): number;
  71494. /**
  71495. * Sets the overall exposure used by the pipeline
  71496. */
  71497. set exposure(value: number);
  71498. /**
  71499. * Texture used typically to simulate "dirty" on camera lens
  71500. */
  71501. lensTexture: Nullable<Texture>;
  71502. /**
  71503. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71504. */
  71505. volumetricLightCoefficient: number;
  71506. /**
  71507. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71508. */
  71509. volumetricLightPower: number;
  71510. /**
  71511. * Used the set the blur intensity to smooth the volumetric lights
  71512. */
  71513. volumetricLightBlurScale: number;
  71514. /**
  71515. * Light (spot or directional) used to generate the volumetric lights rays
  71516. * The source light must have a shadow generate so the pipeline can get its
  71517. * depth map
  71518. */
  71519. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71520. /**
  71521. * For eye adaptation, represents the minimum luminance the eye can see
  71522. */
  71523. hdrMinimumLuminance: number;
  71524. /**
  71525. * For eye adaptation, represents the decrease luminance speed
  71526. */
  71527. hdrDecreaseRate: number;
  71528. /**
  71529. * For eye adaptation, represents the increase luminance speed
  71530. */
  71531. hdrIncreaseRate: number;
  71532. /**
  71533. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71534. */
  71535. get hdrAutoExposure(): boolean;
  71536. /**
  71537. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71538. */
  71539. set hdrAutoExposure(value: boolean);
  71540. /**
  71541. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71542. */
  71543. lensColorTexture: Nullable<Texture>;
  71544. /**
  71545. * The overall strengh for the lens flare effect
  71546. */
  71547. lensFlareStrength: number;
  71548. /**
  71549. * Dispersion coefficient for lens flare ghosts
  71550. */
  71551. lensFlareGhostDispersal: number;
  71552. /**
  71553. * Main lens flare halo width
  71554. */
  71555. lensFlareHaloWidth: number;
  71556. /**
  71557. * Based on the lens distortion effect, defines how much the lens flare result
  71558. * is distorted
  71559. */
  71560. lensFlareDistortionStrength: number;
  71561. /**
  71562. * Configures the blur intensity used for for lens flare (halo)
  71563. */
  71564. lensFlareBlurWidth: number;
  71565. /**
  71566. * Lens star texture must be used to simulate rays on the flares and is available
  71567. * in the documentation
  71568. */
  71569. lensStarTexture: Nullable<Texture>;
  71570. /**
  71571. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71572. * flare effect by taking account of the dirt texture
  71573. */
  71574. lensFlareDirtTexture: Nullable<Texture>;
  71575. /**
  71576. * Represents the focal length for the depth of field effect
  71577. */
  71578. depthOfFieldDistance: number;
  71579. /**
  71580. * Represents the blur intensity for the blurred part of the depth of field effect
  71581. */
  71582. depthOfFieldBlurWidth: number;
  71583. /**
  71584. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71585. */
  71586. get motionStrength(): number;
  71587. /**
  71588. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71589. */
  71590. set motionStrength(strength: number);
  71591. /**
  71592. * Gets wether or not the motion blur post-process is object based or screen based.
  71593. */
  71594. get objectBasedMotionBlur(): boolean;
  71595. /**
  71596. * Sets wether or not the motion blur post-process should be object based or screen based
  71597. */
  71598. set objectBasedMotionBlur(value: boolean);
  71599. /**
  71600. * List of animations for the pipeline (IAnimatable implementation)
  71601. */
  71602. animations: Animation[];
  71603. /**
  71604. * Private members
  71605. */
  71606. private _scene;
  71607. private _currentDepthOfFieldSource;
  71608. private _basePostProcess;
  71609. private _fixedExposure;
  71610. private _currentExposure;
  71611. private _hdrAutoExposure;
  71612. private _hdrCurrentLuminance;
  71613. private _motionStrength;
  71614. private _isObjectBasedMotionBlur;
  71615. private _floatTextureType;
  71616. private _camerasToBeAttached;
  71617. private _ratio;
  71618. private _bloomEnabled;
  71619. private _depthOfFieldEnabled;
  71620. private _vlsEnabled;
  71621. private _lensFlareEnabled;
  71622. private _hdrEnabled;
  71623. private _motionBlurEnabled;
  71624. private _fxaaEnabled;
  71625. private _screenSpaceReflectionsEnabled;
  71626. private _motionBlurSamples;
  71627. private _volumetricLightStepsCount;
  71628. private _samples;
  71629. /**
  71630. * @ignore
  71631. * Specifies if the bloom pipeline is enabled
  71632. */
  71633. get BloomEnabled(): boolean;
  71634. set BloomEnabled(enabled: boolean);
  71635. /**
  71636. * @ignore
  71637. * Specifies if the depth of field pipeline is enabed
  71638. */
  71639. get DepthOfFieldEnabled(): boolean;
  71640. set DepthOfFieldEnabled(enabled: boolean);
  71641. /**
  71642. * @ignore
  71643. * Specifies if the lens flare pipeline is enabed
  71644. */
  71645. get LensFlareEnabled(): boolean;
  71646. set LensFlareEnabled(enabled: boolean);
  71647. /**
  71648. * @ignore
  71649. * Specifies if the HDR pipeline is enabled
  71650. */
  71651. get HDREnabled(): boolean;
  71652. set HDREnabled(enabled: boolean);
  71653. /**
  71654. * @ignore
  71655. * Specifies if the volumetric lights scattering effect is enabled
  71656. */
  71657. get VLSEnabled(): boolean;
  71658. set VLSEnabled(enabled: boolean);
  71659. /**
  71660. * @ignore
  71661. * Specifies if the motion blur effect is enabled
  71662. */
  71663. get MotionBlurEnabled(): boolean;
  71664. set MotionBlurEnabled(enabled: boolean);
  71665. /**
  71666. * Specifies if anti-aliasing is enabled
  71667. */
  71668. get fxaaEnabled(): boolean;
  71669. set fxaaEnabled(enabled: boolean);
  71670. /**
  71671. * Specifies if screen space reflections are enabled.
  71672. */
  71673. get screenSpaceReflectionsEnabled(): boolean;
  71674. set screenSpaceReflectionsEnabled(enabled: boolean);
  71675. /**
  71676. * Specifies the number of steps used to calculate the volumetric lights
  71677. * Typically in interval [50, 200]
  71678. */
  71679. get volumetricLightStepsCount(): number;
  71680. set volumetricLightStepsCount(count: number);
  71681. /**
  71682. * Specifies the number of samples used for the motion blur effect
  71683. * Typically in interval [16, 64]
  71684. */
  71685. get motionBlurSamples(): number;
  71686. set motionBlurSamples(samples: number);
  71687. /**
  71688. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71689. */
  71690. get samples(): number;
  71691. set samples(sampleCount: number);
  71692. /**
  71693. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71694. * @constructor
  71695. * @param name The rendering pipeline name
  71696. * @param scene The scene linked to this pipeline
  71697. * @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)
  71698. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71699. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71700. */
  71701. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71702. private _buildPipeline;
  71703. private _createDownSampleX4PostProcess;
  71704. private _createBrightPassPostProcess;
  71705. private _createBlurPostProcesses;
  71706. private _createTextureAdderPostProcess;
  71707. private _createVolumetricLightPostProcess;
  71708. private _createLuminancePostProcesses;
  71709. private _createHdrPostProcess;
  71710. private _createLensFlarePostProcess;
  71711. private _createDepthOfFieldPostProcess;
  71712. private _createMotionBlurPostProcess;
  71713. private _getDepthTexture;
  71714. private _disposePostProcesses;
  71715. /**
  71716. * Dispose of the pipeline and stop all post processes
  71717. */
  71718. dispose(): void;
  71719. /**
  71720. * Serialize the rendering pipeline (Used when exporting)
  71721. * @returns the serialized object
  71722. */
  71723. serialize(): any;
  71724. /**
  71725. * Parse the serialized pipeline
  71726. * @param source Source pipeline.
  71727. * @param scene The scene to load the pipeline to.
  71728. * @param rootUrl The URL of the serialized pipeline.
  71729. * @returns An instantiated pipeline from the serialized object.
  71730. */
  71731. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71732. /**
  71733. * Luminance steps
  71734. */
  71735. static LuminanceSteps: number;
  71736. }
  71737. }
  71738. declare module BABYLON {
  71739. /** @hidden */
  71740. export var stereoscopicInterlacePixelShader: {
  71741. name: string;
  71742. shader: string;
  71743. };
  71744. }
  71745. declare module BABYLON {
  71746. /**
  71747. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71748. */
  71749. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71750. private _stepSize;
  71751. private _passedProcess;
  71752. /**
  71753. * Gets a string identifying the name of the class
  71754. * @returns "StereoscopicInterlacePostProcessI" string
  71755. */
  71756. getClassName(): string;
  71757. /**
  71758. * Initializes a StereoscopicInterlacePostProcessI
  71759. * @param name The name of the effect.
  71760. * @param rigCameras The rig cameras to be appled to the post process
  71761. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71762. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71764. * @param engine The engine which the post process will be applied. (default: current engine)
  71765. * @param reusable If the post process can be reused on the same frame. (default: false)
  71766. */
  71767. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71768. }
  71769. /**
  71770. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71771. */
  71772. export class StereoscopicInterlacePostProcess extends PostProcess {
  71773. private _stepSize;
  71774. private _passedProcess;
  71775. /**
  71776. * Gets a string identifying the name of the class
  71777. * @returns "StereoscopicInterlacePostProcess" string
  71778. */
  71779. getClassName(): string;
  71780. /**
  71781. * Initializes a StereoscopicInterlacePostProcess
  71782. * @param name The name of the effect.
  71783. * @param rigCameras The rig cameras to be appled to the post process
  71784. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71786. * @param engine The engine which the post process will be applied. (default: current engine)
  71787. * @param reusable If the post process can be reused on the same frame. (default: false)
  71788. */
  71789. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /** @hidden */
  71794. export var tonemapPixelShader: {
  71795. name: string;
  71796. shader: string;
  71797. };
  71798. }
  71799. declare module BABYLON {
  71800. /** Defines operator used for tonemapping */
  71801. export enum TonemappingOperator {
  71802. /** Hable */
  71803. Hable = 0,
  71804. /** Reinhard */
  71805. Reinhard = 1,
  71806. /** HejiDawson */
  71807. HejiDawson = 2,
  71808. /** Photographic */
  71809. Photographic = 3
  71810. }
  71811. /**
  71812. * Defines a post process to apply tone mapping
  71813. */
  71814. export class TonemapPostProcess extends PostProcess {
  71815. private _operator;
  71816. /** Defines the required exposure adjustement */
  71817. exposureAdjustment: number;
  71818. /**
  71819. * Gets a string identifying the name of the class
  71820. * @returns "TonemapPostProcess" string
  71821. */
  71822. getClassName(): string;
  71823. /**
  71824. * Creates a new TonemapPostProcess
  71825. * @param name defines the name of the postprocess
  71826. * @param _operator defines the operator to use
  71827. * @param exposureAdjustment defines the required exposure adjustement
  71828. * @param camera defines the camera to use (can be null)
  71829. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71830. * @param engine defines the hosting engine (can be ignore if camera is set)
  71831. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71832. */
  71833. constructor(name: string, _operator: TonemappingOperator,
  71834. /** Defines the required exposure adjustement */
  71835. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. /** @hidden */
  71840. export var volumetricLightScatteringPixelShader: {
  71841. name: string;
  71842. shader: string;
  71843. };
  71844. }
  71845. declare module BABYLON {
  71846. /** @hidden */
  71847. export var volumetricLightScatteringPassVertexShader: {
  71848. name: string;
  71849. shader: string;
  71850. };
  71851. }
  71852. declare module BABYLON {
  71853. /** @hidden */
  71854. export var volumetricLightScatteringPassPixelShader: {
  71855. name: string;
  71856. shader: string;
  71857. };
  71858. }
  71859. declare module BABYLON {
  71860. /**
  71861. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71862. */
  71863. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71864. private _volumetricLightScatteringPass;
  71865. private _volumetricLightScatteringRTT;
  71866. private _viewPort;
  71867. private _screenCoordinates;
  71868. private _cachedDefines;
  71869. /**
  71870. * If not undefined, the mesh position is computed from the attached node position
  71871. */
  71872. attachedNode: {
  71873. position: Vector3;
  71874. };
  71875. /**
  71876. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71877. */
  71878. customMeshPosition: Vector3;
  71879. /**
  71880. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71881. */
  71882. useCustomMeshPosition: boolean;
  71883. /**
  71884. * If the post-process should inverse the light scattering direction
  71885. */
  71886. invert: boolean;
  71887. /**
  71888. * The internal mesh used by the post-process
  71889. */
  71890. mesh: Mesh;
  71891. /**
  71892. * @hidden
  71893. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71894. */
  71895. get useDiffuseColor(): boolean;
  71896. set useDiffuseColor(useDiffuseColor: boolean);
  71897. /**
  71898. * Array containing the excluded meshes not rendered in the internal pass
  71899. */
  71900. excludedMeshes: AbstractMesh[];
  71901. /**
  71902. * Controls the overall intensity of the post-process
  71903. */
  71904. exposure: number;
  71905. /**
  71906. * Dissipates each sample's contribution in range [0, 1]
  71907. */
  71908. decay: number;
  71909. /**
  71910. * Controls the overall intensity of each sample
  71911. */
  71912. weight: number;
  71913. /**
  71914. * Controls the density of each sample
  71915. */
  71916. density: number;
  71917. /**
  71918. * @constructor
  71919. * @param name The post-process name
  71920. * @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)
  71921. * @param camera The camera that the post-process will be attached to
  71922. * @param mesh The mesh used to create the light scattering
  71923. * @param samples The post-process quality, default 100
  71924. * @param samplingModeThe post-process filtering mode
  71925. * @param engine The babylon engine
  71926. * @param reusable If the post-process is reusable
  71927. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71928. */
  71929. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71930. /**
  71931. * Returns the string "VolumetricLightScatteringPostProcess"
  71932. * @returns "VolumetricLightScatteringPostProcess"
  71933. */
  71934. getClassName(): string;
  71935. private _isReady;
  71936. /**
  71937. * Sets the new light position for light scattering effect
  71938. * @param position The new custom light position
  71939. */
  71940. setCustomMeshPosition(position: Vector3): void;
  71941. /**
  71942. * Returns the light position for light scattering effect
  71943. * @return Vector3 The custom light position
  71944. */
  71945. getCustomMeshPosition(): Vector3;
  71946. /**
  71947. * Disposes the internal assets and detaches the post-process from the camera
  71948. */
  71949. dispose(camera: Camera): void;
  71950. /**
  71951. * Returns the render target texture used by the post-process
  71952. * @return the render target texture used by the post-process
  71953. */
  71954. getPass(): RenderTargetTexture;
  71955. private _meshExcluded;
  71956. private _createPass;
  71957. private _updateMeshScreenCoordinates;
  71958. /**
  71959. * Creates a default mesh for the Volumeric Light Scattering post-process
  71960. * @param name The mesh name
  71961. * @param scene The scene where to create the mesh
  71962. * @return the default mesh
  71963. */
  71964. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71965. }
  71966. }
  71967. declare module BABYLON {
  71968. /** @hidden */
  71969. export var screenSpaceCurvaturePixelShader: {
  71970. name: string;
  71971. shader: string;
  71972. };
  71973. }
  71974. declare module BABYLON {
  71975. /**
  71976. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71977. */
  71978. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71979. /**
  71980. * Defines how much ridge the curvature effect displays.
  71981. */
  71982. ridge: number;
  71983. /**
  71984. * Defines how much valley the curvature effect displays.
  71985. */
  71986. valley: number;
  71987. private _geometryBufferRenderer;
  71988. /**
  71989. * Gets a string identifying the name of the class
  71990. * @returns "ScreenSpaceCurvaturePostProcess" string
  71991. */
  71992. getClassName(): string;
  71993. /**
  71994. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71995. * @param name The name of the effect.
  71996. * @param scene The scene containing the objects to blur according to their velocity.
  71997. * @param options The required width/height ratio to downsize to before computing the render pass.
  71998. * @param camera The camera to apply the render pass to.
  71999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72000. * @param engine The engine which the post process will be applied. (default: current engine)
  72001. * @param reusable If the post process can be reused on the same frame. (default: false)
  72002. * @param textureType Type of textures used when performing the post process. (default: 0)
  72003. * @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)
  72004. */
  72005. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72006. /**
  72007. * Support test.
  72008. */
  72009. static get IsSupported(): boolean;
  72010. /** @hidden */
  72011. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72012. }
  72013. }
  72014. declare module BABYLON {
  72015. interface Scene {
  72016. /** @hidden (Backing field) */
  72017. _boundingBoxRenderer: BoundingBoxRenderer;
  72018. /** @hidden (Backing field) */
  72019. _forceShowBoundingBoxes: boolean;
  72020. /**
  72021. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72022. */
  72023. forceShowBoundingBoxes: boolean;
  72024. /**
  72025. * Gets the bounding box renderer associated with the scene
  72026. * @returns a BoundingBoxRenderer
  72027. */
  72028. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72029. }
  72030. interface AbstractMesh {
  72031. /** @hidden (Backing field) */
  72032. _showBoundingBox: boolean;
  72033. /**
  72034. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72035. */
  72036. showBoundingBox: boolean;
  72037. }
  72038. /**
  72039. * Component responsible of rendering the bounding box of the meshes in a scene.
  72040. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72041. */
  72042. export class BoundingBoxRenderer implements ISceneComponent {
  72043. /**
  72044. * The component name helpfull to identify the component in the list of scene components.
  72045. */
  72046. readonly name: string;
  72047. /**
  72048. * The scene the component belongs to.
  72049. */
  72050. scene: Scene;
  72051. /**
  72052. * Color of the bounding box lines placed in front of an object
  72053. */
  72054. frontColor: Color3;
  72055. /**
  72056. * Color of the bounding box lines placed behind an object
  72057. */
  72058. backColor: Color3;
  72059. /**
  72060. * Defines if the renderer should show the back lines or not
  72061. */
  72062. showBackLines: boolean;
  72063. /**
  72064. * Observable raised before rendering a bounding box
  72065. */
  72066. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72067. /**
  72068. * Observable raised after rendering a bounding box
  72069. */
  72070. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72071. /**
  72072. * @hidden
  72073. */
  72074. renderList: SmartArray<BoundingBox>;
  72075. private _colorShader;
  72076. private _vertexBuffers;
  72077. private _indexBuffer;
  72078. private _fillIndexBuffer;
  72079. private _fillIndexData;
  72080. /**
  72081. * Instantiates a new bounding box renderer in a scene.
  72082. * @param scene the scene the renderer renders in
  72083. */
  72084. constructor(scene: Scene);
  72085. /**
  72086. * Registers the component in a given scene
  72087. */
  72088. register(): void;
  72089. private _evaluateSubMesh;
  72090. private _activeMesh;
  72091. private _prepareRessources;
  72092. private _createIndexBuffer;
  72093. /**
  72094. * Rebuilds the elements related to this component in case of
  72095. * context lost for instance.
  72096. */
  72097. rebuild(): void;
  72098. /**
  72099. * @hidden
  72100. */
  72101. reset(): void;
  72102. /**
  72103. * Render the bounding boxes of a specific rendering group
  72104. * @param renderingGroupId defines the rendering group to render
  72105. */
  72106. render(renderingGroupId: number): void;
  72107. /**
  72108. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72109. * @param mesh Define the mesh to render the occlusion bounding box for
  72110. */
  72111. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72112. /**
  72113. * Dispose and release the resources attached to this renderer.
  72114. */
  72115. dispose(): void;
  72116. }
  72117. }
  72118. declare module BABYLON {
  72119. interface Scene {
  72120. /** @hidden (Backing field) */
  72121. _depthRenderer: {
  72122. [id: string]: DepthRenderer;
  72123. };
  72124. /**
  72125. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72126. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72127. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72128. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72129. * @returns the created depth renderer
  72130. */
  72131. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72132. /**
  72133. * Disables a depth renderer for a given camera
  72134. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72135. */
  72136. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72137. }
  72138. /**
  72139. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72140. * in several rendering techniques.
  72141. */
  72142. export class DepthRendererSceneComponent implements ISceneComponent {
  72143. /**
  72144. * The component name helpfull to identify the component in the list of scene components.
  72145. */
  72146. readonly name: string;
  72147. /**
  72148. * The scene the component belongs to.
  72149. */
  72150. scene: Scene;
  72151. /**
  72152. * Creates a new instance of the component for the given scene
  72153. * @param scene Defines the scene to register the component in
  72154. */
  72155. constructor(scene: Scene);
  72156. /**
  72157. * Registers the component in a given scene
  72158. */
  72159. register(): void;
  72160. /**
  72161. * Rebuilds the elements related to this component in case of
  72162. * context lost for instance.
  72163. */
  72164. rebuild(): void;
  72165. /**
  72166. * Disposes the component and the associated ressources
  72167. */
  72168. dispose(): void;
  72169. private _gatherRenderTargets;
  72170. private _gatherActiveCameraRenderTargets;
  72171. }
  72172. }
  72173. declare module BABYLON {
  72174. interface AbstractScene {
  72175. /** @hidden (Backing field) */
  72176. _prePassRenderer: Nullable<PrePassRenderer>;
  72177. /**
  72178. * Gets or Sets the current prepass renderer associated to the scene.
  72179. */
  72180. prePassRenderer: Nullable<PrePassRenderer>;
  72181. /**
  72182. * Enables the prepass and associates it with the scene
  72183. * @returns the PrePassRenderer
  72184. */
  72185. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72186. /**
  72187. * Disables the prepass associated with the scene
  72188. */
  72189. disablePrePassRenderer(): void;
  72190. }
  72191. /**
  72192. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72193. * in several rendering techniques.
  72194. */
  72195. export class PrePassRendererSceneComponent implements ISceneComponent {
  72196. /**
  72197. * The component name helpful to identify the component in the list of scene components.
  72198. */
  72199. readonly name: string;
  72200. /**
  72201. * The scene the component belongs to.
  72202. */
  72203. scene: Scene;
  72204. /**
  72205. * Creates a new instance of the component for the given scene
  72206. * @param scene Defines the scene to register the component in
  72207. */
  72208. constructor(scene: Scene);
  72209. /**
  72210. * Registers the component in a given scene
  72211. */
  72212. register(): void;
  72213. private _beforeCameraDraw;
  72214. private _afterCameraDraw;
  72215. private _beforeClearStage;
  72216. /**
  72217. * Rebuilds the elements related to this component in case of
  72218. * context lost for instance.
  72219. */
  72220. rebuild(): void;
  72221. /**
  72222. * Disposes the component and the associated ressources
  72223. */
  72224. dispose(): void;
  72225. }
  72226. }
  72227. declare module BABYLON {
  72228. /** @hidden */
  72229. export var fibonacci: {
  72230. name: string;
  72231. shader: string;
  72232. };
  72233. }
  72234. declare module BABYLON {
  72235. /** @hidden */
  72236. export var diffusionProfile: {
  72237. name: string;
  72238. shader: string;
  72239. };
  72240. }
  72241. declare module BABYLON {
  72242. /** @hidden */
  72243. export var subSurfaceScatteringPixelShader: {
  72244. name: string;
  72245. shader: string;
  72246. };
  72247. }
  72248. declare module BABYLON {
  72249. /**
  72250. * Sub surface scattering post process
  72251. */
  72252. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72253. /**
  72254. * Gets a string identifying the name of the class
  72255. * @returns "SubSurfaceScatteringPostProcess" string
  72256. */
  72257. getClassName(): string;
  72258. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /**
  72263. * Contains all parameters needed for the prepass to perform
  72264. * screen space subsurface scattering
  72265. */
  72266. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72267. /** @hidden */
  72268. static _SceneComponentInitialization: (scene: Scene) => void;
  72269. private _ssDiffusionS;
  72270. private _ssFilterRadii;
  72271. private _ssDiffusionD;
  72272. /**
  72273. * Post process to attach for screen space subsurface scattering
  72274. */
  72275. postProcess: SubSurfaceScatteringPostProcess;
  72276. /**
  72277. * Diffusion profile color for subsurface scattering
  72278. */
  72279. get ssDiffusionS(): number[];
  72280. /**
  72281. * Diffusion profile max color channel value for subsurface scattering
  72282. */
  72283. get ssDiffusionD(): number[];
  72284. /**
  72285. * Diffusion profile filter radius for subsurface scattering
  72286. */
  72287. get ssFilterRadii(): number[];
  72288. /**
  72289. * Is subsurface enabled
  72290. */
  72291. enabled: boolean;
  72292. /**
  72293. * Name of the configuration
  72294. */
  72295. name: string;
  72296. /**
  72297. * Diffusion profile colors for subsurface scattering
  72298. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72299. * See ...
  72300. * Note that you can only store up to 5 of them
  72301. */
  72302. ssDiffusionProfileColors: Color3[];
  72303. /**
  72304. * Defines the ratio real world => scene units.
  72305. * Used for subsurface scattering
  72306. */
  72307. metersPerUnit: number;
  72308. /**
  72309. * Textures that should be present in the MRT for this effect to work
  72310. */
  72311. readonly texturesRequired: number[];
  72312. private _scene;
  72313. /**
  72314. * Builds a subsurface configuration object
  72315. * @param scene The scene
  72316. */
  72317. constructor(scene: Scene);
  72318. /**
  72319. * Adds a new diffusion profile.
  72320. * Useful for more realistic subsurface scattering on diverse materials.
  72321. * @param color The color of the diffusion profile. Should be the average color of the material.
  72322. * @return The index of the diffusion profile for the material subsurface configuration
  72323. */
  72324. addDiffusionProfile(color: Color3): number;
  72325. /**
  72326. * Creates the sss post process
  72327. * @return The created post process
  72328. */
  72329. createPostProcess(): SubSurfaceScatteringPostProcess;
  72330. /**
  72331. * Deletes all diffusion profiles.
  72332. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72333. */
  72334. clearAllDiffusionProfiles(): void;
  72335. /**
  72336. * Disposes this object
  72337. */
  72338. dispose(): void;
  72339. /**
  72340. * @hidden
  72341. * https://zero-radiance.github.io/post/sampling-diffusion/
  72342. *
  72343. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72344. * ------------------------------------------------------------------------------------
  72345. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72346. * PDF[r, phi, s] = r * R[r, phi, s]
  72347. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72348. * ------------------------------------------------------------------------------------
  72349. * We importance sample the color channel with the widest scattering distance.
  72350. */
  72351. getDiffusionProfileParameters(color: Color3): number;
  72352. /**
  72353. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72354. * 'u' is the random number (the value of the CDF): [0, 1).
  72355. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72356. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72357. */
  72358. private _sampleBurleyDiffusionProfile;
  72359. }
  72360. }
  72361. declare module BABYLON {
  72362. interface AbstractScene {
  72363. /** @hidden (Backing field) */
  72364. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72365. /**
  72366. * Gets or Sets the current prepass renderer associated to the scene.
  72367. */
  72368. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72369. /**
  72370. * Enables the subsurface effect for prepass
  72371. * @returns the SubSurfaceConfiguration
  72372. */
  72373. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72374. /**
  72375. * Disables the subsurface effect for prepass
  72376. */
  72377. disableSubSurfaceForPrePass(): void;
  72378. }
  72379. /**
  72380. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72381. * in several rendering techniques.
  72382. */
  72383. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72384. /**
  72385. * The component name helpful to identify the component in the list of scene components.
  72386. */
  72387. readonly name: string;
  72388. /**
  72389. * The scene the component belongs to.
  72390. */
  72391. scene: Scene;
  72392. /**
  72393. * Creates a new instance of the component for the given scene
  72394. * @param scene Defines the scene to register the component in
  72395. */
  72396. constructor(scene: Scene);
  72397. /**
  72398. * Registers the component in a given scene
  72399. */
  72400. register(): void;
  72401. /**
  72402. * Serializes the component data to the specified json object
  72403. * @param serializationObject The object to serialize to
  72404. */
  72405. serialize(serializationObject: any): void;
  72406. /**
  72407. * Adds all the elements from the container to the scene
  72408. * @param container the container holding the elements
  72409. */
  72410. addFromContainer(container: AbstractScene): void;
  72411. /**
  72412. * Removes all the elements in the container from the scene
  72413. * @param container contains the elements to remove
  72414. * @param dispose if the removed element should be disposed (default: false)
  72415. */
  72416. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72417. /**
  72418. * Rebuilds the elements related to this component in case of
  72419. * context lost for instance.
  72420. */
  72421. rebuild(): void;
  72422. /**
  72423. * Disposes the component and the associated ressources
  72424. */
  72425. dispose(): void;
  72426. }
  72427. }
  72428. declare module BABYLON {
  72429. /** @hidden */
  72430. export var outlinePixelShader: {
  72431. name: string;
  72432. shader: string;
  72433. };
  72434. }
  72435. declare module BABYLON {
  72436. /** @hidden */
  72437. export var outlineVertexShader: {
  72438. name: string;
  72439. shader: string;
  72440. };
  72441. }
  72442. declare module BABYLON {
  72443. interface Scene {
  72444. /** @hidden */
  72445. _outlineRenderer: OutlineRenderer;
  72446. /**
  72447. * Gets the outline renderer associated with the scene
  72448. * @returns a OutlineRenderer
  72449. */
  72450. getOutlineRenderer(): OutlineRenderer;
  72451. }
  72452. interface AbstractMesh {
  72453. /** @hidden (Backing field) */
  72454. _renderOutline: boolean;
  72455. /**
  72456. * Gets or sets a boolean indicating if the outline must be rendered as well
  72457. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72458. */
  72459. renderOutline: boolean;
  72460. /** @hidden (Backing field) */
  72461. _renderOverlay: boolean;
  72462. /**
  72463. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72464. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72465. */
  72466. renderOverlay: boolean;
  72467. }
  72468. /**
  72469. * This class is responsible to draw bothe outline/overlay of meshes.
  72470. * It should not be used directly but through the available method on mesh.
  72471. */
  72472. export class OutlineRenderer implements ISceneComponent {
  72473. /**
  72474. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72475. */
  72476. private static _StencilReference;
  72477. /**
  72478. * The name of the component. Each component must have a unique name.
  72479. */
  72480. name: string;
  72481. /**
  72482. * The scene the component belongs to.
  72483. */
  72484. scene: Scene;
  72485. /**
  72486. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72487. */
  72488. zOffset: number;
  72489. private _engine;
  72490. private _effect;
  72491. private _cachedDefines;
  72492. private _savedDepthWrite;
  72493. /**
  72494. * Instantiates a new outline renderer. (There could be only one per scene).
  72495. * @param scene Defines the scene it belongs to
  72496. */
  72497. constructor(scene: Scene);
  72498. /**
  72499. * Register the component to one instance of a scene.
  72500. */
  72501. register(): void;
  72502. /**
  72503. * Rebuilds the elements related to this component in case of
  72504. * context lost for instance.
  72505. */
  72506. rebuild(): void;
  72507. /**
  72508. * Disposes the component and the associated ressources.
  72509. */
  72510. dispose(): void;
  72511. /**
  72512. * Renders the outline in the canvas.
  72513. * @param subMesh Defines the sumesh to render
  72514. * @param batch Defines the batch of meshes in case of instances
  72515. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72516. */
  72517. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72518. /**
  72519. * Returns whether or not the outline renderer is ready for a given submesh.
  72520. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72521. * @param subMesh Defines the submesh to check readyness for
  72522. * @param useInstances Defines wheter wee are trying to render instances or not
  72523. * @returns true if ready otherwise false
  72524. */
  72525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72526. private _beforeRenderingMesh;
  72527. private _afterRenderingMesh;
  72528. }
  72529. }
  72530. declare module BABYLON {
  72531. /**
  72532. * Defines the basic options interface of a Sprite Frame Source Size.
  72533. */
  72534. export interface ISpriteJSONSpriteSourceSize {
  72535. /**
  72536. * number of the original width of the Frame
  72537. */
  72538. w: number;
  72539. /**
  72540. * number of the original height of the Frame
  72541. */
  72542. h: number;
  72543. }
  72544. /**
  72545. * Defines the basic options interface of a Sprite Frame Data.
  72546. */
  72547. export interface ISpriteJSONSpriteFrameData {
  72548. /**
  72549. * number of the x offset of the Frame
  72550. */
  72551. x: number;
  72552. /**
  72553. * number of the y offset of the Frame
  72554. */
  72555. y: number;
  72556. /**
  72557. * number of the width of the Frame
  72558. */
  72559. w: number;
  72560. /**
  72561. * number of the height of the Frame
  72562. */
  72563. h: number;
  72564. }
  72565. /**
  72566. * Defines the basic options interface of a JSON Sprite.
  72567. */
  72568. export interface ISpriteJSONSprite {
  72569. /**
  72570. * string name of the Frame
  72571. */
  72572. filename: string;
  72573. /**
  72574. * ISpriteJSONSpriteFrame basic object of the frame data
  72575. */
  72576. frame: ISpriteJSONSpriteFrameData;
  72577. /**
  72578. * boolean to flag is the frame was rotated.
  72579. */
  72580. rotated: boolean;
  72581. /**
  72582. * boolean to flag is the frame was trimmed.
  72583. */
  72584. trimmed: boolean;
  72585. /**
  72586. * ISpriteJSONSpriteFrame basic object of the source data
  72587. */
  72588. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72589. /**
  72590. * ISpriteJSONSpriteFrame basic object of the source data
  72591. */
  72592. sourceSize: ISpriteJSONSpriteSourceSize;
  72593. }
  72594. /**
  72595. * Defines the basic options interface of a JSON atlas.
  72596. */
  72597. export interface ISpriteJSONAtlas {
  72598. /**
  72599. * Array of objects that contain the frame data.
  72600. */
  72601. frames: Array<ISpriteJSONSprite>;
  72602. /**
  72603. * object basic object containing the sprite meta data.
  72604. */
  72605. meta?: object;
  72606. }
  72607. }
  72608. declare module BABYLON {
  72609. /** @hidden */
  72610. export var spriteMapPixelShader: {
  72611. name: string;
  72612. shader: string;
  72613. };
  72614. }
  72615. declare module BABYLON {
  72616. /** @hidden */
  72617. export var spriteMapVertexShader: {
  72618. name: string;
  72619. shader: string;
  72620. };
  72621. }
  72622. declare module BABYLON {
  72623. /**
  72624. * Defines the basic options interface of a SpriteMap
  72625. */
  72626. export interface ISpriteMapOptions {
  72627. /**
  72628. * Vector2 of the number of cells in the grid.
  72629. */
  72630. stageSize?: Vector2;
  72631. /**
  72632. * Vector2 of the size of the output plane in World Units.
  72633. */
  72634. outputSize?: Vector2;
  72635. /**
  72636. * Vector3 of the position of the output plane in World Units.
  72637. */
  72638. outputPosition?: Vector3;
  72639. /**
  72640. * Vector3 of the rotation of the output plane.
  72641. */
  72642. outputRotation?: Vector3;
  72643. /**
  72644. * number of layers that the system will reserve in resources.
  72645. */
  72646. layerCount?: number;
  72647. /**
  72648. * number of max animation frames a single cell will reserve in resources.
  72649. */
  72650. maxAnimationFrames?: number;
  72651. /**
  72652. * number cell index of the base tile when the system compiles.
  72653. */
  72654. baseTile?: number;
  72655. /**
  72656. * boolean flip the sprite after its been repositioned by the framing data.
  72657. */
  72658. flipU?: boolean;
  72659. /**
  72660. * Vector3 scalar of the global RGB values of the SpriteMap.
  72661. */
  72662. colorMultiply?: Vector3;
  72663. }
  72664. /**
  72665. * Defines the IDisposable interface in order to be cleanable from resources.
  72666. */
  72667. export interface ISpriteMap extends IDisposable {
  72668. /**
  72669. * String name of the SpriteMap.
  72670. */
  72671. name: string;
  72672. /**
  72673. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72674. */
  72675. atlasJSON: ISpriteJSONAtlas;
  72676. /**
  72677. * Texture of the SpriteMap.
  72678. */
  72679. spriteSheet: Texture;
  72680. /**
  72681. * The parameters to initialize the SpriteMap with.
  72682. */
  72683. options: ISpriteMapOptions;
  72684. }
  72685. /**
  72686. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72687. */
  72688. export class SpriteMap implements ISpriteMap {
  72689. /** The Name of the spriteMap */
  72690. name: string;
  72691. /** The JSON file with the frame and meta data */
  72692. atlasJSON: ISpriteJSONAtlas;
  72693. /** The systems Sprite Sheet Texture */
  72694. spriteSheet: Texture;
  72695. /** Arguments passed with the Constructor */
  72696. options: ISpriteMapOptions;
  72697. /** Public Sprite Storage array, parsed from atlasJSON */
  72698. sprites: Array<ISpriteJSONSprite>;
  72699. /** Returns the Number of Sprites in the System */
  72700. get spriteCount(): number;
  72701. /** Returns the Position of Output Plane*/
  72702. get position(): Vector3;
  72703. /** Returns the Position of Output Plane*/
  72704. set position(v: Vector3);
  72705. /** Returns the Rotation of Output Plane*/
  72706. get rotation(): Vector3;
  72707. /** Returns the Rotation of Output Plane*/
  72708. set rotation(v: Vector3);
  72709. /** Sets the AnimationMap*/
  72710. get animationMap(): RawTexture;
  72711. /** Sets the AnimationMap*/
  72712. set animationMap(v: RawTexture);
  72713. /** Scene that the SpriteMap was created in */
  72714. private _scene;
  72715. /** Texture Buffer of Float32 that holds tile frame data*/
  72716. private _frameMap;
  72717. /** Texture Buffers of Float32 that holds tileMap data*/
  72718. private _tileMaps;
  72719. /** Texture Buffer of Float32 that holds Animation Data*/
  72720. private _animationMap;
  72721. /** Custom ShaderMaterial Central to the System*/
  72722. private _material;
  72723. /** Custom ShaderMaterial Central to the System*/
  72724. private _output;
  72725. /** Systems Time Ticker*/
  72726. private _time;
  72727. /**
  72728. * Creates a new SpriteMap
  72729. * @param name defines the SpriteMaps Name
  72730. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72731. * @param spriteSheet is the Texture that the Sprites are on.
  72732. * @param options a basic deployment configuration
  72733. * @param scene The Scene that the map is deployed on
  72734. */
  72735. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72736. /**
  72737. * Returns tileID location
  72738. * @returns Vector2 the cell position ID
  72739. */
  72740. getTileID(): Vector2;
  72741. /**
  72742. * Gets the UV location of the mouse over the SpriteMap.
  72743. * @returns Vector2 the UV position of the mouse interaction
  72744. */
  72745. getMousePosition(): Vector2;
  72746. /**
  72747. * Creates the "frame" texture Buffer
  72748. * -------------------------------------
  72749. * Structure of frames
  72750. * "filename": "Falling-Water-2.png",
  72751. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72752. * "rotated": true,
  72753. * "trimmed": true,
  72754. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72755. * "sourceSize": {"w":32,"h":32}
  72756. * @returns RawTexture of the frameMap
  72757. */
  72758. private _createFrameBuffer;
  72759. /**
  72760. * Creates the tileMap texture Buffer
  72761. * @param buffer normally and array of numbers, or a false to generate from scratch
  72762. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72763. * @returns RawTexture of the tileMap
  72764. */
  72765. private _createTileBuffer;
  72766. /**
  72767. * Modifies the data of the tileMaps
  72768. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72769. * @param pos is the iVector2 Coordinates of the Tile
  72770. * @param tile The SpriteIndex of the new Tile
  72771. */
  72772. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72773. /**
  72774. * Creates the animationMap texture Buffer
  72775. * @param buffer normally and array of numbers, or a false to generate from scratch
  72776. * @returns RawTexture of the animationMap
  72777. */
  72778. private _createTileAnimationBuffer;
  72779. /**
  72780. * Modifies the data of the animationMap
  72781. * @param cellID is the Index of the Sprite
  72782. * @param _frame is the target Animation frame
  72783. * @param toCell is the Target Index of the next frame of the animation
  72784. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72785. * @param speed is a global scalar of the time variable on the map.
  72786. */
  72787. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72788. /**
  72789. * Exports the .tilemaps file
  72790. */
  72791. saveTileMaps(): void;
  72792. /**
  72793. * Imports the .tilemaps file
  72794. * @param url of the .tilemaps file
  72795. */
  72796. loadTileMaps(url: string): void;
  72797. /**
  72798. * Release associated resources
  72799. */
  72800. dispose(): void;
  72801. }
  72802. }
  72803. declare module BABYLON {
  72804. /**
  72805. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72806. * @see https://doc.babylonjs.com/babylon101/sprites
  72807. */
  72808. export class SpritePackedManager extends SpriteManager {
  72809. /** defines the packed manager's name */
  72810. name: string;
  72811. /**
  72812. * Creates a new sprite manager from a packed sprite sheet
  72813. * @param name defines the manager's name
  72814. * @param imgUrl defines the sprite sheet url
  72815. * @param capacity defines the maximum allowed number of sprites
  72816. * @param scene defines the hosting scene
  72817. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72818. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72819. * @param samplingMode defines the smapling mode to use with spritesheet
  72820. * @param fromPacked set to true; do not alter
  72821. */
  72822. constructor(
  72823. /** defines the packed manager's name */
  72824. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72825. }
  72826. }
  72827. declare module BABYLON {
  72828. /**
  72829. * Defines the list of states available for a task inside a AssetsManager
  72830. */
  72831. export enum AssetTaskState {
  72832. /**
  72833. * Initialization
  72834. */
  72835. INIT = 0,
  72836. /**
  72837. * Running
  72838. */
  72839. RUNNING = 1,
  72840. /**
  72841. * Done
  72842. */
  72843. DONE = 2,
  72844. /**
  72845. * Error
  72846. */
  72847. ERROR = 3
  72848. }
  72849. /**
  72850. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72851. */
  72852. export abstract class AbstractAssetTask {
  72853. /**
  72854. * Task name
  72855. */ name: string;
  72856. /**
  72857. * Callback called when the task is successful
  72858. */
  72859. onSuccess: (task: any) => void;
  72860. /**
  72861. * Callback called when the task is not successful
  72862. */
  72863. onError: (task: any, message?: string, exception?: any) => void;
  72864. /**
  72865. * Creates a new AssetsManager
  72866. * @param name defines the name of the task
  72867. */
  72868. constructor(
  72869. /**
  72870. * Task name
  72871. */ name: string);
  72872. private _isCompleted;
  72873. private _taskState;
  72874. private _errorObject;
  72875. /**
  72876. * Get if the task is completed
  72877. */
  72878. get isCompleted(): boolean;
  72879. /**
  72880. * Gets the current state of the task
  72881. */
  72882. get taskState(): AssetTaskState;
  72883. /**
  72884. * Gets the current error object (if task is in error)
  72885. */
  72886. get errorObject(): {
  72887. message?: string;
  72888. exception?: any;
  72889. };
  72890. /**
  72891. * Internal only
  72892. * @hidden
  72893. */
  72894. _setErrorObject(message?: string, exception?: any): void;
  72895. /**
  72896. * Execute the current task
  72897. * @param scene defines the scene where you want your assets to be loaded
  72898. * @param onSuccess is a callback called when the task is successfully executed
  72899. * @param onError is a callback called if an error occurs
  72900. */
  72901. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72902. /**
  72903. * Execute the current task
  72904. * @param scene defines the scene where you want your assets to be loaded
  72905. * @param onSuccess is a callback called when the task is successfully executed
  72906. * @param onError is a callback called if an error occurs
  72907. */
  72908. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72909. /**
  72910. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72911. * This can be used with failed tasks that have the reason for failure fixed.
  72912. */
  72913. reset(): void;
  72914. private onErrorCallback;
  72915. private onDoneCallback;
  72916. }
  72917. /**
  72918. * Define the interface used by progress events raised during assets loading
  72919. */
  72920. export interface IAssetsProgressEvent {
  72921. /**
  72922. * Defines the number of remaining tasks to process
  72923. */
  72924. remainingCount: number;
  72925. /**
  72926. * Defines the total number of tasks
  72927. */
  72928. totalCount: number;
  72929. /**
  72930. * Defines the task that was just processed
  72931. */
  72932. task: AbstractAssetTask;
  72933. }
  72934. /**
  72935. * Class used to share progress information about assets loading
  72936. */
  72937. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72938. /**
  72939. * Defines the number of remaining tasks to process
  72940. */
  72941. remainingCount: number;
  72942. /**
  72943. * Defines the total number of tasks
  72944. */
  72945. totalCount: number;
  72946. /**
  72947. * Defines the task that was just processed
  72948. */
  72949. task: AbstractAssetTask;
  72950. /**
  72951. * Creates a AssetsProgressEvent
  72952. * @param remainingCount defines the number of remaining tasks to process
  72953. * @param totalCount defines the total number of tasks
  72954. * @param task defines the task that was just processed
  72955. */
  72956. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72957. }
  72958. /**
  72959. * Define a task used by AssetsManager to load assets into a container
  72960. */
  72961. export class ContainerAssetTask extends AbstractAssetTask {
  72962. /**
  72963. * Defines the name of the task
  72964. */
  72965. name: string;
  72966. /**
  72967. * Defines the list of mesh's names you want to load
  72968. */
  72969. meshesNames: any;
  72970. /**
  72971. * Defines the root url to use as a base to load your meshes and associated resources
  72972. */
  72973. rootUrl: string;
  72974. /**
  72975. * Defines the filename or File of the scene to load from
  72976. */
  72977. sceneFilename: string | File;
  72978. /**
  72979. * Get the loaded asset container
  72980. */
  72981. loadedContainer: AssetContainer;
  72982. /**
  72983. * Gets the list of loaded meshes
  72984. */
  72985. loadedMeshes: Array<AbstractMesh>;
  72986. /**
  72987. * Gets the list of loaded particle systems
  72988. */
  72989. loadedParticleSystems: Array<IParticleSystem>;
  72990. /**
  72991. * Gets the list of loaded skeletons
  72992. */
  72993. loadedSkeletons: Array<Skeleton>;
  72994. /**
  72995. * Gets the list of loaded animation groups
  72996. */
  72997. loadedAnimationGroups: Array<AnimationGroup>;
  72998. /**
  72999. * Callback called when the task is successful
  73000. */
  73001. onSuccess: (task: ContainerAssetTask) => void;
  73002. /**
  73003. * Callback called when the task is successful
  73004. */
  73005. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73006. /**
  73007. * Creates a new ContainerAssetTask
  73008. * @param name defines the name of the task
  73009. * @param meshesNames defines the list of mesh's names you want to load
  73010. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73011. * @param sceneFilename defines the filename or File of the scene to load from
  73012. */
  73013. constructor(
  73014. /**
  73015. * Defines the name of the task
  73016. */
  73017. name: string,
  73018. /**
  73019. * Defines the list of mesh's names you want to load
  73020. */
  73021. meshesNames: any,
  73022. /**
  73023. * Defines the root url to use as a base to load your meshes and associated resources
  73024. */
  73025. rootUrl: string,
  73026. /**
  73027. * Defines the filename or File of the scene to load from
  73028. */
  73029. sceneFilename: string | File);
  73030. /**
  73031. * Execute the current task
  73032. * @param scene defines the scene where you want your assets to be loaded
  73033. * @param onSuccess is a callback called when the task is successfully executed
  73034. * @param onError is a callback called if an error occurs
  73035. */
  73036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73037. }
  73038. /**
  73039. * Define a task used by AssetsManager to load meshes
  73040. */
  73041. export class MeshAssetTask extends AbstractAssetTask {
  73042. /**
  73043. * Defines the name of the task
  73044. */
  73045. name: string;
  73046. /**
  73047. * Defines the list of mesh's names you want to load
  73048. */
  73049. meshesNames: any;
  73050. /**
  73051. * Defines the root url to use as a base to load your meshes and associated resources
  73052. */
  73053. rootUrl: string;
  73054. /**
  73055. * Defines the filename or File of the scene to load from
  73056. */
  73057. sceneFilename: string | File;
  73058. /**
  73059. * Gets the list of loaded meshes
  73060. */
  73061. loadedMeshes: Array<AbstractMesh>;
  73062. /**
  73063. * Gets the list of loaded particle systems
  73064. */
  73065. loadedParticleSystems: Array<IParticleSystem>;
  73066. /**
  73067. * Gets the list of loaded skeletons
  73068. */
  73069. loadedSkeletons: Array<Skeleton>;
  73070. /**
  73071. * Gets the list of loaded animation groups
  73072. */
  73073. loadedAnimationGroups: Array<AnimationGroup>;
  73074. /**
  73075. * Callback called when the task is successful
  73076. */
  73077. onSuccess: (task: MeshAssetTask) => void;
  73078. /**
  73079. * Callback called when the task is successful
  73080. */
  73081. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73082. /**
  73083. * Creates a new MeshAssetTask
  73084. * @param name defines the name of the task
  73085. * @param meshesNames defines the list of mesh's names you want to load
  73086. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73087. * @param sceneFilename defines the filename or File of the scene to load from
  73088. */
  73089. constructor(
  73090. /**
  73091. * Defines the name of the task
  73092. */
  73093. name: string,
  73094. /**
  73095. * Defines the list of mesh's names you want to load
  73096. */
  73097. meshesNames: any,
  73098. /**
  73099. * Defines the root url to use as a base to load your meshes and associated resources
  73100. */
  73101. rootUrl: string,
  73102. /**
  73103. * Defines the filename or File of the scene to load from
  73104. */
  73105. sceneFilename: string | File);
  73106. /**
  73107. * Execute the current task
  73108. * @param scene defines the scene where you want your assets to be loaded
  73109. * @param onSuccess is a callback called when the task is successfully executed
  73110. * @param onError is a callback called if an error occurs
  73111. */
  73112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73113. }
  73114. /**
  73115. * Define a task used by AssetsManager to load text content
  73116. */
  73117. export class TextFileAssetTask extends AbstractAssetTask {
  73118. /**
  73119. * Defines the name of the task
  73120. */
  73121. name: string;
  73122. /**
  73123. * Defines the location of the file to load
  73124. */
  73125. url: string;
  73126. /**
  73127. * Gets the loaded text string
  73128. */
  73129. text: string;
  73130. /**
  73131. * Callback called when the task is successful
  73132. */
  73133. onSuccess: (task: TextFileAssetTask) => void;
  73134. /**
  73135. * Callback called when the task is successful
  73136. */
  73137. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73138. /**
  73139. * Creates a new TextFileAssetTask object
  73140. * @param name defines the name of the task
  73141. * @param url defines the location of the file to load
  73142. */
  73143. constructor(
  73144. /**
  73145. * Defines the name of the task
  73146. */
  73147. name: string,
  73148. /**
  73149. * Defines the location of the file to load
  73150. */
  73151. url: string);
  73152. /**
  73153. * Execute the current task
  73154. * @param scene defines the scene where you want your assets to be loaded
  73155. * @param onSuccess is a callback called when the task is successfully executed
  73156. * @param onError is a callback called if an error occurs
  73157. */
  73158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73159. }
  73160. /**
  73161. * Define a task used by AssetsManager to load binary data
  73162. */
  73163. export class BinaryFileAssetTask extends AbstractAssetTask {
  73164. /**
  73165. * Defines the name of the task
  73166. */
  73167. name: string;
  73168. /**
  73169. * Defines the location of the file to load
  73170. */
  73171. url: string;
  73172. /**
  73173. * Gets the lodaded data (as an array buffer)
  73174. */
  73175. data: ArrayBuffer;
  73176. /**
  73177. * Callback called when the task is successful
  73178. */
  73179. onSuccess: (task: BinaryFileAssetTask) => void;
  73180. /**
  73181. * Callback called when the task is successful
  73182. */
  73183. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73184. /**
  73185. * Creates a new BinaryFileAssetTask object
  73186. * @param name defines the name of the new task
  73187. * @param url defines the location of the file to load
  73188. */
  73189. constructor(
  73190. /**
  73191. * Defines the name of the task
  73192. */
  73193. name: string,
  73194. /**
  73195. * Defines the location of the file to load
  73196. */
  73197. url: string);
  73198. /**
  73199. * Execute the current task
  73200. * @param scene defines the scene where you want your assets to be loaded
  73201. * @param onSuccess is a callback called when the task is successfully executed
  73202. * @param onError is a callback called if an error occurs
  73203. */
  73204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73205. }
  73206. /**
  73207. * Define a task used by AssetsManager to load images
  73208. */
  73209. export class ImageAssetTask extends AbstractAssetTask {
  73210. /**
  73211. * Defines the name of the task
  73212. */
  73213. name: string;
  73214. /**
  73215. * Defines the location of the image to load
  73216. */
  73217. url: string;
  73218. /**
  73219. * Gets the loaded images
  73220. */
  73221. image: HTMLImageElement;
  73222. /**
  73223. * Callback called when the task is successful
  73224. */
  73225. onSuccess: (task: ImageAssetTask) => void;
  73226. /**
  73227. * Callback called when the task is successful
  73228. */
  73229. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73230. /**
  73231. * Creates a new ImageAssetTask
  73232. * @param name defines the name of the task
  73233. * @param url defines the location of the image to load
  73234. */
  73235. constructor(
  73236. /**
  73237. * Defines the name of the task
  73238. */
  73239. name: string,
  73240. /**
  73241. * Defines the location of the image to load
  73242. */
  73243. url: string);
  73244. /**
  73245. * Execute the current task
  73246. * @param scene defines the scene where you want your assets to be loaded
  73247. * @param onSuccess is a callback called when the task is successfully executed
  73248. * @param onError is a callback called if an error occurs
  73249. */
  73250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73251. }
  73252. /**
  73253. * Defines the interface used by texture loading tasks
  73254. */
  73255. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73256. /**
  73257. * Gets the loaded texture
  73258. */
  73259. texture: TEX;
  73260. }
  73261. /**
  73262. * Define a task used by AssetsManager to load 2D textures
  73263. */
  73264. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73265. /**
  73266. * Defines the name of the task
  73267. */
  73268. name: string;
  73269. /**
  73270. * Defines the location of the file to load
  73271. */
  73272. url: string;
  73273. /**
  73274. * Defines if mipmap should not be generated (default is false)
  73275. */
  73276. noMipmap?: boolean | undefined;
  73277. /**
  73278. * Defines if texture must be inverted on Y axis (default is true)
  73279. */
  73280. invertY: boolean;
  73281. /**
  73282. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73283. */
  73284. samplingMode: number;
  73285. /**
  73286. * Gets the loaded texture
  73287. */
  73288. texture: Texture;
  73289. /**
  73290. * Callback called when the task is successful
  73291. */
  73292. onSuccess: (task: TextureAssetTask) => void;
  73293. /**
  73294. * Callback called when the task is successful
  73295. */
  73296. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73297. /**
  73298. * Creates a new TextureAssetTask object
  73299. * @param name defines the name of the task
  73300. * @param url defines the location of the file to load
  73301. * @param noMipmap defines if mipmap should not be generated (default is false)
  73302. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73303. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73304. */
  73305. constructor(
  73306. /**
  73307. * Defines the name of the task
  73308. */
  73309. name: string,
  73310. /**
  73311. * Defines the location of the file to load
  73312. */
  73313. url: string,
  73314. /**
  73315. * Defines if mipmap should not be generated (default is false)
  73316. */
  73317. noMipmap?: boolean | undefined,
  73318. /**
  73319. * Defines if texture must be inverted on Y axis (default is true)
  73320. */
  73321. invertY?: boolean,
  73322. /**
  73323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73324. */
  73325. samplingMode?: number);
  73326. /**
  73327. * Execute the current task
  73328. * @param scene defines the scene where you want your assets to be loaded
  73329. * @param onSuccess is a callback called when the task is successfully executed
  73330. * @param onError is a callback called if an error occurs
  73331. */
  73332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73333. }
  73334. /**
  73335. * Define a task used by AssetsManager to load cube textures
  73336. */
  73337. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73338. /**
  73339. * Defines the name of the task
  73340. */
  73341. name: string;
  73342. /**
  73343. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73344. */
  73345. url: string;
  73346. /**
  73347. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73348. */
  73349. extensions?: string[] | undefined;
  73350. /**
  73351. * Defines if mipmaps should not be generated (default is false)
  73352. */
  73353. noMipmap?: boolean | undefined;
  73354. /**
  73355. * Defines the explicit list of files (undefined by default)
  73356. */
  73357. files?: string[] | undefined;
  73358. /**
  73359. * Gets the loaded texture
  73360. */
  73361. texture: CubeTexture;
  73362. /**
  73363. * Callback called when the task is successful
  73364. */
  73365. onSuccess: (task: CubeTextureAssetTask) => void;
  73366. /**
  73367. * Callback called when the task is successful
  73368. */
  73369. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73370. /**
  73371. * Creates a new CubeTextureAssetTask
  73372. * @param name defines the name of the task
  73373. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73374. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73375. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73376. * @param files defines the explicit list of files (undefined by default)
  73377. */
  73378. constructor(
  73379. /**
  73380. * Defines the name of the task
  73381. */
  73382. name: string,
  73383. /**
  73384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73385. */
  73386. url: string,
  73387. /**
  73388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73389. */
  73390. extensions?: string[] | undefined,
  73391. /**
  73392. * Defines if mipmaps should not be generated (default is false)
  73393. */
  73394. noMipmap?: boolean | undefined,
  73395. /**
  73396. * Defines the explicit list of files (undefined by default)
  73397. */
  73398. files?: string[] | undefined);
  73399. /**
  73400. * Execute the current task
  73401. * @param scene defines the scene where you want your assets to be loaded
  73402. * @param onSuccess is a callback called when the task is successfully executed
  73403. * @param onError is a callback called if an error occurs
  73404. */
  73405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73406. }
  73407. /**
  73408. * Define a task used by AssetsManager to load HDR cube textures
  73409. */
  73410. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73411. /**
  73412. * Defines the name of the task
  73413. */
  73414. name: string;
  73415. /**
  73416. * Defines the location of the file to load
  73417. */
  73418. url: string;
  73419. /**
  73420. * Defines the desired size (the more it increases the longer the generation will be)
  73421. */
  73422. size: number;
  73423. /**
  73424. * Defines if mipmaps should not be generated (default is false)
  73425. */
  73426. noMipmap: boolean;
  73427. /**
  73428. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73429. */
  73430. generateHarmonics: boolean;
  73431. /**
  73432. * 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)
  73433. */
  73434. gammaSpace: boolean;
  73435. /**
  73436. * Internal Use Only
  73437. */
  73438. reserved: boolean;
  73439. /**
  73440. * Gets the loaded texture
  73441. */
  73442. texture: HDRCubeTexture;
  73443. /**
  73444. * Callback called when the task is successful
  73445. */
  73446. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73447. /**
  73448. * Callback called when the task is successful
  73449. */
  73450. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73451. /**
  73452. * Creates a new HDRCubeTextureAssetTask object
  73453. * @param name defines the name of the task
  73454. * @param url defines the location of the file to load
  73455. * @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.
  73456. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73457. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73458. * @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)
  73459. * @param reserved Internal use only
  73460. */
  73461. constructor(
  73462. /**
  73463. * Defines the name of the task
  73464. */
  73465. name: string,
  73466. /**
  73467. * Defines the location of the file to load
  73468. */
  73469. url: string,
  73470. /**
  73471. * Defines the desired size (the more it increases the longer the generation will be)
  73472. */
  73473. size: number,
  73474. /**
  73475. * Defines if mipmaps should not be generated (default is false)
  73476. */
  73477. noMipmap?: boolean,
  73478. /**
  73479. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73480. */
  73481. generateHarmonics?: boolean,
  73482. /**
  73483. * 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)
  73484. */
  73485. gammaSpace?: boolean,
  73486. /**
  73487. * Internal Use Only
  73488. */
  73489. reserved?: boolean);
  73490. /**
  73491. * Execute the current task
  73492. * @param scene defines the scene where you want your assets to be loaded
  73493. * @param onSuccess is a callback called when the task is successfully executed
  73494. * @param onError is a callback called if an error occurs
  73495. */
  73496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73497. }
  73498. /**
  73499. * Define a task used by AssetsManager to load Equirectangular cube textures
  73500. */
  73501. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73502. /**
  73503. * Defines the name of the task
  73504. */
  73505. name: string;
  73506. /**
  73507. * Defines the location of the file to load
  73508. */
  73509. url: string;
  73510. /**
  73511. * Defines the desired size (the more it increases the longer the generation will be)
  73512. */
  73513. size: number;
  73514. /**
  73515. * Defines if mipmaps should not be generated (default is false)
  73516. */
  73517. noMipmap: boolean;
  73518. /**
  73519. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73520. * but the standard material would require them in Gamma space) (default is true)
  73521. */
  73522. gammaSpace: boolean;
  73523. /**
  73524. * Gets the loaded texture
  73525. */
  73526. texture: EquiRectangularCubeTexture;
  73527. /**
  73528. * Callback called when the task is successful
  73529. */
  73530. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73531. /**
  73532. * Callback called when the task is successful
  73533. */
  73534. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73535. /**
  73536. * Creates a new EquiRectangularCubeTextureAssetTask object
  73537. * @param name defines the name of the task
  73538. * @param url defines the location of the file to load
  73539. * @param size defines the desired size (the more it increases the longer the generation will be)
  73540. * If the size is omitted this implies you are using a preprocessed cubemap.
  73541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73542. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73543. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73544. * (default is true)
  73545. */
  73546. constructor(
  73547. /**
  73548. * Defines the name of the task
  73549. */
  73550. name: string,
  73551. /**
  73552. * Defines the location of the file to load
  73553. */
  73554. url: string,
  73555. /**
  73556. * Defines the desired size (the more it increases the longer the generation will be)
  73557. */
  73558. size: number,
  73559. /**
  73560. * Defines if mipmaps should not be generated (default is false)
  73561. */
  73562. noMipmap?: boolean,
  73563. /**
  73564. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73565. * but the standard material would require them in Gamma space) (default is true)
  73566. */
  73567. gammaSpace?: boolean);
  73568. /**
  73569. * Execute the current task
  73570. * @param scene defines the scene where you want your assets to be loaded
  73571. * @param onSuccess is a callback called when the task is successfully executed
  73572. * @param onError is a callback called if an error occurs
  73573. */
  73574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73575. }
  73576. /**
  73577. * This class can be used to easily import assets into a scene
  73578. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73579. */
  73580. export class AssetsManager {
  73581. private _scene;
  73582. private _isLoading;
  73583. protected _tasks: AbstractAssetTask[];
  73584. protected _waitingTasksCount: number;
  73585. protected _totalTasksCount: number;
  73586. /**
  73587. * Callback called when all tasks are processed
  73588. */
  73589. onFinish: (tasks: AbstractAssetTask[]) => void;
  73590. /**
  73591. * Callback called when a task is successful
  73592. */
  73593. onTaskSuccess: (task: AbstractAssetTask) => void;
  73594. /**
  73595. * Callback called when a task had an error
  73596. */
  73597. onTaskError: (task: AbstractAssetTask) => void;
  73598. /**
  73599. * Callback called when a task is done (whatever the result is)
  73600. */
  73601. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73602. /**
  73603. * Observable called when all tasks are processed
  73604. */
  73605. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73606. /**
  73607. * Observable called when a task had an error
  73608. */
  73609. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73610. /**
  73611. * Observable called when all tasks were executed
  73612. */
  73613. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73614. /**
  73615. * Observable called when a task is done (whatever the result is)
  73616. */
  73617. onProgressObservable: Observable<IAssetsProgressEvent>;
  73618. /**
  73619. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73620. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73621. */
  73622. useDefaultLoadingScreen: boolean;
  73623. /**
  73624. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73625. * when all assets have been downloaded.
  73626. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73627. */
  73628. autoHideLoadingUI: boolean;
  73629. /**
  73630. * Creates a new AssetsManager
  73631. * @param scene defines the scene to work on
  73632. */
  73633. constructor(scene: Scene);
  73634. /**
  73635. * Add a ContainerAssetTask to the list of active tasks
  73636. * @param taskName defines the name of the new task
  73637. * @param meshesNames defines the name of meshes to load
  73638. * @param rootUrl defines the root url to use to locate files
  73639. * @param sceneFilename defines the filename of the scene file
  73640. * @returns a new ContainerAssetTask object
  73641. */
  73642. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73643. /**
  73644. * Add a MeshAssetTask to the list of active tasks
  73645. * @param taskName defines the name of the new task
  73646. * @param meshesNames defines the name of meshes to load
  73647. * @param rootUrl defines the root url to use to locate files
  73648. * @param sceneFilename defines the filename of the scene file
  73649. * @returns a new MeshAssetTask object
  73650. */
  73651. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73652. /**
  73653. * Add a TextFileAssetTask to the list of active tasks
  73654. * @param taskName defines the name of the new task
  73655. * @param url defines the url of the file to load
  73656. * @returns a new TextFileAssetTask object
  73657. */
  73658. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73659. /**
  73660. * Add a BinaryFileAssetTask to the list of active tasks
  73661. * @param taskName defines the name of the new task
  73662. * @param url defines the url of the file to load
  73663. * @returns a new BinaryFileAssetTask object
  73664. */
  73665. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73666. /**
  73667. * Add a ImageAssetTask to the list of active tasks
  73668. * @param taskName defines the name of the new task
  73669. * @param url defines the url of the file to load
  73670. * @returns a new ImageAssetTask object
  73671. */
  73672. addImageTask(taskName: string, url: string): ImageAssetTask;
  73673. /**
  73674. * Add a TextureAssetTask to the list of active tasks
  73675. * @param taskName defines the name of the new task
  73676. * @param url defines the url of the file to load
  73677. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73678. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73679. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73680. * @returns a new TextureAssetTask object
  73681. */
  73682. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73683. /**
  73684. * Add a CubeTextureAssetTask to the list of active tasks
  73685. * @param taskName defines the name of the new task
  73686. * @param url defines the url of the file to load
  73687. * @param extensions defines the extension to use to load the cube map (can be null)
  73688. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73689. * @param files defines the list of files to load (can be null)
  73690. * @returns a new CubeTextureAssetTask object
  73691. */
  73692. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73693. /**
  73694. *
  73695. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73696. * @param taskName defines the name of the new task
  73697. * @param url defines the url of the file to load
  73698. * @param size defines the size you want for the cubemap (can be null)
  73699. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73700. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73701. * @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)
  73702. * @param reserved Internal use only
  73703. * @returns a new HDRCubeTextureAssetTask object
  73704. */
  73705. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73706. /**
  73707. *
  73708. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73709. * @param taskName defines the name of the new task
  73710. * @param url defines the url of the file to load
  73711. * @param size defines the size you want for the cubemap (can be null)
  73712. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73713. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73714. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73715. * @returns a new EquiRectangularCubeTextureAssetTask object
  73716. */
  73717. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73718. /**
  73719. * Remove a task from the assets manager.
  73720. * @param task the task to remove
  73721. */
  73722. removeTask(task: AbstractAssetTask): void;
  73723. private _decreaseWaitingTasksCount;
  73724. private _runTask;
  73725. /**
  73726. * Reset the AssetsManager and remove all tasks
  73727. * @return the current instance of the AssetsManager
  73728. */
  73729. reset(): AssetsManager;
  73730. /**
  73731. * Start the loading process
  73732. * @return the current instance of the AssetsManager
  73733. */
  73734. load(): AssetsManager;
  73735. /**
  73736. * Start the loading process as an async operation
  73737. * @return a promise returning the list of failed tasks
  73738. */
  73739. loadAsync(): Promise<void>;
  73740. }
  73741. }
  73742. declare module BABYLON {
  73743. /**
  73744. * Wrapper class for promise with external resolve and reject.
  73745. */
  73746. export class Deferred<T> {
  73747. /**
  73748. * The promise associated with this deferred object.
  73749. */
  73750. readonly promise: Promise<T>;
  73751. private _resolve;
  73752. private _reject;
  73753. /**
  73754. * The resolve method of the promise associated with this deferred object.
  73755. */
  73756. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73757. /**
  73758. * The reject method of the promise associated with this deferred object.
  73759. */
  73760. get reject(): (reason?: any) => void;
  73761. /**
  73762. * Constructor for this deferred object.
  73763. */
  73764. constructor();
  73765. }
  73766. }
  73767. declare module BABYLON {
  73768. /**
  73769. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73770. */
  73771. export class MeshExploder {
  73772. private _centerMesh;
  73773. private _meshes;
  73774. private _meshesOrigins;
  73775. private _toCenterVectors;
  73776. private _scaledDirection;
  73777. private _newPosition;
  73778. private _centerPosition;
  73779. /**
  73780. * Explodes meshes from a center mesh.
  73781. * @param meshes The meshes to explode.
  73782. * @param centerMesh The mesh to be center of explosion.
  73783. */
  73784. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73785. private _setCenterMesh;
  73786. /**
  73787. * Get class name
  73788. * @returns "MeshExploder"
  73789. */
  73790. getClassName(): string;
  73791. /**
  73792. * "Exploded meshes"
  73793. * @returns Array of meshes with the centerMesh at index 0.
  73794. */
  73795. getMeshes(): Array<Mesh>;
  73796. /**
  73797. * Explodes meshes giving a specific direction
  73798. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73799. */
  73800. explode(direction?: number): void;
  73801. }
  73802. }
  73803. declare module BABYLON {
  73804. /**
  73805. * Class used to help managing file picking and drag'n'drop
  73806. */
  73807. export class FilesInput {
  73808. /**
  73809. * List of files ready to be loaded
  73810. */
  73811. static get FilesToLoad(): {
  73812. [key: string]: File;
  73813. };
  73814. /**
  73815. * Callback called when a file is processed
  73816. */
  73817. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73818. private _engine;
  73819. private _currentScene;
  73820. private _sceneLoadedCallback;
  73821. private _progressCallback;
  73822. private _additionalRenderLoopLogicCallback;
  73823. private _textureLoadingCallback;
  73824. private _startingProcessingFilesCallback;
  73825. private _onReloadCallback;
  73826. private _errorCallback;
  73827. private _elementToMonitor;
  73828. private _sceneFileToLoad;
  73829. private _filesToLoad;
  73830. /**
  73831. * Creates a new FilesInput
  73832. * @param engine defines the rendering engine
  73833. * @param scene defines the hosting scene
  73834. * @param sceneLoadedCallback callback called when scene is loaded
  73835. * @param progressCallback callback called to track progress
  73836. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73837. * @param textureLoadingCallback callback called when a texture is loading
  73838. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73839. * @param onReloadCallback callback called when a reload is requested
  73840. * @param errorCallback callback call if an error occurs
  73841. */
  73842. 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>);
  73843. private _dragEnterHandler;
  73844. private _dragOverHandler;
  73845. private _dropHandler;
  73846. /**
  73847. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73848. * @param elementToMonitor defines the DOM element to track
  73849. */
  73850. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73851. /** Gets the current list of files to load */
  73852. get filesToLoad(): File[];
  73853. /**
  73854. * Release all associated resources
  73855. */
  73856. dispose(): void;
  73857. private renderFunction;
  73858. private drag;
  73859. private drop;
  73860. private _traverseFolder;
  73861. private _processFiles;
  73862. /**
  73863. * Load files from a drop event
  73864. * @param event defines the drop event to use as source
  73865. */
  73866. loadFiles(event: any): void;
  73867. private _processReload;
  73868. /**
  73869. * Reload the current scene from the loaded files
  73870. */
  73871. reload(): void;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /**
  73876. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73877. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73878. */
  73879. export class SceneOptimization {
  73880. /**
  73881. * Defines the priority of this optimization (0 by default which means first in the list)
  73882. */
  73883. priority: number;
  73884. /**
  73885. * Gets a string describing the action executed by the current optimization
  73886. * @returns description string
  73887. */
  73888. getDescription(): string;
  73889. /**
  73890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73891. * @param scene defines the current scene where to apply this optimization
  73892. * @param optimizer defines the current optimizer
  73893. * @returns true if everything that can be done was applied
  73894. */
  73895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73896. /**
  73897. * Creates the SceneOptimization object
  73898. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73899. * @param desc defines the description associated with the optimization
  73900. */
  73901. constructor(
  73902. /**
  73903. * Defines the priority of this optimization (0 by default which means first in the list)
  73904. */
  73905. priority?: number);
  73906. }
  73907. /**
  73908. * Defines an optimization used to reduce the size of render target textures
  73909. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73910. */
  73911. export class TextureOptimization extends SceneOptimization {
  73912. /**
  73913. * Defines the priority of this optimization (0 by default which means first in the list)
  73914. */
  73915. priority: number;
  73916. /**
  73917. * 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
  73918. */
  73919. maximumSize: number;
  73920. /**
  73921. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73922. */
  73923. step: number;
  73924. /**
  73925. * Gets a string describing the action executed by the current optimization
  73926. * @returns description string
  73927. */
  73928. getDescription(): string;
  73929. /**
  73930. * Creates the TextureOptimization object
  73931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73932. * @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
  73933. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73934. */
  73935. constructor(
  73936. /**
  73937. * Defines the priority of this optimization (0 by default which means first in the list)
  73938. */
  73939. priority?: number,
  73940. /**
  73941. * 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
  73942. */
  73943. maximumSize?: number,
  73944. /**
  73945. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73946. */
  73947. step?: number);
  73948. /**
  73949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73950. * @param scene defines the current scene where to apply this optimization
  73951. * @param optimizer defines the current optimizer
  73952. * @returns true if everything that can be done was applied
  73953. */
  73954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73955. }
  73956. /**
  73957. * Defines an optimization used to increase or decrease the rendering resolution
  73958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73959. */
  73960. export class HardwareScalingOptimization extends SceneOptimization {
  73961. /**
  73962. * Defines the priority of this optimization (0 by default which means first in the list)
  73963. */
  73964. priority: number;
  73965. /**
  73966. * Defines the maximum scale to use (2 by default)
  73967. */
  73968. maximumScale: number;
  73969. /**
  73970. * Defines the step to use between two passes (0.5 by default)
  73971. */
  73972. step: number;
  73973. private _currentScale;
  73974. private _directionOffset;
  73975. /**
  73976. * Gets a string describing the action executed by the current optimization
  73977. * @return description string
  73978. */
  73979. getDescription(): string;
  73980. /**
  73981. * Creates the HardwareScalingOptimization object
  73982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73983. * @param maximumScale defines the maximum scale to use (2 by default)
  73984. * @param step defines the step to use between two passes (0.5 by default)
  73985. */
  73986. constructor(
  73987. /**
  73988. * Defines the priority of this optimization (0 by default which means first in the list)
  73989. */
  73990. priority?: number,
  73991. /**
  73992. * Defines the maximum scale to use (2 by default)
  73993. */
  73994. maximumScale?: number,
  73995. /**
  73996. * Defines the step to use between two passes (0.5 by default)
  73997. */
  73998. step?: number);
  73999. /**
  74000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74001. * @param scene defines the current scene where to apply this optimization
  74002. * @param optimizer defines the current optimizer
  74003. * @returns true if everything that can be done was applied
  74004. */
  74005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74006. }
  74007. /**
  74008. * Defines an optimization used to remove shadows
  74009. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74010. */
  74011. export class ShadowsOptimization extends SceneOptimization {
  74012. /**
  74013. * Gets a string describing the action executed by the current optimization
  74014. * @return description string
  74015. */
  74016. getDescription(): string;
  74017. /**
  74018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74019. * @param scene defines the current scene where to apply this optimization
  74020. * @param optimizer defines the current optimizer
  74021. * @returns true if everything that can be done was applied
  74022. */
  74023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74024. }
  74025. /**
  74026. * Defines an optimization used to turn post-processes off
  74027. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74028. */
  74029. export class PostProcessesOptimization extends SceneOptimization {
  74030. /**
  74031. * Gets a string describing the action executed by the current optimization
  74032. * @return description string
  74033. */
  74034. getDescription(): string;
  74035. /**
  74036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74037. * @param scene defines the current scene where to apply this optimization
  74038. * @param optimizer defines the current optimizer
  74039. * @returns true if everything that can be done was applied
  74040. */
  74041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74042. }
  74043. /**
  74044. * Defines an optimization used to turn lens flares off
  74045. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74046. */
  74047. export class LensFlaresOptimization extends SceneOptimization {
  74048. /**
  74049. * Gets a string describing the action executed by the current optimization
  74050. * @return description string
  74051. */
  74052. getDescription(): string;
  74053. /**
  74054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74055. * @param scene defines the current scene where to apply this optimization
  74056. * @param optimizer defines the current optimizer
  74057. * @returns true if everything that can be done was applied
  74058. */
  74059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74060. }
  74061. /**
  74062. * Defines an optimization based on user defined callback.
  74063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74064. */
  74065. export class CustomOptimization extends SceneOptimization {
  74066. /**
  74067. * Callback called to apply the custom optimization.
  74068. */
  74069. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74070. /**
  74071. * Callback called to get custom description
  74072. */
  74073. onGetDescription: () => string;
  74074. /**
  74075. * Gets a string describing the action executed by the current optimization
  74076. * @returns description string
  74077. */
  74078. getDescription(): string;
  74079. /**
  74080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74081. * @param scene defines the current scene where to apply this optimization
  74082. * @param optimizer defines the current optimizer
  74083. * @returns true if everything that can be done was applied
  74084. */
  74085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74086. }
  74087. /**
  74088. * Defines an optimization used to turn particles off
  74089. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74090. */
  74091. export class ParticlesOptimization extends SceneOptimization {
  74092. /**
  74093. * Gets a string describing the action executed by the current optimization
  74094. * @return description string
  74095. */
  74096. getDescription(): string;
  74097. /**
  74098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74099. * @param scene defines the current scene where to apply this optimization
  74100. * @param optimizer defines the current optimizer
  74101. * @returns true if everything that can be done was applied
  74102. */
  74103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74104. }
  74105. /**
  74106. * Defines an optimization used to turn render targets off
  74107. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74108. */
  74109. export class RenderTargetsOptimization extends SceneOptimization {
  74110. /**
  74111. * Gets a string describing the action executed by the current optimization
  74112. * @return description string
  74113. */
  74114. getDescription(): string;
  74115. /**
  74116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74117. * @param scene defines the current scene where to apply this optimization
  74118. * @param optimizer defines the current optimizer
  74119. * @returns true if everything that can be done was applied
  74120. */
  74121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74122. }
  74123. /**
  74124. * Defines an optimization used to merge meshes with compatible materials
  74125. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74126. */
  74127. export class MergeMeshesOptimization extends SceneOptimization {
  74128. private static _UpdateSelectionTree;
  74129. /**
  74130. * Gets or sets a boolean which defines if optimization octree has to be updated
  74131. */
  74132. static get UpdateSelectionTree(): boolean;
  74133. /**
  74134. * Gets or sets a boolean which defines if optimization octree has to be updated
  74135. */
  74136. static set UpdateSelectionTree(value: boolean);
  74137. /**
  74138. * Gets a string describing the action executed by the current optimization
  74139. * @return description string
  74140. */
  74141. getDescription(): string;
  74142. private _canBeMerged;
  74143. /**
  74144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74145. * @param scene defines the current scene where to apply this optimization
  74146. * @param optimizer defines the current optimizer
  74147. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74148. * @returns true if everything that can be done was applied
  74149. */
  74150. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74151. }
  74152. /**
  74153. * Defines a list of options used by SceneOptimizer
  74154. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74155. */
  74156. export class SceneOptimizerOptions {
  74157. /**
  74158. * Defines the target frame rate to reach (60 by default)
  74159. */
  74160. targetFrameRate: number;
  74161. /**
  74162. * Defines the interval between two checkes (2000ms by default)
  74163. */
  74164. trackerDuration: number;
  74165. /**
  74166. * Gets the list of optimizations to apply
  74167. */
  74168. optimizations: SceneOptimization[];
  74169. /**
  74170. * Creates a new list of options used by SceneOptimizer
  74171. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74172. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74173. */
  74174. constructor(
  74175. /**
  74176. * Defines the target frame rate to reach (60 by default)
  74177. */
  74178. targetFrameRate?: number,
  74179. /**
  74180. * Defines the interval between two checkes (2000ms by default)
  74181. */
  74182. trackerDuration?: number);
  74183. /**
  74184. * Add a new optimization
  74185. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74186. * @returns the current SceneOptimizerOptions
  74187. */
  74188. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74189. /**
  74190. * Add a new custom optimization
  74191. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74192. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74193. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74194. * @returns the current SceneOptimizerOptions
  74195. */
  74196. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74197. /**
  74198. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74199. * @param targetFrameRate defines the target frame rate (60 by default)
  74200. * @returns a SceneOptimizerOptions object
  74201. */
  74202. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74203. /**
  74204. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74205. * @param targetFrameRate defines the target frame rate (60 by default)
  74206. * @returns a SceneOptimizerOptions object
  74207. */
  74208. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74209. /**
  74210. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74211. * @param targetFrameRate defines the target frame rate (60 by default)
  74212. * @returns a SceneOptimizerOptions object
  74213. */
  74214. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74215. }
  74216. /**
  74217. * Class used to run optimizations in order to reach a target frame rate
  74218. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74219. */
  74220. export class SceneOptimizer implements IDisposable {
  74221. private _isRunning;
  74222. private _options;
  74223. private _scene;
  74224. private _currentPriorityLevel;
  74225. private _targetFrameRate;
  74226. private _trackerDuration;
  74227. private _currentFrameRate;
  74228. private _sceneDisposeObserver;
  74229. private _improvementMode;
  74230. /**
  74231. * Defines an observable called when the optimizer reaches the target frame rate
  74232. */
  74233. onSuccessObservable: Observable<SceneOptimizer>;
  74234. /**
  74235. * Defines an observable called when the optimizer enables an optimization
  74236. */
  74237. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74238. /**
  74239. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74240. */
  74241. onFailureObservable: Observable<SceneOptimizer>;
  74242. /**
  74243. * Gets a boolean indicating if the optimizer is in improvement mode
  74244. */
  74245. get isInImprovementMode(): boolean;
  74246. /**
  74247. * Gets the current priority level (0 at start)
  74248. */
  74249. get currentPriorityLevel(): number;
  74250. /**
  74251. * Gets the current frame rate checked by the SceneOptimizer
  74252. */
  74253. get currentFrameRate(): number;
  74254. /**
  74255. * Gets or sets the current target frame rate (60 by default)
  74256. */
  74257. get targetFrameRate(): number;
  74258. /**
  74259. * Gets or sets the current target frame rate (60 by default)
  74260. */
  74261. set targetFrameRate(value: number);
  74262. /**
  74263. * Gets or sets the current interval between two checks (every 2000ms by default)
  74264. */
  74265. get trackerDuration(): number;
  74266. /**
  74267. * Gets or sets the current interval between two checks (every 2000ms by default)
  74268. */
  74269. set trackerDuration(value: number);
  74270. /**
  74271. * Gets the list of active optimizations
  74272. */
  74273. get optimizations(): SceneOptimization[];
  74274. /**
  74275. * Creates a new SceneOptimizer
  74276. * @param scene defines the scene to work on
  74277. * @param options defines the options to use with the SceneOptimizer
  74278. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74279. * @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)
  74280. */
  74281. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74282. /**
  74283. * Stops the current optimizer
  74284. */
  74285. stop(): void;
  74286. /**
  74287. * Reset the optimizer to initial step (current priority level = 0)
  74288. */
  74289. reset(): void;
  74290. /**
  74291. * Start the optimizer. By default it will try to reach a specific framerate
  74292. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74293. */
  74294. start(): void;
  74295. private _checkCurrentState;
  74296. /**
  74297. * Release all resources
  74298. */
  74299. dispose(): void;
  74300. /**
  74301. * Helper function to create a SceneOptimizer with one single line of code
  74302. * @param scene defines the scene to work on
  74303. * @param options defines the options to use with the SceneOptimizer
  74304. * @param onSuccess defines a callback to call on success
  74305. * @param onFailure defines a callback to call on failure
  74306. * @returns the new SceneOptimizer object
  74307. */
  74308. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74309. }
  74310. }
  74311. declare module BABYLON {
  74312. /**
  74313. * Class used to serialize a scene into a string
  74314. */
  74315. export class SceneSerializer {
  74316. /**
  74317. * Clear cache used by a previous serialization
  74318. */
  74319. static ClearCache(): void;
  74320. /**
  74321. * Serialize a scene into a JSON compatible object
  74322. * @param scene defines the scene to serialize
  74323. * @returns a JSON compatible object
  74324. */
  74325. static Serialize(scene: Scene): any;
  74326. /**
  74327. * Serialize a mesh into a JSON compatible object
  74328. * @param toSerialize defines the mesh to serialize
  74329. * @param withParents defines if parents must be serialized as well
  74330. * @param withChildren defines if children must be serialized as well
  74331. * @returns a JSON compatible object
  74332. */
  74333. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74334. }
  74335. }
  74336. declare module BABYLON {
  74337. /**
  74338. * Class used to host texture specific utilities
  74339. */
  74340. export class TextureTools {
  74341. /**
  74342. * Uses the GPU to create a copy texture rescaled at a given size
  74343. * @param texture Texture to copy from
  74344. * @param width defines the desired width
  74345. * @param height defines the desired height
  74346. * @param useBilinearMode defines if bilinear mode has to be used
  74347. * @return the generated texture
  74348. */
  74349. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74350. }
  74351. }
  74352. declare module BABYLON {
  74353. /**
  74354. * This represents the different options available for the video capture.
  74355. */
  74356. export interface VideoRecorderOptions {
  74357. /** Defines the mime type of the video. */
  74358. mimeType: string;
  74359. /** Defines the FPS the video should be recorded at. */
  74360. fps: number;
  74361. /** Defines the chunk size for the recording data. */
  74362. recordChunckSize: number;
  74363. /** The audio tracks to attach to the recording. */
  74364. audioTracks?: MediaStreamTrack[];
  74365. }
  74366. /**
  74367. * This can help with recording videos from BabylonJS.
  74368. * This is based on the available WebRTC functionalities of the browser.
  74369. *
  74370. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74371. */
  74372. export class VideoRecorder {
  74373. private static readonly _defaultOptions;
  74374. /**
  74375. * Returns whether or not the VideoRecorder is available in your browser.
  74376. * @param engine Defines the Babylon Engine.
  74377. * @returns true if supported otherwise false.
  74378. */
  74379. static IsSupported(engine: Engine): boolean;
  74380. private readonly _options;
  74381. private _canvas;
  74382. private _mediaRecorder;
  74383. private _recordedChunks;
  74384. private _fileName;
  74385. private _resolve;
  74386. private _reject;
  74387. /**
  74388. * True when a recording is already in progress.
  74389. */
  74390. get isRecording(): boolean;
  74391. /**
  74392. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74393. * @param engine Defines the BabylonJS Engine you wish to record.
  74394. * @param options Defines options that can be used to customize the capture.
  74395. */
  74396. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74397. /**
  74398. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74399. */
  74400. stopRecording(): void;
  74401. /**
  74402. * Starts recording the canvas for a max duration specified in parameters.
  74403. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74404. * If null no automatic download will start and you can rely on the promise to get the data back.
  74405. * @param maxDuration Defines the maximum recording time in seconds.
  74406. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74407. * @return A promise callback at the end of the recording with the video data in Blob.
  74408. */
  74409. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74410. /**
  74411. * Releases internal resources used during the recording.
  74412. */
  74413. dispose(): void;
  74414. private _handleDataAvailable;
  74415. private _handleError;
  74416. private _handleStop;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /**
  74421. * Class containing a set of static utilities functions for screenshots
  74422. */
  74423. export class ScreenshotTools {
  74424. /**
  74425. * Captures a screenshot of the current rendering
  74426. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74427. * @param engine defines the rendering engine
  74428. * @param camera defines the source camera
  74429. * @param size This parameter can be set to a single number or to an object with the
  74430. * following (optional) properties: precision, width, height. If a single number is passed,
  74431. * it will be used for both width and height. If an object is passed, the screenshot size
  74432. * will be derived from the parameters. The precision property is a multiplier allowing
  74433. * rendering at a higher or lower resolution
  74434. * @param successCallback defines the callback receives a single parameter which contains the
  74435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74436. * src parameter of an <img> to display it
  74437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74438. * Check your browser for supported MIME types
  74439. */
  74440. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74441. /**
  74442. * Captures a screenshot of the current rendering
  74443. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74444. * @param engine defines the rendering engine
  74445. * @param camera defines the source camera
  74446. * @param size This parameter can be set to a single number or to an object with the
  74447. * following (optional) properties: precision, width, height. If a single number is passed,
  74448. * it will be used for both width and height. If an object is passed, the screenshot size
  74449. * will be derived from the parameters. The precision property is a multiplier allowing
  74450. * rendering at a higher or lower resolution
  74451. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74452. * Check your browser for supported MIME types
  74453. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74454. * to the src parameter of an <img> to display it
  74455. */
  74456. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74457. /**
  74458. * Generates an image screenshot from the specified camera.
  74459. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74460. * @param engine The engine to use for rendering
  74461. * @param camera The camera to use for rendering
  74462. * @param size This parameter can be set to a single number or to an object with the
  74463. * following (optional) properties: precision, width, height. If a single number is passed,
  74464. * it will be used for both width and height. If an object is passed, the screenshot size
  74465. * will be derived from the parameters. The precision property is a multiplier allowing
  74466. * rendering at a higher or lower resolution
  74467. * @param successCallback The callback receives a single parameter which contains the
  74468. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74469. * src parameter of an <img> to display it
  74470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74471. * Check your browser for supported MIME types
  74472. * @param samples Texture samples (default: 1)
  74473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74474. * @param fileName A name for for the downloaded file.
  74475. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74476. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74477. */
  74478. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  74479. /**
  74480. * Generates an image screenshot from the specified camera.
  74481. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74482. * @param engine The engine to use for rendering
  74483. * @param camera The camera to use for rendering
  74484. * @param size This parameter can be set to a single number or to an object with the
  74485. * following (optional) properties: precision, width, height. If a single number is passed,
  74486. * it will be used for both width and height. If an object is passed, the screenshot size
  74487. * will be derived from the parameters. The precision property is a multiplier allowing
  74488. * rendering at a higher or lower resolution
  74489. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74490. * Check your browser for supported MIME types
  74491. * @param samples Texture samples (default: 1)
  74492. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74493. * @param fileName A name for for the downloaded file.
  74494. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74495. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74496. * to the src parameter of an <img> to display it
  74497. */
  74498. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74499. /**
  74500. * Gets height and width for screenshot size
  74501. * @private
  74502. */
  74503. private static _getScreenshotSize;
  74504. }
  74505. }
  74506. declare module BABYLON {
  74507. /**
  74508. * Interface for a data buffer
  74509. */
  74510. export interface IDataBuffer {
  74511. /**
  74512. * Reads bytes from the data buffer.
  74513. * @param byteOffset The byte offset to read
  74514. * @param byteLength The byte length to read
  74515. * @returns A promise that resolves when the bytes are read
  74516. */
  74517. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74518. /**
  74519. * The byte length of the buffer.
  74520. */
  74521. readonly byteLength: number;
  74522. }
  74523. /**
  74524. * Utility class for reading from a data buffer
  74525. */
  74526. export class DataReader {
  74527. /**
  74528. * The data buffer associated with this data reader.
  74529. */
  74530. readonly buffer: IDataBuffer;
  74531. /**
  74532. * The current byte offset from the beginning of the data buffer.
  74533. */
  74534. byteOffset: number;
  74535. private _dataView;
  74536. private _dataByteOffset;
  74537. /**
  74538. * Constructor
  74539. * @param buffer The buffer to read
  74540. */
  74541. constructor(buffer: IDataBuffer);
  74542. /**
  74543. * Loads the given byte length.
  74544. * @param byteLength The byte length to load
  74545. * @returns A promise that resolves when the load is complete
  74546. */
  74547. loadAsync(byteLength: number): Promise<void>;
  74548. /**
  74549. * Read a unsigned 32-bit integer from the currently loaded data range.
  74550. * @returns The 32-bit integer read
  74551. */
  74552. readUint32(): number;
  74553. /**
  74554. * Read a byte array from the currently loaded data range.
  74555. * @param byteLength The byte length to read
  74556. * @returns The byte array read
  74557. */
  74558. readUint8Array(byteLength: number): Uint8Array;
  74559. /**
  74560. * Read a string from the currently loaded data range.
  74561. * @param byteLength The byte length to read
  74562. * @returns The string read
  74563. */
  74564. readString(byteLength: number): string;
  74565. /**
  74566. * Skips the given byte length the currently loaded data range.
  74567. * @param byteLength The byte length to skip
  74568. */
  74569. skipBytes(byteLength: number): void;
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * Class for storing data to local storage if available or in-memory storage otherwise
  74575. */
  74576. export class DataStorage {
  74577. private static _Storage;
  74578. private static _GetStorage;
  74579. /**
  74580. * Reads a string from the data storage
  74581. * @param key The key to read
  74582. * @param defaultValue The value if the key doesn't exist
  74583. * @returns The string value
  74584. */
  74585. static ReadString(key: string, defaultValue: string): string;
  74586. /**
  74587. * Writes a string to the data storage
  74588. * @param key The key to write
  74589. * @param value The value to write
  74590. */
  74591. static WriteString(key: string, value: string): void;
  74592. /**
  74593. * Reads a boolean from the data storage
  74594. * @param key The key to read
  74595. * @param defaultValue The value if the key doesn't exist
  74596. * @returns The boolean value
  74597. */
  74598. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74599. /**
  74600. * Writes a boolean to the data storage
  74601. * @param key The key to write
  74602. * @param value The value to write
  74603. */
  74604. static WriteBoolean(key: string, value: boolean): void;
  74605. /**
  74606. * Reads a number from the data storage
  74607. * @param key The key to read
  74608. * @param defaultValue The value if the key doesn't exist
  74609. * @returns The number value
  74610. */
  74611. static ReadNumber(key: string, defaultValue: number): number;
  74612. /**
  74613. * Writes a number to the data storage
  74614. * @param key The key to write
  74615. * @param value The value to write
  74616. */
  74617. static WriteNumber(key: string, value: number): void;
  74618. }
  74619. }
  74620. declare module BABYLON {
  74621. /**
  74622. * Class used to record delta files between 2 scene states
  74623. */
  74624. export class SceneRecorder {
  74625. private _trackedScene;
  74626. private _savedJSON;
  74627. /**
  74628. * Track a given scene. This means the current scene state will be considered the original state
  74629. * @param scene defines the scene to track
  74630. */
  74631. track(scene: Scene): void;
  74632. /**
  74633. * Get the delta between current state and original state
  74634. * @returns a string containing the delta
  74635. */
  74636. getDelta(): any;
  74637. private _compareArray;
  74638. private _compareObjects;
  74639. private _compareCollections;
  74640. private static GetShadowGeneratorById;
  74641. /**
  74642. * Apply a given delta to a given scene
  74643. * @param deltaJSON defines the JSON containing the delta
  74644. * @param scene defines the scene to apply the delta to
  74645. */
  74646. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74647. private static _ApplyPropertiesToEntity;
  74648. private static _ApplyDeltaForEntity;
  74649. }
  74650. }
  74651. declare module BABYLON {
  74652. /**
  74653. * A 3D trajectory consisting of an order list of vectors describing a
  74654. * path of motion through 3D space.
  74655. */
  74656. export class Trajectory {
  74657. private _points;
  74658. private readonly _segmentLength;
  74659. /**
  74660. * Serialize to JSON.
  74661. * @returns serialized JSON string
  74662. */
  74663. serialize(): string;
  74664. /**
  74665. * Deserialize from JSON.
  74666. * @param json serialized JSON string
  74667. * @returns deserialized Trajectory
  74668. */
  74669. static Deserialize(json: string): Trajectory;
  74670. /**
  74671. * Create a new empty Trajectory.
  74672. * @param segmentLength radius of discretization for Trajectory points
  74673. */
  74674. constructor(segmentLength?: number);
  74675. /**
  74676. * Get the length of the Trajectory.
  74677. * @returns length of the Trajectory
  74678. */
  74679. getLength(): number;
  74680. /**
  74681. * Append a new point to the Trajectory.
  74682. * NOTE: This implementation has many allocations.
  74683. * @param point point to append to the Trajectory
  74684. */
  74685. add(point: DeepImmutable<Vector3>): void;
  74686. /**
  74687. * Create a new Trajectory with a segment length chosen to make it
  74688. * probable that the new Trajectory will have a specified number of
  74689. * segments. This operation is imprecise.
  74690. * @param targetResolution number of segments desired
  74691. * @returns new Trajectory with approximately the requested number of segments
  74692. */
  74693. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74694. /**
  74695. * Convert Trajectory segments into tokenized representation. This
  74696. * representation is an array of numbers where each nth number is the
  74697. * index of the token which is most similar to the nth segment of the
  74698. * Trajectory.
  74699. * @param tokens list of vectors which serve as discrete tokens
  74700. * @returns list of indices of most similar token per segment
  74701. */
  74702. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74703. private static _forwardDir;
  74704. private static _inverseFromVec;
  74705. private static _upDir;
  74706. private static _fromToVec;
  74707. private static _lookMatrix;
  74708. /**
  74709. * Transform the rotation (i.e., direction) of a segment to isolate
  74710. * the relative transformation represented by the segment. This operation
  74711. * may or may not succeed due to singularities in the equations that define
  74712. * motion relativity in this context.
  74713. * @param priorVec the origin of the prior segment
  74714. * @param fromVec the origin of the current segment
  74715. * @param toVec the destination of the current segment
  74716. * @param result reference to output variable
  74717. * @returns whether or not transformation was successful
  74718. */
  74719. private static _transformSegmentDirToRef;
  74720. private static _bestMatch;
  74721. private static _score;
  74722. private static _bestScore;
  74723. /**
  74724. * Determine which token vector is most similar to the
  74725. * segment vector.
  74726. * @param segment segment vector
  74727. * @param tokens token vector list
  74728. * @returns index of the most similar token to the segment
  74729. */
  74730. private static _tokenizeSegment;
  74731. }
  74732. /**
  74733. * Class representing a set of known, named trajectories to which Trajectories can be
  74734. * added and using which Trajectories can be recognized.
  74735. */
  74736. export class TrajectoryClassifier {
  74737. private _maximumAllowableMatchCost;
  74738. private _vector3Alphabet;
  74739. private _levenshteinAlphabet;
  74740. private _nameToDescribedTrajectory;
  74741. /**
  74742. * Serialize to JSON.
  74743. * @returns JSON serialization
  74744. */
  74745. serialize(): string;
  74746. /**
  74747. * Deserialize from JSON.
  74748. * @param json JSON serialization
  74749. * @returns deserialized TrajectorySet
  74750. */
  74751. static Deserialize(json: string): TrajectoryClassifier;
  74752. /**
  74753. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74754. * VERY naive, need to be generating these things from known
  74755. * sets. Better version later, probably eliminating this one.
  74756. * @returns auto-generated TrajectorySet
  74757. */
  74758. static Generate(): TrajectoryClassifier;
  74759. private constructor();
  74760. /**
  74761. * Add a new Trajectory to the set with a given name.
  74762. * @param trajectory new Trajectory to be added
  74763. * @param classification name to which to add the Trajectory
  74764. */
  74765. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74766. /**
  74767. * Remove a known named trajectory and all Trajectories associated with it.
  74768. * @param classification name to remove
  74769. * @returns whether anything was removed
  74770. */
  74771. deleteClassification(classification: string): boolean;
  74772. /**
  74773. * Attempt to recognize a Trajectory from among all the classifications
  74774. * already known to the classifier.
  74775. * @param trajectory Trajectory to be recognized
  74776. * @returns classification of Trajectory if recognized, null otherwise
  74777. */
  74778. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74779. }
  74780. }
  74781. declare module BABYLON {
  74782. /**
  74783. * An interface for all Hit test features
  74784. */
  74785. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74786. /**
  74787. * Triggered when new babylon (transformed) hit test results are available
  74788. */
  74789. onHitTestResultObservable: Observable<T[]>;
  74790. }
  74791. /**
  74792. * Options used for hit testing
  74793. */
  74794. export interface IWebXRLegacyHitTestOptions {
  74795. /**
  74796. * Only test when user interacted with the scene. Default - hit test every frame
  74797. */
  74798. testOnPointerDownOnly?: boolean;
  74799. /**
  74800. * The node to use to transform the local results to world coordinates
  74801. */
  74802. worldParentNode?: TransformNode;
  74803. }
  74804. /**
  74805. * Interface defining the babylon result of raycasting/hit-test
  74806. */
  74807. export interface IWebXRLegacyHitResult {
  74808. /**
  74809. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74810. */
  74811. transformationMatrix: Matrix;
  74812. /**
  74813. * The native hit test result
  74814. */
  74815. xrHitResult: XRHitResult | XRHitTestResult;
  74816. }
  74817. /**
  74818. * The currently-working hit-test module.
  74819. * Hit test (or Ray-casting) is used to interact with the real world.
  74820. * For further information read here - https://github.com/immersive-web/hit-test
  74821. */
  74822. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74823. /**
  74824. * options to use when constructing this feature
  74825. */
  74826. readonly options: IWebXRLegacyHitTestOptions;
  74827. private _direction;
  74828. private _mat;
  74829. private _onSelectEnabled;
  74830. private _origin;
  74831. /**
  74832. * The module's name
  74833. */
  74834. static readonly Name: string;
  74835. /**
  74836. * The (Babylon) version of this module.
  74837. * This is an integer representing the implementation version.
  74838. * This number does not correspond to the WebXR specs version
  74839. */
  74840. static readonly Version: number;
  74841. /**
  74842. * Populated with the last native XR Hit Results
  74843. */
  74844. lastNativeXRHitResults: XRHitResult[];
  74845. /**
  74846. * Triggered when new babylon (transformed) hit test results are available
  74847. */
  74848. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74849. /**
  74850. * Creates a new instance of the (legacy version) hit test feature
  74851. * @param _xrSessionManager an instance of WebXRSessionManager
  74852. * @param options options to use when constructing this feature
  74853. */
  74854. constructor(_xrSessionManager: WebXRSessionManager,
  74855. /**
  74856. * options to use when constructing this feature
  74857. */
  74858. options?: IWebXRLegacyHitTestOptions);
  74859. /**
  74860. * execute a hit test with an XR Ray
  74861. *
  74862. * @param xrSession a native xrSession that will execute this hit test
  74863. * @param xrRay the ray (position and direction) to use for ray-casting
  74864. * @param referenceSpace native XR reference space to use for the hit-test
  74865. * @param filter filter function that will filter the results
  74866. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74867. */
  74868. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74869. /**
  74870. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74871. * @param event the (select) event to use to select with
  74872. * @param referenceSpace the reference space to use for this hit test
  74873. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74874. */
  74875. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74876. /**
  74877. * attach this feature
  74878. * Will usually be called by the features manager
  74879. *
  74880. * @returns true if successful.
  74881. */
  74882. attach(): boolean;
  74883. /**
  74884. * detach this feature.
  74885. * Will usually be called by the features manager
  74886. *
  74887. * @returns true if successful.
  74888. */
  74889. detach(): boolean;
  74890. /**
  74891. * Dispose this feature and all of the resources attached
  74892. */
  74893. dispose(): void;
  74894. protected _onXRFrame(frame: XRFrame): void;
  74895. private _onHitTestResults;
  74896. private _onSelect;
  74897. }
  74898. }
  74899. declare module BABYLON {
  74900. /**
  74901. * Options used for hit testing (version 2)
  74902. */
  74903. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74904. /**
  74905. * Do not create a permanent hit test. Will usually be used when only
  74906. * transient inputs are needed.
  74907. */
  74908. disablePermanentHitTest?: boolean;
  74909. /**
  74910. * Enable transient (for example touch-based) hit test inspections
  74911. */
  74912. enableTransientHitTest?: boolean;
  74913. /**
  74914. * Offset ray for the permanent hit test
  74915. */
  74916. offsetRay?: Vector3;
  74917. /**
  74918. * Offset ray for the transient hit test
  74919. */
  74920. transientOffsetRay?: Vector3;
  74921. /**
  74922. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74923. */
  74924. useReferenceSpace?: boolean;
  74925. /**
  74926. * Override the default entity type(s) of the hit-test result
  74927. */
  74928. entityTypes?: XRHitTestTrackableType[];
  74929. }
  74930. /**
  74931. * Interface defining the babylon result of hit-test
  74932. */
  74933. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74934. /**
  74935. * The input source that generated this hit test (if transient)
  74936. */
  74937. inputSource?: XRInputSource;
  74938. /**
  74939. * Is this a transient hit test
  74940. */
  74941. isTransient?: boolean;
  74942. /**
  74943. * Position of the hit test result
  74944. */
  74945. position: Vector3;
  74946. /**
  74947. * Rotation of the hit test result
  74948. */
  74949. rotationQuaternion: Quaternion;
  74950. /**
  74951. * The native hit test result
  74952. */
  74953. xrHitResult: XRHitTestResult;
  74954. }
  74955. /**
  74956. * The currently-working hit-test module.
  74957. * Hit test (or Ray-casting) is used to interact with the real world.
  74958. * For further information read here - https://github.com/immersive-web/hit-test
  74959. *
  74960. * Tested on chrome (mobile) 80.
  74961. */
  74962. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74963. /**
  74964. * options to use when constructing this feature
  74965. */
  74966. readonly options: IWebXRHitTestOptions;
  74967. private _tmpMat;
  74968. private _tmpPos;
  74969. private _tmpQuat;
  74970. private _transientXrHitTestSource;
  74971. private _xrHitTestSource;
  74972. private initHitTestSource;
  74973. /**
  74974. * The module's name
  74975. */
  74976. static readonly Name: string;
  74977. /**
  74978. * The (Babylon) version of this module.
  74979. * This is an integer representing the implementation version.
  74980. * This number does not correspond to the WebXR specs version
  74981. */
  74982. static readonly Version: number;
  74983. /**
  74984. * When set to true, each hit test will have its own position/rotation objects
  74985. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74986. * the developers will clone them or copy them as they see fit.
  74987. */
  74988. autoCloneTransformation: boolean;
  74989. /**
  74990. * Triggered when new babylon (transformed) hit test results are available
  74991. * Note - this will be called when results come back from the device. It can be an empty array!!
  74992. */
  74993. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74994. /**
  74995. * Use this to temporarily pause hit test checks.
  74996. */
  74997. paused: boolean;
  74998. /**
  74999. * Creates a new instance of the hit test feature
  75000. * @param _xrSessionManager an instance of WebXRSessionManager
  75001. * @param options options to use when constructing this feature
  75002. */
  75003. constructor(_xrSessionManager: WebXRSessionManager,
  75004. /**
  75005. * options to use when constructing this feature
  75006. */
  75007. options?: IWebXRHitTestOptions);
  75008. /**
  75009. * attach this feature
  75010. * Will usually be called by the features manager
  75011. *
  75012. * @returns true if successful.
  75013. */
  75014. attach(): boolean;
  75015. /**
  75016. * detach this feature.
  75017. * Will usually be called by the features manager
  75018. *
  75019. * @returns true if successful.
  75020. */
  75021. detach(): boolean;
  75022. /**
  75023. * Dispose this feature and all of the resources attached
  75024. */
  75025. dispose(): void;
  75026. protected _onXRFrame(frame: XRFrame): void;
  75027. private _processWebXRHitTestResult;
  75028. }
  75029. }
  75030. declare module BABYLON {
  75031. /**
  75032. * Configuration options of the anchor system
  75033. */
  75034. export interface IWebXRAnchorSystemOptions {
  75035. /**
  75036. * a node that will be used to convert local to world coordinates
  75037. */
  75038. worldParentNode?: TransformNode;
  75039. /**
  75040. * If set to true a reference of the created anchors will be kept until the next session starts
  75041. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75042. */
  75043. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75044. }
  75045. /**
  75046. * A babylon container for an XR Anchor
  75047. */
  75048. export interface IWebXRAnchor {
  75049. /**
  75050. * A babylon-assigned ID for this anchor
  75051. */
  75052. id: number;
  75053. /**
  75054. * Transformation matrix to apply to an object attached to this anchor
  75055. */
  75056. transformationMatrix: Matrix;
  75057. /**
  75058. * The native anchor object
  75059. */
  75060. xrAnchor: XRAnchor;
  75061. /**
  75062. * if defined, this object will be constantly updated by the anchor's position and rotation
  75063. */
  75064. attachedNode?: TransformNode;
  75065. }
  75066. /**
  75067. * An implementation of the anchor system for WebXR.
  75068. * For further information see https://github.com/immersive-web/anchors/
  75069. */
  75070. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75071. private _options;
  75072. private _lastFrameDetected;
  75073. private _trackedAnchors;
  75074. private _referenceSpaceForFrameAnchors;
  75075. private _futureAnchors;
  75076. /**
  75077. * The module's name
  75078. */
  75079. static readonly Name: string;
  75080. /**
  75081. * The (Babylon) version of this module.
  75082. * This is an integer representing the implementation version.
  75083. * This number does not correspond to the WebXR specs version
  75084. */
  75085. static readonly Version: number;
  75086. /**
  75087. * Observers registered here will be executed when a new anchor was added to the session
  75088. */
  75089. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75090. /**
  75091. * Observers registered here will be executed when an anchor was removed from the session
  75092. */
  75093. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75094. /**
  75095. * Observers registered here will be executed when an existing anchor updates
  75096. * This can execute N times every frame
  75097. */
  75098. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75099. /**
  75100. * Set the reference space to use for anchor creation, when not using a hit test.
  75101. * Will default to the session's reference space if not defined
  75102. */
  75103. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75104. /**
  75105. * constructs a new anchor system
  75106. * @param _xrSessionManager an instance of WebXRSessionManager
  75107. * @param _options configuration object for this feature
  75108. */
  75109. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75110. private _tmpVector;
  75111. private _tmpQuaternion;
  75112. private _populateTmpTransformation;
  75113. /**
  75114. * Create a new anchor point using a hit test result at a specific point in the scene
  75115. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75116. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75117. *
  75118. * @param hitTestResult The hit test result to use for this anchor creation
  75119. * @param position an optional position offset for this anchor
  75120. * @param rotationQuaternion an optional rotation offset for this anchor
  75121. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75122. */
  75123. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75124. /**
  75125. * Add a new anchor at a specific position and rotation
  75126. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75127. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75128. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75129. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75130. *
  75131. * @param position the position in which to add an anchor
  75132. * @param rotationQuaternion an optional rotation for the anchor transformation
  75133. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75134. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75135. */
  75136. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75137. /**
  75138. * detach this feature.
  75139. * Will usually be called by the features manager
  75140. *
  75141. * @returns true if successful.
  75142. */
  75143. detach(): boolean;
  75144. /**
  75145. * Dispose this feature and all of the resources attached
  75146. */
  75147. dispose(): void;
  75148. protected _onXRFrame(frame: XRFrame): void;
  75149. /**
  75150. * avoiding using Array.find for global support.
  75151. * @param xrAnchor the plane to find in the array
  75152. */
  75153. private _findIndexInAnchorArray;
  75154. private _updateAnchorWithXRFrame;
  75155. private _createAnchorAtTransformation;
  75156. }
  75157. }
  75158. declare module BABYLON {
  75159. /**
  75160. * Options used in the plane detector module
  75161. */
  75162. export interface IWebXRPlaneDetectorOptions {
  75163. /**
  75164. * The node to use to transform the local results to world coordinates
  75165. */
  75166. worldParentNode?: TransformNode;
  75167. /**
  75168. * If set to true a reference of the created planes will be kept until the next session starts
  75169. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75170. */
  75171. doNotRemovePlanesOnSessionEnded?: boolean;
  75172. }
  75173. /**
  75174. * A babylon interface for a WebXR plane.
  75175. * A Plane is actually a polygon, built from N points in space
  75176. *
  75177. * Supported in chrome 79, not supported in canary 81 ATM
  75178. */
  75179. export interface IWebXRPlane {
  75180. /**
  75181. * a babylon-assigned ID for this polygon
  75182. */
  75183. id: number;
  75184. /**
  75185. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75186. */
  75187. polygonDefinition: Array<Vector3>;
  75188. /**
  75189. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75190. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75191. */
  75192. transformationMatrix: Matrix;
  75193. /**
  75194. * the native xr-plane object
  75195. */
  75196. xrPlane: XRPlane;
  75197. }
  75198. /**
  75199. * The plane detector is used to detect planes in the real world when in AR
  75200. * For more information see https://github.com/immersive-web/real-world-geometry/
  75201. */
  75202. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75203. private _options;
  75204. private _detectedPlanes;
  75205. private _enabled;
  75206. private _lastFrameDetected;
  75207. /**
  75208. * The module's name
  75209. */
  75210. static readonly Name: string;
  75211. /**
  75212. * The (Babylon) version of this module.
  75213. * This is an integer representing the implementation version.
  75214. * This number does not correspond to the WebXR specs version
  75215. */
  75216. static readonly Version: number;
  75217. /**
  75218. * Observers registered here will be executed when a new plane was added to the session
  75219. */
  75220. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75221. /**
  75222. * Observers registered here will be executed when a plane is no longer detected in the session
  75223. */
  75224. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75225. /**
  75226. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75227. * This can execute N times every frame
  75228. */
  75229. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75230. /**
  75231. * construct a new Plane Detector
  75232. * @param _xrSessionManager an instance of xr Session manager
  75233. * @param _options configuration to use when constructing this feature
  75234. */
  75235. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75236. /**
  75237. * detach this feature.
  75238. * Will usually be called by the features manager
  75239. *
  75240. * @returns true if successful.
  75241. */
  75242. detach(): boolean;
  75243. /**
  75244. * Dispose this feature and all of the resources attached
  75245. */
  75246. dispose(): void;
  75247. protected _onXRFrame(frame: XRFrame): void;
  75248. private _init;
  75249. private _updatePlaneWithXRPlane;
  75250. /**
  75251. * avoiding using Array.find for global support.
  75252. * @param xrPlane the plane to find in the array
  75253. */
  75254. private findIndexInPlaneArray;
  75255. }
  75256. }
  75257. declare module BABYLON {
  75258. /**
  75259. * Options interface for the background remover plugin
  75260. */
  75261. export interface IWebXRBackgroundRemoverOptions {
  75262. /**
  75263. * Further background meshes to disable when entering AR
  75264. */
  75265. backgroundMeshes?: AbstractMesh[];
  75266. /**
  75267. * flags to configure the removal of the environment helper.
  75268. * If not set, the entire background will be removed. If set, flags should be set as well.
  75269. */
  75270. environmentHelperRemovalFlags?: {
  75271. /**
  75272. * Should the skybox be removed (default false)
  75273. */
  75274. skyBox?: boolean;
  75275. /**
  75276. * Should the ground be removed (default false)
  75277. */
  75278. ground?: boolean;
  75279. };
  75280. /**
  75281. * don't disable the environment helper
  75282. */
  75283. ignoreEnvironmentHelper?: boolean;
  75284. }
  75285. /**
  75286. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75287. */
  75288. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75289. /**
  75290. * read-only options to be used in this module
  75291. */
  75292. readonly options: IWebXRBackgroundRemoverOptions;
  75293. /**
  75294. * The module's name
  75295. */
  75296. static readonly Name: string;
  75297. /**
  75298. * The (Babylon) version of this module.
  75299. * This is an integer representing the implementation version.
  75300. * This number does not correspond to the WebXR specs version
  75301. */
  75302. static readonly Version: number;
  75303. /**
  75304. * registered observers will be triggered when the background state changes
  75305. */
  75306. onBackgroundStateChangedObservable: Observable<boolean>;
  75307. /**
  75308. * constructs a new background remover module
  75309. * @param _xrSessionManager the session manager for this module
  75310. * @param options read-only options to be used in this module
  75311. */
  75312. constructor(_xrSessionManager: WebXRSessionManager,
  75313. /**
  75314. * read-only options to be used in this module
  75315. */
  75316. options?: IWebXRBackgroundRemoverOptions);
  75317. /**
  75318. * attach this feature
  75319. * Will usually be called by the features manager
  75320. *
  75321. * @returns true if successful.
  75322. */
  75323. attach(): boolean;
  75324. /**
  75325. * detach this feature.
  75326. * Will usually be called by the features manager
  75327. *
  75328. * @returns true if successful.
  75329. */
  75330. detach(): boolean;
  75331. /**
  75332. * Dispose this feature and all of the resources attached
  75333. */
  75334. dispose(): void;
  75335. protected _onXRFrame(_xrFrame: XRFrame): void;
  75336. private _setBackgroundState;
  75337. }
  75338. }
  75339. declare module BABYLON {
  75340. /**
  75341. * Options for the controller physics feature
  75342. */
  75343. export class IWebXRControllerPhysicsOptions {
  75344. /**
  75345. * Should the headset get its own impostor
  75346. */
  75347. enableHeadsetImpostor?: boolean;
  75348. /**
  75349. * Optional parameters for the headset impostor
  75350. */
  75351. headsetImpostorParams?: {
  75352. /**
  75353. * The type of impostor to create. Default is sphere
  75354. */
  75355. impostorType: number;
  75356. /**
  75357. * the size of the impostor. Defaults to 10cm
  75358. */
  75359. impostorSize?: number | {
  75360. width: number;
  75361. height: number;
  75362. depth: number;
  75363. };
  75364. /**
  75365. * Friction definitions
  75366. */
  75367. friction?: number;
  75368. /**
  75369. * Restitution
  75370. */
  75371. restitution?: number;
  75372. };
  75373. /**
  75374. * The physics properties of the future impostors
  75375. */
  75376. physicsProperties?: {
  75377. /**
  75378. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75379. * Note that this requires a physics engine that supports mesh impostors!
  75380. */
  75381. useControllerMesh?: boolean;
  75382. /**
  75383. * The type of impostor to create. Default is sphere
  75384. */
  75385. impostorType?: number;
  75386. /**
  75387. * the size of the impostor. Defaults to 10cm
  75388. */
  75389. impostorSize?: number | {
  75390. width: number;
  75391. height: number;
  75392. depth: number;
  75393. };
  75394. /**
  75395. * Friction definitions
  75396. */
  75397. friction?: number;
  75398. /**
  75399. * Restitution
  75400. */
  75401. restitution?: number;
  75402. };
  75403. /**
  75404. * the xr input to use with this pointer selection
  75405. */
  75406. xrInput: WebXRInput;
  75407. }
  75408. /**
  75409. * Add physics impostor to your webxr controllers,
  75410. * including naive calculation of their linear and angular velocity
  75411. */
  75412. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75413. private readonly _options;
  75414. private _attachController;
  75415. private _controllers;
  75416. private _debugMode;
  75417. private _delta;
  75418. private _headsetImpostor?;
  75419. private _headsetMesh?;
  75420. private _lastTimestamp;
  75421. private _tmpQuaternion;
  75422. private _tmpVector;
  75423. /**
  75424. * The module's name
  75425. */
  75426. static readonly Name: string;
  75427. /**
  75428. * The (Babylon) version of this module.
  75429. * This is an integer representing the implementation version.
  75430. * This number does not correspond to the webxr specs version
  75431. */
  75432. static readonly Version: number;
  75433. /**
  75434. * Construct a new Controller Physics Feature
  75435. * @param _xrSessionManager the corresponding xr session manager
  75436. * @param _options options to create this feature with
  75437. */
  75438. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75439. /**
  75440. * @hidden
  75441. * enable debugging - will show console outputs and the impostor mesh
  75442. */
  75443. _enablePhysicsDebug(): void;
  75444. /**
  75445. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75446. * @param xrController the controller to add
  75447. */
  75448. addController(xrController: WebXRInputSource): void;
  75449. /**
  75450. * attach this feature
  75451. * Will usually be called by the features manager
  75452. *
  75453. * @returns true if successful.
  75454. */
  75455. attach(): boolean;
  75456. /**
  75457. * detach this feature.
  75458. * Will usually be called by the features manager
  75459. *
  75460. * @returns true if successful.
  75461. */
  75462. detach(): boolean;
  75463. /**
  75464. * Get the headset impostor, if enabled
  75465. * @returns the impostor
  75466. */
  75467. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75468. /**
  75469. * Get the physics impostor of a specific controller.
  75470. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75471. * @param controller the controller or the controller id of which to get the impostor
  75472. * @returns the impostor or null
  75473. */
  75474. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75475. /**
  75476. * Update the physics properties provided in the constructor
  75477. * @param newProperties the new properties object
  75478. */
  75479. setPhysicsProperties(newProperties: {
  75480. impostorType?: number;
  75481. impostorSize?: number | {
  75482. width: number;
  75483. height: number;
  75484. depth: number;
  75485. };
  75486. friction?: number;
  75487. restitution?: number;
  75488. }): void;
  75489. protected _onXRFrame(_xrFrame: any): void;
  75490. private _detachController;
  75491. }
  75492. }
  75493. declare module BABYLON {
  75494. /**
  75495. * A babylon interface for a "WebXR" feature point.
  75496. * Represents the position and confidence value of a given feature point.
  75497. */
  75498. export interface IWebXRFeaturePoint {
  75499. /**
  75500. * Represents the position of the feature point in world space.
  75501. */
  75502. position: Vector3;
  75503. /**
  75504. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75505. */
  75506. confidenceValue: number;
  75507. }
  75508. /**
  75509. * The feature point system is used to detect feature points from real world geometry.
  75510. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75511. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75512. */
  75513. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75514. private _enabled;
  75515. private _featurePointCloud;
  75516. /**
  75517. * The module's name
  75518. */
  75519. static readonly Name: string;
  75520. /**
  75521. * The (Babylon) version of this module.
  75522. * This is an integer representing the implementation version.
  75523. * This number does not correspond to the WebXR specs version
  75524. */
  75525. static readonly Version: number;
  75526. /**
  75527. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75528. * Will notify the observers about which feature points have been added.
  75529. */
  75530. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75531. /**
  75532. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75533. * Will notify the observers about which feature points have been updated.
  75534. */
  75535. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75536. /**
  75537. * The current feature point cloud maintained across frames.
  75538. */
  75539. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75540. /**
  75541. * construct the feature point system
  75542. * @param _xrSessionManager an instance of xr Session manager
  75543. */
  75544. constructor(_xrSessionManager: WebXRSessionManager);
  75545. /**
  75546. * Detach this feature.
  75547. * Will usually be called by the features manager
  75548. *
  75549. * @returns true if successful.
  75550. */
  75551. detach(): boolean;
  75552. /**
  75553. * Dispose this feature and all of the resources attached
  75554. */
  75555. dispose(): void;
  75556. /**
  75557. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75558. */
  75559. protected _onXRFrame(frame: XRFrame): void;
  75560. /**
  75561. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75562. */
  75563. private _init;
  75564. }
  75565. }
  75566. declare module BABYLON {
  75567. /**
  75568. * Configuration interface for the hand tracking feature
  75569. */
  75570. export interface IWebXRHandTrackingOptions {
  75571. /**
  75572. * The xrInput that will be used as source for new hands
  75573. */
  75574. xrInput: WebXRInput;
  75575. /**
  75576. * Configuration object for the joint meshes
  75577. */
  75578. jointMeshes?: {
  75579. /**
  75580. * Should the meshes created be invisible (defaults to false)
  75581. */
  75582. invisible?: boolean;
  75583. /**
  75584. * A source mesh to be used to create instances. Defaults to a sphere.
  75585. * This mesh will be the source for all other (25) meshes.
  75586. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75587. */
  75588. sourceMesh?: Mesh;
  75589. /**
  75590. * Should the source mesh stay visible. Defaults to false
  75591. */
  75592. keepOriginalVisible?: boolean;
  75593. /**
  75594. * Scale factor for all instances (defaults to 2)
  75595. */
  75596. scaleFactor?: number;
  75597. /**
  75598. * Should each instance have its own physics impostor
  75599. */
  75600. enablePhysics?: boolean;
  75601. /**
  75602. * If enabled, override default physics properties
  75603. */
  75604. physicsProps?: {
  75605. friction?: number;
  75606. restitution?: number;
  75607. impostorType?: number;
  75608. };
  75609. /**
  75610. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75611. */
  75612. handMesh?: AbstractMesh;
  75613. };
  75614. }
  75615. /**
  75616. * Parts of the hands divided to writs and finger names
  75617. */
  75618. export const enum HandPart {
  75619. /**
  75620. * HandPart - Wrist
  75621. */
  75622. WRIST = "wrist",
  75623. /**
  75624. * HandPart - The THumb
  75625. */
  75626. THUMB = "thumb",
  75627. /**
  75628. * HandPart - Index finger
  75629. */
  75630. INDEX = "index",
  75631. /**
  75632. * HandPart - Middle finger
  75633. */
  75634. MIDDLE = "middle",
  75635. /**
  75636. * HandPart - Ring finger
  75637. */
  75638. RING = "ring",
  75639. /**
  75640. * HandPart - Little finger
  75641. */
  75642. LITTLE = "little"
  75643. }
  75644. /**
  75645. * Representing a single hand (with its corresponding native XRHand object)
  75646. */
  75647. export class WebXRHand implements IDisposable {
  75648. /** the controller to which the hand correlates */
  75649. readonly xrController: WebXRInputSource;
  75650. /** the meshes to be used to track the hand joints */
  75651. readonly trackedMeshes: AbstractMesh[];
  75652. /**
  75653. * Hand-parts definition (key is HandPart)
  75654. */
  75655. handPartsDefinition: {
  75656. [key: string]: number[];
  75657. };
  75658. /**
  75659. * Populate the HandPartsDefinition object.
  75660. * This is called as a side effect since certain browsers don't have XRHand defined.
  75661. */
  75662. private generateHandPartsDefinition;
  75663. /**
  75664. * Construct a new hand object
  75665. * @param xrController the controller to which the hand correlates
  75666. * @param trackedMeshes the meshes to be used to track the hand joints
  75667. */
  75668. constructor(
  75669. /** the controller to which the hand correlates */
  75670. xrController: WebXRInputSource,
  75671. /** the meshes to be used to track the hand joints */
  75672. trackedMeshes: AbstractMesh[]);
  75673. /**
  75674. * Update this hand from the latest xr frame
  75675. * @param xrFrame xrFrame to update from
  75676. * @param referenceSpace The current viewer reference space
  75677. * @param scaleFactor optional scale factor for the meshes
  75678. */
  75679. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75680. /**
  75681. * Get meshes of part of the hand
  75682. * @param part the part of hand to get
  75683. * @returns An array of meshes that correlate to the hand part requested
  75684. */
  75685. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75686. /**
  75687. * Dispose this Hand object
  75688. */
  75689. dispose(): void;
  75690. }
  75691. /**
  75692. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75693. */
  75694. export class WebXRHandTracking extends WebXRAbstractFeature {
  75695. /**
  75696. * options to use when constructing this feature
  75697. */
  75698. readonly options: IWebXRHandTrackingOptions;
  75699. private static _idCounter;
  75700. /**
  75701. * The module's name
  75702. */
  75703. static readonly Name: string;
  75704. /**
  75705. * The (Babylon) version of this module.
  75706. * This is an integer representing the implementation version.
  75707. * This number does not correspond to the WebXR specs version
  75708. */
  75709. static readonly Version: number;
  75710. /**
  75711. * This observable will notify registered observers when a new hand object was added and initialized
  75712. */
  75713. onHandAddedObservable: Observable<WebXRHand>;
  75714. /**
  75715. * This observable will notify its observers right before the hand object is disposed
  75716. */
  75717. onHandRemovedObservable: Observable<WebXRHand>;
  75718. private _hands;
  75719. /**
  75720. * Creates a new instance of the hit test feature
  75721. * @param _xrSessionManager an instance of WebXRSessionManager
  75722. * @param options options to use when constructing this feature
  75723. */
  75724. constructor(_xrSessionManager: WebXRSessionManager,
  75725. /**
  75726. * options to use when constructing this feature
  75727. */
  75728. options: IWebXRHandTrackingOptions);
  75729. /**
  75730. * Check if the needed objects are defined.
  75731. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75732. */
  75733. isCompatible(): boolean;
  75734. /**
  75735. * attach this feature
  75736. * Will usually be called by the features manager
  75737. *
  75738. * @returns true if successful.
  75739. */
  75740. attach(): boolean;
  75741. /**
  75742. * detach this feature.
  75743. * Will usually be called by the features manager
  75744. *
  75745. * @returns true if successful.
  75746. */
  75747. detach(): boolean;
  75748. /**
  75749. * Dispose this feature and all of the resources attached
  75750. */
  75751. dispose(): void;
  75752. /**
  75753. * Get the hand object according to the controller id
  75754. * @param controllerId the controller id to which we want to get the hand
  75755. * @returns null if not found or the WebXRHand object if found
  75756. */
  75757. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75758. /**
  75759. * Get a hand object according to the requested handedness
  75760. * @param handedness the handedness to request
  75761. * @returns null if not found or the WebXRHand object if found
  75762. */
  75763. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75764. protected _onXRFrame(_xrFrame: XRFrame): void;
  75765. private _attachHand;
  75766. private _detachHand;
  75767. }
  75768. }
  75769. declare module BABYLON {
  75770. /**
  75771. * The motion controller class for all microsoft mixed reality controllers
  75772. */
  75773. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75774. protected readonly _mapping: {
  75775. defaultButton: {
  75776. valueNodeName: string;
  75777. unpressedNodeName: string;
  75778. pressedNodeName: string;
  75779. };
  75780. defaultAxis: {
  75781. valueNodeName: string;
  75782. minNodeName: string;
  75783. maxNodeName: string;
  75784. };
  75785. buttons: {
  75786. "xr-standard-trigger": {
  75787. rootNodeName: string;
  75788. componentProperty: string;
  75789. states: string[];
  75790. };
  75791. "xr-standard-squeeze": {
  75792. rootNodeName: string;
  75793. componentProperty: string;
  75794. states: string[];
  75795. };
  75796. "xr-standard-touchpad": {
  75797. rootNodeName: string;
  75798. labelAnchorNodeName: string;
  75799. touchPointNodeName: string;
  75800. };
  75801. "xr-standard-thumbstick": {
  75802. rootNodeName: string;
  75803. componentProperty: string;
  75804. states: string[];
  75805. };
  75806. };
  75807. axes: {
  75808. "xr-standard-touchpad": {
  75809. "x-axis": {
  75810. rootNodeName: string;
  75811. };
  75812. "y-axis": {
  75813. rootNodeName: string;
  75814. };
  75815. };
  75816. "xr-standard-thumbstick": {
  75817. "x-axis": {
  75818. rootNodeName: string;
  75819. };
  75820. "y-axis": {
  75821. rootNodeName: string;
  75822. };
  75823. };
  75824. };
  75825. };
  75826. /**
  75827. * The base url used to load the left and right controller models
  75828. */
  75829. static MODEL_BASE_URL: string;
  75830. /**
  75831. * The name of the left controller model file
  75832. */
  75833. static MODEL_LEFT_FILENAME: string;
  75834. /**
  75835. * The name of the right controller model file
  75836. */
  75837. static MODEL_RIGHT_FILENAME: string;
  75838. profileId: string;
  75839. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75840. protected _getFilenameAndPath(): {
  75841. filename: string;
  75842. path: string;
  75843. };
  75844. protected _getModelLoadingConstraints(): boolean;
  75845. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75846. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75847. protected _updateModel(): void;
  75848. }
  75849. }
  75850. declare module BABYLON {
  75851. /**
  75852. * The motion controller class for oculus touch (quest, rift).
  75853. * This class supports legacy mapping as well the standard xr mapping
  75854. */
  75855. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75856. private _forceLegacyControllers;
  75857. private _modelRootNode;
  75858. /**
  75859. * The base url used to load the left and right controller models
  75860. */
  75861. static MODEL_BASE_URL: string;
  75862. /**
  75863. * The name of the left controller model file
  75864. */
  75865. static MODEL_LEFT_FILENAME: string;
  75866. /**
  75867. * The name of the right controller model file
  75868. */
  75869. static MODEL_RIGHT_FILENAME: string;
  75870. /**
  75871. * Base Url for the Quest controller model.
  75872. */
  75873. static QUEST_MODEL_BASE_URL: string;
  75874. profileId: string;
  75875. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75876. protected _getFilenameAndPath(): {
  75877. filename: string;
  75878. path: string;
  75879. };
  75880. protected _getModelLoadingConstraints(): boolean;
  75881. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75882. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75883. protected _updateModel(): void;
  75884. /**
  75885. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75886. * between the touch and touch 2.
  75887. */
  75888. private _isQuest;
  75889. }
  75890. }
  75891. declare module BABYLON {
  75892. /**
  75893. * The motion controller class for the standard HTC-Vive controllers
  75894. */
  75895. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75896. private _modelRootNode;
  75897. /**
  75898. * The base url used to load the left and right controller models
  75899. */
  75900. static MODEL_BASE_URL: string;
  75901. /**
  75902. * File name for the controller model.
  75903. */
  75904. static MODEL_FILENAME: string;
  75905. profileId: string;
  75906. /**
  75907. * Create a new Vive motion controller object
  75908. * @param scene the scene to use to create this controller
  75909. * @param gamepadObject the corresponding gamepad object
  75910. * @param handedness the handedness of the controller
  75911. */
  75912. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75913. protected _getFilenameAndPath(): {
  75914. filename: string;
  75915. path: string;
  75916. };
  75917. protected _getModelLoadingConstraints(): boolean;
  75918. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75919. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75920. protected _updateModel(): void;
  75921. }
  75922. }
  75923. declare module BABYLON {
  75924. /**
  75925. * A cursor which tracks a point on a path
  75926. */
  75927. export class PathCursor {
  75928. private path;
  75929. /**
  75930. * Stores path cursor callbacks for when an onchange event is triggered
  75931. */
  75932. private _onchange;
  75933. /**
  75934. * The value of the path cursor
  75935. */
  75936. value: number;
  75937. /**
  75938. * The animation array of the path cursor
  75939. */
  75940. animations: Animation[];
  75941. /**
  75942. * Initializes the path cursor
  75943. * @param path The path to track
  75944. */
  75945. constructor(path: Path2);
  75946. /**
  75947. * Gets the cursor point on the path
  75948. * @returns A point on the path cursor at the cursor location
  75949. */
  75950. getPoint(): Vector3;
  75951. /**
  75952. * Moves the cursor ahead by the step amount
  75953. * @param step The amount to move the cursor forward
  75954. * @returns This path cursor
  75955. */
  75956. moveAhead(step?: number): PathCursor;
  75957. /**
  75958. * Moves the cursor behind by the step amount
  75959. * @param step The amount to move the cursor back
  75960. * @returns This path cursor
  75961. */
  75962. moveBack(step?: number): PathCursor;
  75963. /**
  75964. * Moves the cursor by the step amount
  75965. * If the step amount is greater than one, an exception is thrown
  75966. * @param step The amount to move the cursor
  75967. * @returns This path cursor
  75968. */
  75969. move(step: number): PathCursor;
  75970. /**
  75971. * Ensures that the value is limited between zero and one
  75972. * @returns This path cursor
  75973. */
  75974. private ensureLimits;
  75975. /**
  75976. * Runs onchange callbacks on change (used by the animation engine)
  75977. * @returns This path cursor
  75978. */
  75979. private raiseOnChange;
  75980. /**
  75981. * Executes a function on change
  75982. * @param f A path cursor onchange callback
  75983. * @returns This path cursor
  75984. */
  75985. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75986. }
  75987. }
  75988. declare module BABYLON {
  75989. /** @hidden */
  75990. export var blurPixelShader: {
  75991. name: string;
  75992. shader: string;
  75993. };
  75994. }
  75995. declare module BABYLON {
  75996. /** @hidden */
  75997. export var pointCloudVertexDeclaration: {
  75998. name: string;
  75999. shader: string;
  76000. };
  76001. }
  76002. // Mixins
  76003. interface Window {
  76004. mozIndexedDB: IDBFactory;
  76005. webkitIndexedDB: IDBFactory;
  76006. msIndexedDB: IDBFactory;
  76007. webkitURL: typeof URL;
  76008. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76009. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76010. WebGLRenderingContext: WebGLRenderingContext;
  76011. MSGesture: MSGesture;
  76012. CANNON: any;
  76013. AudioContext: AudioContext;
  76014. webkitAudioContext: AudioContext;
  76015. PointerEvent: any;
  76016. Math: Math;
  76017. Uint8Array: Uint8ArrayConstructor;
  76018. Float32Array: Float32ArrayConstructor;
  76019. mozURL: typeof URL;
  76020. msURL: typeof URL;
  76021. VRFrameData: any; // WebVR, from specs 1.1
  76022. DracoDecoderModule: any;
  76023. setImmediate(handler: (...args: any[]) => void): number;
  76024. }
  76025. interface HTMLCanvasElement {
  76026. requestPointerLock(): void;
  76027. msRequestPointerLock?(): void;
  76028. mozRequestPointerLock?(): void;
  76029. webkitRequestPointerLock?(): void;
  76030. /** Track wether a record is in progress */
  76031. isRecording: boolean;
  76032. /** Capture Stream method defined by some browsers */
  76033. captureStream(fps?: number): MediaStream;
  76034. }
  76035. interface CanvasRenderingContext2D {
  76036. msImageSmoothingEnabled: boolean;
  76037. }
  76038. interface MouseEvent {
  76039. mozMovementX: number;
  76040. mozMovementY: number;
  76041. webkitMovementX: number;
  76042. webkitMovementY: number;
  76043. msMovementX: number;
  76044. msMovementY: number;
  76045. }
  76046. interface Navigator {
  76047. mozGetVRDevices: (any: any) => any;
  76048. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76049. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76050. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76051. webkitGetGamepads(): Gamepad[];
  76052. msGetGamepads(): Gamepad[];
  76053. webkitGamepads(): Gamepad[];
  76054. }
  76055. interface HTMLVideoElement {
  76056. mozSrcObject: any;
  76057. }
  76058. interface Math {
  76059. fround(x: number): number;
  76060. imul(a: number, b: number): number;
  76061. }
  76062. interface WebGLRenderingContext {
  76063. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76064. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76065. vertexAttribDivisor(index: number, divisor: number): void;
  76066. createVertexArray(): any;
  76067. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76068. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76069. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76070. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76071. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76072. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76073. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76074. // Queries
  76075. createQuery(): WebGLQuery;
  76076. deleteQuery(query: WebGLQuery): void;
  76077. beginQuery(target: number, query: WebGLQuery): void;
  76078. endQuery(target: number): void;
  76079. getQueryParameter(query: WebGLQuery, pname: number): any;
  76080. getQuery(target: number, pname: number): any;
  76081. MAX_SAMPLES: number;
  76082. RGBA8: number;
  76083. READ_FRAMEBUFFER: number;
  76084. DRAW_FRAMEBUFFER: number;
  76085. UNIFORM_BUFFER: number;
  76086. HALF_FLOAT_OES: number;
  76087. RGBA16F: number;
  76088. RGBA32F: number;
  76089. R32F: number;
  76090. RG32F: number;
  76091. RGB32F: number;
  76092. R16F: number;
  76093. RG16F: number;
  76094. RGB16F: number;
  76095. RED: number;
  76096. RG: number;
  76097. R8: number;
  76098. RG8: number;
  76099. UNSIGNED_INT_24_8: number;
  76100. DEPTH24_STENCIL8: number;
  76101. MIN: number;
  76102. MAX: number;
  76103. /* Multiple Render Targets */
  76104. drawBuffers(buffers: number[]): void;
  76105. readBuffer(src: number): void;
  76106. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76107. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76108. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76109. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76110. // Occlusion Query
  76111. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76112. ANY_SAMPLES_PASSED: number;
  76113. QUERY_RESULT_AVAILABLE: number;
  76114. QUERY_RESULT: number;
  76115. }
  76116. interface WebGLProgram {
  76117. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76118. }
  76119. interface EXT_disjoint_timer_query {
  76120. QUERY_COUNTER_BITS_EXT: number;
  76121. TIME_ELAPSED_EXT: number;
  76122. TIMESTAMP_EXT: number;
  76123. GPU_DISJOINT_EXT: number;
  76124. QUERY_RESULT_EXT: number;
  76125. QUERY_RESULT_AVAILABLE_EXT: number;
  76126. queryCounterEXT(query: WebGLQuery, target: number): void;
  76127. createQueryEXT(): WebGLQuery;
  76128. beginQueryEXT(target: number, query: WebGLQuery): void;
  76129. endQueryEXT(target: number): void;
  76130. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76131. deleteQueryEXT(query: WebGLQuery): void;
  76132. }
  76133. interface WebGLUniformLocation {
  76134. _currentState: any;
  76135. }
  76136. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76137. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76138. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76139. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76140. interface WebGLRenderingContext {
  76141. readonly RASTERIZER_DISCARD: number;
  76142. readonly DEPTH_COMPONENT24: number;
  76143. readonly TEXTURE_3D: number;
  76144. readonly TEXTURE_2D_ARRAY: number;
  76145. readonly TEXTURE_COMPARE_FUNC: number;
  76146. readonly TEXTURE_COMPARE_MODE: number;
  76147. readonly COMPARE_REF_TO_TEXTURE: number;
  76148. readonly TEXTURE_WRAP_R: number;
  76149. readonly HALF_FLOAT: number;
  76150. readonly RGB8: number;
  76151. readonly RED_INTEGER: number;
  76152. readonly RG_INTEGER: number;
  76153. readonly RGB_INTEGER: number;
  76154. readonly RGBA_INTEGER: number;
  76155. readonly R8_SNORM: number;
  76156. readonly RG8_SNORM: number;
  76157. readonly RGB8_SNORM: number;
  76158. readonly RGBA8_SNORM: number;
  76159. readonly R8I: number;
  76160. readonly RG8I: number;
  76161. readonly RGB8I: number;
  76162. readonly RGBA8I: number;
  76163. readonly R8UI: number;
  76164. readonly RG8UI: number;
  76165. readonly RGB8UI: number;
  76166. readonly RGBA8UI: number;
  76167. readonly R16I: number;
  76168. readonly RG16I: number;
  76169. readonly RGB16I: number;
  76170. readonly RGBA16I: number;
  76171. readonly R16UI: number;
  76172. readonly RG16UI: number;
  76173. readonly RGB16UI: number;
  76174. readonly RGBA16UI: number;
  76175. readonly R32I: number;
  76176. readonly RG32I: number;
  76177. readonly RGB32I: number;
  76178. readonly RGBA32I: number;
  76179. readonly R32UI: number;
  76180. readonly RG32UI: number;
  76181. readonly RGB32UI: number;
  76182. readonly RGBA32UI: number;
  76183. readonly RGB10_A2UI: number;
  76184. readonly R11F_G11F_B10F: number;
  76185. readonly RGB9_E5: number;
  76186. readonly RGB10_A2: number;
  76187. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76188. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76189. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76190. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76191. readonly DEPTH_COMPONENT32F: number;
  76192. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76193. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76194. 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;
  76195. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76196. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76197. readonly TRANSFORM_FEEDBACK: number;
  76198. readonly INTERLEAVED_ATTRIBS: number;
  76199. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76200. createTransformFeedback(): WebGLTransformFeedback;
  76201. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76202. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76203. beginTransformFeedback(primitiveMode: number): void;
  76204. endTransformFeedback(): void;
  76205. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76206. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76207. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76208. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76209. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76210. }
  76211. interface ImageBitmap {
  76212. readonly width: number;
  76213. readonly height: number;
  76214. close(): void;
  76215. }
  76216. interface WebGLQuery extends WebGLObject {
  76217. }
  76218. declare var WebGLQuery: {
  76219. prototype: WebGLQuery;
  76220. new(): WebGLQuery;
  76221. };
  76222. interface WebGLSampler extends WebGLObject {
  76223. }
  76224. declare var WebGLSampler: {
  76225. prototype: WebGLSampler;
  76226. new(): WebGLSampler;
  76227. };
  76228. interface WebGLSync extends WebGLObject {
  76229. }
  76230. declare var WebGLSync: {
  76231. prototype: WebGLSync;
  76232. new(): WebGLSync;
  76233. };
  76234. interface WebGLTransformFeedback extends WebGLObject {
  76235. }
  76236. declare var WebGLTransformFeedback: {
  76237. prototype: WebGLTransformFeedback;
  76238. new(): WebGLTransformFeedback;
  76239. };
  76240. interface WebGLVertexArrayObject extends WebGLObject {
  76241. }
  76242. declare var WebGLVertexArrayObject: {
  76243. prototype: WebGLVertexArrayObject;
  76244. new(): WebGLVertexArrayObject;
  76245. };
  76246. // Type definitions for WebVR API
  76247. // Project: https://w3c.github.io/webvr/
  76248. // Definitions by: six a <https://github.com/lostfictions>
  76249. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76250. interface VRDisplay extends EventTarget {
  76251. /**
  76252. * Dictionary of capabilities describing the VRDisplay.
  76253. */
  76254. readonly capabilities: VRDisplayCapabilities;
  76255. /**
  76256. * z-depth defining the far plane of the eye view frustum
  76257. * enables mapping of values in the render target depth
  76258. * attachment to scene coordinates. Initially set to 10000.0.
  76259. */
  76260. depthFar: number;
  76261. /**
  76262. * z-depth defining the near plane of the eye view frustum
  76263. * enables mapping of values in the render target depth
  76264. * attachment to scene coordinates. Initially set to 0.01.
  76265. */
  76266. depthNear: number;
  76267. /**
  76268. * An identifier for this distinct VRDisplay. Used as an
  76269. * association point in the Gamepad API.
  76270. */
  76271. readonly displayId: number;
  76272. /**
  76273. * A display name, a user-readable name identifying it.
  76274. */
  76275. readonly displayName: string;
  76276. readonly isConnected: boolean;
  76277. readonly isPresenting: boolean;
  76278. /**
  76279. * If this VRDisplay supports room-scale experiences, the optional
  76280. * stage attribute contains details on the room-scale parameters.
  76281. */
  76282. readonly stageParameters: VRStageParameters | null;
  76283. /**
  76284. * Passing the value returned by `requestAnimationFrame` to
  76285. * `cancelAnimationFrame` will unregister the callback.
  76286. * @param handle Define the hanle of the request to cancel
  76287. */
  76288. cancelAnimationFrame(handle: number): void;
  76289. /**
  76290. * Stops presenting to the VRDisplay.
  76291. * @returns a promise to know when it stopped
  76292. */
  76293. exitPresent(): Promise<void>;
  76294. /**
  76295. * Return the current VREyeParameters for the given eye.
  76296. * @param whichEye Define the eye we want the parameter for
  76297. * @returns the eye parameters
  76298. */
  76299. getEyeParameters(whichEye: string): VREyeParameters;
  76300. /**
  76301. * Populates the passed VRFrameData with the information required to render
  76302. * the current frame.
  76303. * @param frameData Define the data structure to populate
  76304. * @returns true if ok otherwise false
  76305. */
  76306. getFrameData(frameData: VRFrameData): boolean;
  76307. /**
  76308. * Get the layers currently being presented.
  76309. * @returns the list of VR layers
  76310. */
  76311. getLayers(): VRLayer[];
  76312. /**
  76313. * Return a VRPose containing the future predicted pose of the VRDisplay
  76314. * when the current frame will be presented. The value returned will not
  76315. * change until JavaScript has returned control to the browser.
  76316. *
  76317. * The VRPose will contain the position, orientation, velocity,
  76318. * and acceleration of each of these properties.
  76319. * @returns the pose object
  76320. */
  76321. getPose(): VRPose;
  76322. /**
  76323. * Return the current instantaneous pose of the VRDisplay, with no
  76324. * prediction applied.
  76325. * @returns the current instantaneous pose
  76326. */
  76327. getImmediatePose(): VRPose;
  76328. /**
  76329. * The callback passed to `requestAnimationFrame` will be called
  76330. * any time a new frame should be rendered. When the VRDisplay is
  76331. * presenting the callback will be called at the native refresh
  76332. * rate of the HMD. When not presenting this function acts
  76333. * identically to how window.requestAnimationFrame acts. Content should
  76334. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76335. * asynchronously from other displays and at differing refresh rates.
  76336. * @param callback Define the eaction to run next frame
  76337. * @returns the request handle it
  76338. */
  76339. requestAnimationFrame(callback: FrameRequestCallback): number;
  76340. /**
  76341. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76342. * Repeat calls while already presenting will update the VRLayers being displayed.
  76343. * @param layers Define the list of layer to present
  76344. * @returns a promise to know when the request has been fulfilled
  76345. */
  76346. requestPresent(layers: VRLayer[]): Promise<void>;
  76347. /**
  76348. * Reset the pose for this display, treating its current position and
  76349. * orientation as the "origin/zero" values. VRPose.position,
  76350. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76351. * updated when calling resetPose(). This should be called in only
  76352. * sitting-space experiences.
  76353. */
  76354. resetPose(): void;
  76355. /**
  76356. * The VRLayer provided to the VRDisplay will be captured and presented
  76357. * in the HMD. Calling this function has the same effect on the source
  76358. * canvas as any other operation that uses its source image, and canvases
  76359. * created without preserveDrawingBuffer set to true will be cleared.
  76360. * @param pose Define the pose to submit
  76361. */
  76362. submitFrame(pose?: VRPose): void;
  76363. }
  76364. declare var VRDisplay: {
  76365. prototype: VRDisplay;
  76366. new(): VRDisplay;
  76367. };
  76368. interface VRLayer {
  76369. leftBounds?: number[] | Float32Array | null;
  76370. rightBounds?: number[] | Float32Array | null;
  76371. source?: HTMLCanvasElement | null;
  76372. }
  76373. interface VRDisplayCapabilities {
  76374. readonly canPresent: boolean;
  76375. readonly hasExternalDisplay: boolean;
  76376. readonly hasOrientation: boolean;
  76377. readonly hasPosition: boolean;
  76378. readonly maxLayers: number;
  76379. }
  76380. interface VREyeParameters {
  76381. /** @deprecated */
  76382. readonly fieldOfView: VRFieldOfView;
  76383. readonly offset: Float32Array;
  76384. readonly renderHeight: number;
  76385. readonly renderWidth: number;
  76386. }
  76387. interface VRFieldOfView {
  76388. readonly downDegrees: number;
  76389. readonly leftDegrees: number;
  76390. readonly rightDegrees: number;
  76391. readonly upDegrees: number;
  76392. }
  76393. interface VRFrameData {
  76394. readonly leftProjectionMatrix: Float32Array;
  76395. readonly leftViewMatrix: Float32Array;
  76396. readonly pose: VRPose;
  76397. readonly rightProjectionMatrix: Float32Array;
  76398. readonly rightViewMatrix: Float32Array;
  76399. readonly timestamp: number;
  76400. }
  76401. interface VRPose {
  76402. readonly angularAcceleration: Float32Array | null;
  76403. readonly angularVelocity: Float32Array | null;
  76404. readonly linearAcceleration: Float32Array | null;
  76405. readonly linearVelocity: Float32Array | null;
  76406. readonly orientation: Float32Array | null;
  76407. readonly position: Float32Array | null;
  76408. readonly timestamp: number;
  76409. }
  76410. interface VRStageParameters {
  76411. sittingToStandingTransform?: Float32Array;
  76412. sizeX?: number;
  76413. sizeY?: number;
  76414. }
  76415. interface Navigator {
  76416. getVRDisplays(): Promise<VRDisplay[]>;
  76417. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76418. }
  76419. interface Window {
  76420. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76421. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76422. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76423. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76424. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76425. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76426. }
  76427. interface Gamepad {
  76428. readonly displayId: number;
  76429. }
  76430. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76431. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76432. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76433. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76434. type XRHandedness = "none" | "left" | "right";
  76435. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76436. type XREye = "none" | "left" | "right";
  76437. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76438. interface XRSpace extends EventTarget {}
  76439. interface XRRenderState {
  76440. depthNear?: number;
  76441. depthFar?: number;
  76442. inlineVerticalFieldOfView?: number;
  76443. baseLayer?: XRWebGLLayer;
  76444. }
  76445. interface XRInputSource {
  76446. handedness: XRHandedness;
  76447. targetRayMode: XRTargetRayMode;
  76448. targetRaySpace: XRSpace;
  76449. gripSpace: XRSpace | undefined;
  76450. gamepad: Gamepad | undefined;
  76451. profiles: Array<string>;
  76452. hand: XRHand | undefined;
  76453. }
  76454. interface XRSessionInit {
  76455. optionalFeatures?: string[];
  76456. requiredFeatures?: string[];
  76457. }
  76458. interface XRSession {
  76459. addEventListener: Function;
  76460. removeEventListener: Function;
  76461. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76462. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76463. requestAnimationFrame: Function;
  76464. end(): Promise<void>;
  76465. renderState: XRRenderState;
  76466. inputSources: Array<XRInputSource>;
  76467. // hit test
  76468. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76469. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76470. // legacy AR hit test
  76471. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76472. // legacy plane detection
  76473. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76474. }
  76475. interface XRReferenceSpace extends XRSpace {
  76476. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76477. onreset: any;
  76478. }
  76479. type XRPlaneSet = Set<XRPlane>;
  76480. type XRAnchorSet = Set<XRAnchor>;
  76481. interface XRFrame {
  76482. session: XRSession;
  76483. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76484. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76485. // AR
  76486. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76487. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76488. // Anchors
  76489. trackedAnchors?: XRAnchorSet;
  76490. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76491. // Planes
  76492. worldInformation: {
  76493. detectedPlanes?: XRPlaneSet;
  76494. };
  76495. // Hand tracking
  76496. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76497. }
  76498. interface XRViewerPose extends XRPose {
  76499. views: Array<XRView>;
  76500. }
  76501. interface XRPose {
  76502. transform: XRRigidTransform;
  76503. emulatedPosition: boolean;
  76504. }
  76505. interface XRWebGLLayerOptions {
  76506. antialias?: boolean;
  76507. depth?: boolean;
  76508. stencil?: boolean;
  76509. alpha?: boolean;
  76510. multiview?: boolean;
  76511. framebufferScaleFactor?: number;
  76512. }
  76513. declare var XRWebGLLayer: {
  76514. prototype: XRWebGLLayer;
  76515. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76516. };
  76517. interface XRWebGLLayer {
  76518. framebuffer: WebGLFramebuffer;
  76519. framebufferWidth: number;
  76520. framebufferHeight: number;
  76521. getViewport: Function;
  76522. }
  76523. declare class XRRigidTransform {
  76524. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76525. position: DOMPointReadOnly;
  76526. orientation: DOMPointReadOnly;
  76527. matrix: Float32Array;
  76528. inverse: XRRigidTransform;
  76529. }
  76530. interface XRView {
  76531. eye: XREye;
  76532. projectionMatrix: Float32Array;
  76533. transform: XRRigidTransform;
  76534. }
  76535. interface XRInputSourceChangeEvent {
  76536. session: XRSession;
  76537. removed: Array<XRInputSource>;
  76538. added: Array<XRInputSource>;
  76539. }
  76540. interface XRInputSourceEvent extends Event {
  76541. readonly frame: XRFrame;
  76542. readonly inputSource: XRInputSource;
  76543. }
  76544. // Experimental(er) features
  76545. declare class XRRay {
  76546. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76547. origin: DOMPointReadOnly;
  76548. direction: DOMPointReadOnly;
  76549. matrix: Float32Array;
  76550. }
  76551. declare enum XRHitTestTrackableType {
  76552. "point",
  76553. "plane",
  76554. "mesh",
  76555. }
  76556. interface XRHitResult {
  76557. hitMatrix: Float32Array;
  76558. }
  76559. interface XRTransientInputHitTestResult {
  76560. readonly inputSource: XRInputSource;
  76561. readonly results: Array<XRHitTestResult>;
  76562. }
  76563. interface XRHitTestResult {
  76564. getPose(baseSpace: XRSpace): XRPose | undefined;
  76565. // When anchor system is enabled
  76566. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76567. }
  76568. interface XRHitTestSource {
  76569. cancel(): void;
  76570. }
  76571. interface XRTransientInputHitTestSource {
  76572. cancel(): void;
  76573. }
  76574. interface XRHitTestOptionsInit {
  76575. space: XRSpace;
  76576. entityTypes?: Array<XRHitTestTrackableType>;
  76577. offsetRay?: XRRay;
  76578. }
  76579. interface XRTransientInputHitTestOptionsInit {
  76580. profile: string;
  76581. entityTypes?: Array<XRHitTestTrackableType>;
  76582. offsetRay?: XRRay;
  76583. }
  76584. interface XRAnchor {
  76585. anchorSpace: XRSpace;
  76586. delete(): void;
  76587. }
  76588. interface XRPlane {
  76589. orientation: "Horizontal" | "Vertical";
  76590. planeSpace: XRSpace;
  76591. polygon: Array<DOMPointReadOnly>;
  76592. lastChangedTime: number;
  76593. }
  76594. interface XRJointSpace extends XRSpace {}
  76595. interface XRJointPose extends XRPose {
  76596. radius: number | undefined;
  76597. }
  76598. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76599. readonly length: number;
  76600. [index: number]: XRJointSpace;
  76601. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76602. readonly WRIST: number;
  76603. readonly THUMB_METACARPAL: number;
  76604. readonly THUMB_PHALANX_PROXIMAL: number;
  76605. readonly THUMB_PHALANX_DISTAL: number;
  76606. readonly THUMB_PHALANX_TIP: number;
  76607. readonly INDEX_METACARPAL: number;
  76608. readonly INDEX_PHALANX_PROXIMAL: number;
  76609. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76610. readonly INDEX_PHALANX_DISTAL: number;
  76611. readonly INDEX_PHALANX_TIP: number;
  76612. readonly MIDDLE_METACARPAL: number;
  76613. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76614. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76615. readonly MIDDLE_PHALANX_DISTAL: number;
  76616. readonly MIDDLE_PHALANX_TIP: number;
  76617. readonly RING_METACARPAL: number;
  76618. readonly RING_PHALANX_PROXIMAL: number;
  76619. readonly RING_PHALANX_INTERMEDIATE: number;
  76620. readonly RING_PHALANX_DISTAL: number;
  76621. readonly RING_PHALANX_TIP: number;
  76622. readonly LITTLE_METACARPAL: number;
  76623. readonly LITTLE_PHALANX_PROXIMAL: number;
  76624. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76625. readonly LITTLE_PHALANX_DISTAL: number;
  76626. readonly LITTLE_PHALANX_TIP: number;
  76627. }
  76628. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76629. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76630. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76631. interface XRSession {
  76632. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76633. }
  76634. interface XRFrame {
  76635. featurePointCloud? : Array<number>;
  76636. }
  76637. /**
  76638. * @ignore
  76639. */
  76640. declare module BABYLON.GLTF2.Exporter {
  76641. }
  76642. /**
  76643. * @ignore
  76644. */
  76645. declare module BABYLON.GLTF1 {
  76646. }
  76647. declare module BABYLON.GUI {
  76648. /**
  76649. * Class used to specific a value and its associated unit
  76650. */
  76651. export class ValueAndUnit {
  76652. /** defines the unit to store */
  76653. unit: number;
  76654. /** defines a boolean indicating if the value can be negative */
  76655. negativeValueAllowed: boolean;
  76656. private _value;
  76657. private _originalUnit;
  76658. /**
  76659. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76660. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76661. */
  76662. ignoreAdaptiveScaling: boolean;
  76663. /**
  76664. * Creates a new ValueAndUnit
  76665. * @param value defines the value to store
  76666. * @param unit defines the unit to store
  76667. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76668. */
  76669. constructor(value: number,
  76670. /** defines the unit to store */
  76671. unit?: number,
  76672. /** defines a boolean indicating if the value can be negative */
  76673. negativeValueAllowed?: boolean);
  76674. /** Gets a boolean indicating if the value is a percentage */
  76675. get isPercentage(): boolean;
  76676. /** Gets a boolean indicating if the value is store as pixel */
  76677. get isPixel(): boolean;
  76678. /** Gets direct internal value */
  76679. get internalValue(): number;
  76680. /**
  76681. * Gets value as pixel
  76682. * @param host defines the root host
  76683. * @param refValue defines the reference value for percentages
  76684. * @returns the value as pixel
  76685. */
  76686. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76687. /**
  76688. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76689. * @param value defines the value to store
  76690. * @param unit defines the unit to store
  76691. * @returns the current ValueAndUnit
  76692. */
  76693. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76694. /**
  76695. * Gets the value accordingly to its unit
  76696. * @param host defines the root host
  76697. * @returns the value
  76698. */
  76699. getValue(host: AdvancedDynamicTexture): number;
  76700. /**
  76701. * Gets a string representation of the value
  76702. * @param host defines the root host
  76703. * @param decimals defines an optional number of decimals to display
  76704. * @returns a string
  76705. */
  76706. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76707. /**
  76708. * Store a value parsed from a string
  76709. * @param source defines the source string
  76710. * @returns true if the value was successfully parsed
  76711. */
  76712. fromString(source: string | number): boolean;
  76713. private static _Regex;
  76714. private static _UNITMODE_PERCENTAGE;
  76715. private static _UNITMODE_PIXEL;
  76716. /** UNITMODE_PERCENTAGE */
  76717. static get UNITMODE_PERCENTAGE(): number;
  76718. /** UNITMODE_PIXEL */
  76719. static get UNITMODE_PIXEL(): number;
  76720. }
  76721. }
  76722. declare module BABYLON.GUI {
  76723. /**
  76724. * Define a style used by control to automatically setup properties based on a template.
  76725. * Only support font related properties so far
  76726. */
  76727. export class Style implements BABYLON.IDisposable {
  76728. private _fontFamily;
  76729. private _fontStyle;
  76730. private _fontWeight;
  76731. /** @hidden */
  76732. _host: AdvancedDynamicTexture;
  76733. /** @hidden */
  76734. _fontSize: ValueAndUnit;
  76735. /**
  76736. * BABYLON.Observable raised when the style values are changed
  76737. */
  76738. onChangedObservable: BABYLON.Observable<Style>;
  76739. /**
  76740. * Creates a new style object
  76741. * @param host defines the AdvancedDynamicTexture which hosts this style
  76742. */
  76743. constructor(host: AdvancedDynamicTexture);
  76744. /**
  76745. * Gets or sets the font size
  76746. */
  76747. get fontSize(): string | number;
  76748. set fontSize(value: string | number);
  76749. /**
  76750. * Gets or sets the font family
  76751. */
  76752. get fontFamily(): string;
  76753. set fontFamily(value: string);
  76754. /**
  76755. * Gets or sets the font style
  76756. */
  76757. get fontStyle(): string;
  76758. set fontStyle(value: string);
  76759. /** Gets or sets font weight */
  76760. get fontWeight(): string;
  76761. set fontWeight(value: string);
  76762. /** Dispose all associated resources */
  76763. dispose(): void;
  76764. }
  76765. }
  76766. declare module BABYLON.GUI {
  76767. /**
  76768. * Class used to transport BABYLON.Vector2 information for pointer events
  76769. */
  76770. export class Vector2WithInfo extends BABYLON.Vector2 {
  76771. /** defines the current mouse button index */
  76772. buttonIndex: number;
  76773. /**
  76774. * Creates a new Vector2WithInfo
  76775. * @param source defines the vector2 data to transport
  76776. * @param buttonIndex defines the current mouse button index
  76777. */
  76778. constructor(source: BABYLON.Vector2,
  76779. /** defines the current mouse button index */
  76780. buttonIndex?: number);
  76781. }
  76782. /** Class used to provide 2D matrix features */
  76783. export class Matrix2D {
  76784. /** Gets the internal array of 6 floats used to store matrix data */
  76785. m: Float32Array;
  76786. /**
  76787. * Creates a new matrix
  76788. * @param m00 defines value for (0, 0)
  76789. * @param m01 defines value for (0, 1)
  76790. * @param m10 defines value for (1, 0)
  76791. * @param m11 defines value for (1, 1)
  76792. * @param m20 defines value for (2, 0)
  76793. * @param m21 defines value for (2, 1)
  76794. */
  76795. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76796. /**
  76797. * Fills the matrix from direct values
  76798. * @param m00 defines value for (0, 0)
  76799. * @param m01 defines value for (0, 1)
  76800. * @param m10 defines value for (1, 0)
  76801. * @param m11 defines value for (1, 1)
  76802. * @param m20 defines value for (2, 0)
  76803. * @param m21 defines value for (2, 1)
  76804. * @returns the current modified matrix
  76805. */
  76806. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76807. /**
  76808. * Gets matrix determinant
  76809. * @returns the determinant
  76810. */
  76811. determinant(): number;
  76812. /**
  76813. * Inverses the matrix and stores it in a target matrix
  76814. * @param result defines the target matrix
  76815. * @returns the current matrix
  76816. */
  76817. invertToRef(result: Matrix2D): Matrix2D;
  76818. /**
  76819. * Multiplies the current matrix with another one
  76820. * @param other defines the second operand
  76821. * @param result defines the target matrix
  76822. * @returns the current matrix
  76823. */
  76824. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76825. /**
  76826. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76827. * @param x defines the x coordinate to transform
  76828. * @param y defines the x coordinate to transform
  76829. * @param result defines the target vector2
  76830. * @returns the current matrix
  76831. */
  76832. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76833. /**
  76834. * Creates an identity matrix
  76835. * @returns a new matrix
  76836. */
  76837. static Identity(): Matrix2D;
  76838. /**
  76839. * Creates a translation matrix and stores it in a target matrix
  76840. * @param x defines the x coordinate of the translation
  76841. * @param y defines the y coordinate of the translation
  76842. * @param result defines the target matrix
  76843. */
  76844. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76845. /**
  76846. * Creates a scaling matrix and stores it in a target matrix
  76847. * @param x defines the x coordinate of the scaling
  76848. * @param y defines the y coordinate of the scaling
  76849. * @param result defines the target matrix
  76850. */
  76851. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76852. /**
  76853. * Creates a rotation matrix and stores it in a target matrix
  76854. * @param angle defines the rotation angle
  76855. * @param result defines the target matrix
  76856. */
  76857. static RotationToRef(angle: number, result: Matrix2D): void;
  76858. private static _TempPreTranslationMatrix;
  76859. private static _TempPostTranslationMatrix;
  76860. private static _TempRotationMatrix;
  76861. private static _TempScalingMatrix;
  76862. private static _TempCompose0;
  76863. private static _TempCompose1;
  76864. private static _TempCompose2;
  76865. /**
  76866. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76867. * @param tx defines the x coordinate of the translation
  76868. * @param ty defines the y coordinate of the translation
  76869. * @param angle defines the rotation angle
  76870. * @param scaleX defines the x coordinate of the scaling
  76871. * @param scaleY defines the y coordinate of the scaling
  76872. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76873. * @param result defines the target matrix
  76874. */
  76875. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76876. }
  76877. }
  76878. declare module BABYLON.GUI {
  76879. /**
  76880. * Class used to store 2D control sizes
  76881. */
  76882. export class Measure {
  76883. /** defines left coordinate */
  76884. left: number;
  76885. /** defines top coordinate */
  76886. top: number;
  76887. /** defines width dimension */
  76888. width: number;
  76889. /** defines height dimension */
  76890. height: number;
  76891. /**
  76892. * Creates a new measure
  76893. * @param left defines left coordinate
  76894. * @param top defines top coordinate
  76895. * @param width defines width dimension
  76896. * @param height defines height dimension
  76897. */
  76898. constructor(
  76899. /** defines left coordinate */
  76900. left: number,
  76901. /** defines top coordinate */
  76902. top: number,
  76903. /** defines width dimension */
  76904. width: number,
  76905. /** defines height dimension */
  76906. height: number);
  76907. /**
  76908. * Copy from another measure
  76909. * @param other defines the other measure to copy from
  76910. */
  76911. copyFrom(other: Measure): void;
  76912. /**
  76913. * Copy from a group of 4 floats
  76914. * @param left defines left coordinate
  76915. * @param top defines top coordinate
  76916. * @param width defines width dimension
  76917. * @param height defines height dimension
  76918. */
  76919. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76920. /**
  76921. * Computes the axis aligned bounding box measure for two given measures
  76922. * @param a Input measure
  76923. * @param b Input measure
  76924. * @param result the resulting bounding measure
  76925. */
  76926. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76927. /**
  76928. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76929. * @param transform the matrix to transform the measure before computing the AABB
  76930. * @param addX number to add to left
  76931. * @param addY number to add to top
  76932. * @param addWidth number to add to width
  76933. * @param addHeight number to add to height
  76934. * @param result the resulting AABB
  76935. */
  76936. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76937. /**
  76938. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76939. * @param transform the matrix to transform the measure before computing the AABB
  76940. * @param result the resulting AABB
  76941. */
  76942. transformToRef(transform: Matrix2D, result: Measure): void;
  76943. /**
  76944. * Check equality between this measure and another one
  76945. * @param other defines the other measures
  76946. * @returns true if both measures are equals
  76947. */
  76948. isEqualsTo(other: Measure): boolean;
  76949. /**
  76950. * Creates an empty measure
  76951. * @returns a new measure
  76952. */
  76953. static Empty(): Measure;
  76954. }
  76955. }
  76956. declare module BABYLON.GUI {
  76957. /**
  76958. * Interface used to define a control that can receive focus
  76959. */
  76960. export interface IFocusableControl {
  76961. /**
  76962. * Function called when the control receives the focus
  76963. */
  76964. onFocus(): void;
  76965. /**
  76966. * Function called when the control loses the focus
  76967. */
  76968. onBlur(): void;
  76969. /**
  76970. * Function called to let the control handle keyboard events
  76971. * @param evt defines the current keyboard event
  76972. */
  76973. processKeyboard(evt: KeyboardEvent): void;
  76974. /**
  76975. * Function called to get the list of controls that should not steal the focus from this control
  76976. * @returns an array of controls
  76977. */
  76978. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76979. }
  76980. /**
  76981. * Class used to create texture to support 2D GUI elements
  76982. * @see https://doc.babylonjs.com/how_to/gui
  76983. */
  76984. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76985. private _isDirty;
  76986. private _renderObserver;
  76987. private _resizeObserver;
  76988. private _preKeyboardObserver;
  76989. private _pointerMoveObserver;
  76990. private _pointerObserver;
  76991. private _canvasPointerOutObserver;
  76992. private _canvasBlurObserver;
  76993. private _background;
  76994. /** @hidden */
  76995. _rootContainer: Container;
  76996. /** @hidden */
  76997. _lastPickedControl: Control;
  76998. /** @hidden */
  76999. _lastControlOver: {
  77000. [pointerId: number]: Control;
  77001. };
  77002. /** @hidden */
  77003. _lastControlDown: {
  77004. [pointerId: number]: Control;
  77005. };
  77006. /** @hidden */
  77007. _capturingControl: {
  77008. [pointerId: number]: Control;
  77009. };
  77010. /** @hidden */
  77011. _shouldBlockPointer: boolean;
  77012. /** @hidden */
  77013. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77014. /** @hidden */
  77015. _linkedControls: Control[];
  77016. private _isFullscreen;
  77017. private _fullscreenViewport;
  77018. private _idealWidth;
  77019. private _idealHeight;
  77020. private _useSmallestIdeal;
  77021. private _renderAtIdealSize;
  77022. private _focusedControl;
  77023. private _blockNextFocusCheck;
  77024. private _renderScale;
  77025. private _rootElement;
  77026. private _cursorChanged;
  77027. private _defaultMousePointerId;
  77028. /** @hidden */
  77029. _numLayoutCalls: number;
  77030. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77031. get numLayoutCalls(): number;
  77032. /** @hidden */
  77033. _numRenderCalls: number;
  77034. /** Gets the number of render calls made the last time the ADT has been rendered */
  77035. get numRenderCalls(): number;
  77036. /**
  77037. * Define type to string to ensure compatibility across browsers
  77038. * Safari doesn't support DataTransfer constructor
  77039. */
  77040. private _clipboardData;
  77041. /**
  77042. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77043. */
  77044. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77045. /**
  77046. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77047. */
  77048. onControlPickedObservable: BABYLON.Observable<Control>;
  77049. /**
  77050. * BABYLON.Observable event triggered before layout is evaluated
  77051. */
  77052. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77053. /**
  77054. * BABYLON.Observable event triggered after the layout was evaluated
  77055. */
  77056. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77057. /**
  77058. * BABYLON.Observable event triggered before the texture is rendered
  77059. */
  77060. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77061. /**
  77062. * BABYLON.Observable event triggered after the texture was rendered
  77063. */
  77064. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77065. /**
  77066. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77067. */
  77068. premulAlpha: boolean;
  77069. /**
  77070. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77071. * Useful when you want more antialiasing
  77072. */
  77073. get renderScale(): number;
  77074. set renderScale(value: number);
  77075. /** Gets or sets the background color */
  77076. get background(): string;
  77077. set background(value: string);
  77078. /**
  77079. * Gets or sets the ideal width used to design controls.
  77080. * The GUI will then rescale everything accordingly
  77081. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77082. */
  77083. get idealWidth(): number;
  77084. set idealWidth(value: number);
  77085. /**
  77086. * Gets or sets the ideal height used to design controls.
  77087. * The GUI will then rescale everything accordingly
  77088. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77089. */
  77090. get idealHeight(): number;
  77091. set idealHeight(value: number);
  77092. /**
  77093. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77094. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77095. */
  77096. get useSmallestIdeal(): boolean;
  77097. set useSmallestIdeal(value: boolean);
  77098. /**
  77099. * Gets or sets a boolean indicating if adaptive scaling must be used
  77100. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77101. */
  77102. get renderAtIdealSize(): boolean;
  77103. set renderAtIdealSize(value: boolean);
  77104. /**
  77105. * Gets the ratio used when in "ideal mode"
  77106. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77107. * */
  77108. get idealRatio(): number;
  77109. /**
  77110. * Gets the underlying layer used to render the texture when in fullscreen mode
  77111. */
  77112. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77113. /**
  77114. * Gets the root container control
  77115. */
  77116. get rootContainer(): Container;
  77117. /**
  77118. * Returns an array containing the root container.
  77119. * This is mostly used to let the Inspector introspects the ADT
  77120. * @returns an array containing the rootContainer
  77121. */
  77122. getChildren(): Array<Container>;
  77123. /**
  77124. * Will return all controls that are inside this texture
  77125. * @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
  77126. * @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
  77127. * @return all child controls
  77128. */
  77129. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77130. /**
  77131. * Gets or sets the current focused control
  77132. */
  77133. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77134. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77135. /**
  77136. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77137. */
  77138. get isForeground(): boolean;
  77139. set isForeground(value: boolean);
  77140. /**
  77141. * Gets or set information about clipboardData
  77142. */
  77143. get clipboardData(): string;
  77144. set clipboardData(value: string);
  77145. /**
  77146. * Creates a new AdvancedDynamicTexture
  77147. * @param name defines the name of the texture
  77148. * @param width defines the width of the texture
  77149. * @param height defines the height of the texture
  77150. * @param scene defines the hosting scene
  77151. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77152. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77153. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77154. */
  77155. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77156. /**
  77157. * Get the current class name of the texture useful for serialization or dynamic coding.
  77158. * @returns "AdvancedDynamicTexture"
  77159. */
  77160. getClassName(): string;
  77161. /**
  77162. * Function used to execute a function on all controls
  77163. * @param func defines the function to execute
  77164. * @param container defines the container where controls belong. If null the root container will be used
  77165. */
  77166. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77167. private _useInvalidateRectOptimization;
  77168. /**
  77169. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77170. */
  77171. get useInvalidateRectOptimization(): boolean;
  77172. set useInvalidateRectOptimization(value: boolean);
  77173. private _invalidatedRectangle;
  77174. /**
  77175. * Invalidates a rectangle area on the gui texture
  77176. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77177. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77178. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77179. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77180. */
  77181. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77182. /**
  77183. * Marks the texture as dirty forcing a complete update
  77184. */
  77185. markAsDirty(): void;
  77186. /**
  77187. * Helper function used to create a new style
  77188. * @returns a new style
  77189. * @see https://doc.babylonjs.com/how_to/gui#styles
  77190. */
  77191. createStyle(): Style;
  77192. /**
  77193. * Adds a new control to the root container
  77194. * @param control defines the control to add
  77195. * @returns the current texture
  77196. */
  77197. addControl(control: Control): AdvancedDynamicTexture;
  77198. /**
  77199. * Removes a control from the root container
  77200. * @param control defines the control to remove
  77201. * @returns the current texture
  77202. */
  77203. removeControl(control: Control): AdvancedDynamicTexture;
  77204. /**
  77205. * Release all resources
  77206. */
  77207. dispose(): void;
  77208. private _onResize;
  77209. /** @hidden */
  77210. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77211. /**
  77212. * Get screen coordinates for a vector3
  77213. * @param position defines the position to project
  77214. * @param worldMatrix defines the world matrix to use
  77215. * @returns the projected position
  77216. */
  77217. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77218. private _checkUpdate;
  77219. private _clearMeasure;
  77220. private _render;
  77221. /** @hidden */
  77222. _changeCursor(cursor: string): void;
  77223. /** @hidden */
  77224. _registerLastControlDown(control: Control, pointerId: number): void;
  77225. private _doPicking;
  77226. /** @hidden */
  77227. _cleanControlAfterRemovalFromList(list: {
  77228. [pointerId: number]: Control;
  77229. }, control: Control): void;
  77230. /** @hidden */
  77231. _cleanControlAfterRemoval(control: Control): void;
  77232. /** Attach to all scene events required to support pointer events */
  77233. attach(): void;
  77234. /** @hidden */
  77235. private onClipboardCopy;
  77236. /** @hidden */
  77237. private onClipboardCut;
  77238. /** @hidden */
  77239. private onClipboardPaste;
  77240. /**
  77241. * Register the clipboard Events onto the canvas
  77242. */
  77243. registerClipboardEvents(): void;
  77244. /**
  77245. * Unregister the clipboard Events from the canvas
  77246. */
  77247. unRegisterClipboardEvents(): void;
  77248. /**
  77249. * Connect the texture to a hosting mesh to enable interactions
  77250. * @param mesh defines the mesh to attach to
  77251. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77252. */
  77253. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77254. /**
  77255. * Move the focus to a specific control
  77256. * @param control defines the control which will receive the focus
  77257. */
  77258. moveFocusToControl(control: IFocusableControl): void;
  77259. private _manageFocus;
  77260. private _attachToOnPointerOut;
  77261. private _attachToOnBlur;
  77262. /**
  77263. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77264. * @param mesh defines the mesh which will receive the texture
  77265. * @param width defines the texture width (1024 by default)
  77266. * @param height defines the texture height (1024 by default)
  77267. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77268. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77269. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77270. * @returns a new AdvancedDynamicTexture
  77271. */
  77272. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77273. /**
  77274. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77275. * In this mode the texture will rely on a layer for its rendering.
  77276. * This allows it to be treated like any other layer.
  77277. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77278. * LayerMask is set through advancedTexture.layer.layerMask
  77279. * @param name defines name for the texture
  77280. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77281. * @param scene defines the hsoting scene
  77282. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77283. * @returns a new AdvancedDynamicTexture
  77284. */
  77285. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77286. }
  77287. }
  77288. declare module BABYLON.GUI {
  77289. /**
  77290. * Root class used for all 2D controls
  77291. * @see https://doc.babylonjs.com/how_to/gui#controls
  77292. */
  77293. export class Control {
  77294. /** defines the name of the control */
  77295. name?: string | undefined;
  77296. /**
  77297. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77298. */
  77299. static AllowAlphaInheritance: boolean;
  77300. private _alpha;
  77301. private _alphaSet;
  77302. private _zIndex;
  77303. /** @hidden */
  77304. _host: AdvancedDynamicTexture;
  77305. /** Gets or sets the control parent */
  77306. parent: BABYLON.Nullable<Container>;
  77307. /** @hidden */
  77308. _currentMeasure: Measure;
  77309. private _fontFamily;
  77310. private _fontStyle;
  77311. private _fontWeight;
  77312. private _fontSize;
  77313. private _font;
  77314. /** @hidden */
  77315. _width: ValueAndUnit;
  77316. /** @hidden */
  77317. _height: ValueAndUnit;
  77318. /** @hidden */
  77319. protected _fontOffset: {
  77320. ascent: number;
  77321. height: number;
  77322. descent: number;
  77323. };
  77324. private _color;
  77325. private _style;
  77326. private _styleObserver;
  77327. /** @hidden */
  77328. protected _horizontalAlignment: number;
  77329. /** @hidden */
  77330. protected _verticalAlignment: number;
  77331. /** @hidden */
  77332. protected _isDirty: boolean;
  77333. /** @hidden */
  77334. protected _wasDirty: boolean;
  77335. /** @hidden */
  77336. _tempParentMeasure: Measure;
  77337. /** @hidden */
  77338. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77339. /** @hidden */
  77340. protected _cachedParentMeasure: Measure;
  77341. private _paddingLeft;
  77342. private _paddingRight;
  77343. private _paddingTop;
  77344. private _paddingBottom;
  77345. /** @hidden */
  77346. _left: ValueAndUnit;
  77347. /** @hidden */
  77348. _top: ValueAndUnit;
  77349. private _scaleX;
  77350. private _scaleY;
  77351. private _rotation;
  77352. private _transformCenterX;
  77353. private _transformCenterY;
  77354. /** @hidden */
  77355. _transformMatrix: Matrix2D;
  77356. /** @hidden */
  77357. protected _invertTransformMatrix: Matrix2D;
  77358. /** @hidden */
  77359. protected _transformedPosition: BABYLON.Vector2;
  77360. private _isMatrixDirty;
  77361. private _cachedOffsetX;
  77362. private _cachedOffsetY;
  77363. private _isVisible;
  77364. private _isHighlighted;
  77365. /** @hidden */
  77366. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77367. private _fontSet;
  77368. private _dummyVector2;
  77369. private _downCount;
  77370. private _enterCount;
  77371. private _doNotRender;
  77372. private _downPointerIds;
  77373. protected _isEnabled: boolean;
  77374. protected _disabledColor: string;
  77375. protected _disabledColorItem: string;
  77376. /** @hidden */
  77377. protected _rebuildLayout: boolean;
  77378. /** @hidden */
  77379. _customData: any;
  77380. /** @hidden */
  77381. _isClipped: boolean;
  77382. /** @hidden */
  77383. _automaticSize: boolean;
  77384. /** @hidden */
  77385. _tag: any;
  77386. /**
  77387. * 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
  77388. */
  77389. uniqueId: number;
  77390. /**
  77391. * Gets or sets an object used to store user defined information for the node
  77392. */
  77393. metadata: any;
  77394. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77395. isHitTestVisible: boolean;
  77396. /** Gets or sets a boolean indicating if the control can block pointer events */
  77397. isPointerBlocker: boolean;
  77398. /** Gets or sets a boolean indicating if the control can be focusable */
  77399. isFocusInvisible: boolean;
  77400. /**
  77401. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77402. * 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
  77403. */
  77404. clipChildren: boolean;
  77405. /**
  77406. * Gets or sets a boolean indicating that control content must be clipped
  77407. * 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
  77408. */
  77409. clipContent: boolean;
  77410. /**
  77411. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77412. */
  77413. useBitmapCache: boolean;
  77414. private _cacheData;
  77415. private _shadowOffsetX;
  77416. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77417. get shadowOffsetX(): number;
  77418. set shadowOffsetX(value: number);
  77419. private _shadowOffsetY;
  77420. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77421. get shadowOffsetY(): number;
  77422. set shadowOffsetY(value: number);
  77423. private _shadowBlur;
  77424. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77425. get shadowBlur(): number;
  77426. set shadowBlur(value: number);
  77427. private _shadowColor;
  77428. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77429. get shadowColor(): string;
  77430. set shadowColor(value: string);
  77431. /** Gets or sets the cursor to use when the control is hovered */
  77432. hoverCursor: string;
  77433. /** @hidden */
  77434. protected _linkOffsetX: ValueAndUnit;
  77435. /** @hidden */
  77436. protected _linkOffsetY: ValueAndUnit;
  77437. /** Gets the control type name */
  77438. get typeName(): string;
  77439. /**
  77440. * Get the current class name of the control.
  77441. * @returns current class name
  77442. */
  77443. getClassName(): string;
  77444. /**
  77445. * An event triggered when pointer wheel is scrolled
  77446. */
  77447. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77448. /**
  77449. * An event triggered when the pointer move over the control.
  77450. */
  77451. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77452. /**
  77453. * An event triggered when the pointer move out of the control.
  77454. */
  77455. onPointerOutObservable: BABYLON.Observable<Control>;
  77456. /**
  77457. * An event triggered when the pointer taps the control
  77458. */
  77459. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77460. /**
  77461. * An event triggered when pointer up
  77462. */
  77463. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77464. /**
  77465. * An event triggered when a control is clicked on
  77466. */
  77467. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77468. /**
  77469. * An event triggered when pointer enters the control
  77470. */
  77471. onPointerEnterObservable: BABYLON.Observable<Control>;
  77472. /**
  77473. * An event triggered when the control is marked as dirty
  77474. */
  77475. onDirtyObservable: BABYLON.Observable<Control>;
  77476. /**
  77477. * An event triggered before drawing the control
  77478. */
  77479. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77480. /**
  77481. * An event triggered after the control was drawn
  77482. */
  77483. onAfterDrawObservable: BABYLON.Observable<Control>;
  77484. /**
  77485. * An event triggered when the control has been disposed
  77486. */
  77487. onDisposeObservable: BABYLON.Observable<Control>;
  77488. /**
  77489. * Get the hosting AdvancedDynamicTexture
  77490. */
  77491. get host(): AdvancedDynamicTexture;
  77492. /** Gets or set information about font offsets (used to render and align text) */
  77493. get fontOffset(): {
  77494. ascent: number;
  77495. height: number;
  77496. descent: number;
  77497. };
  77498. set fontOffset(offset: {
  77499. ascent: number;
  77500. height: number;
  77501. descent: number;
  77502. });
  77503. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77504. get alpha(): number;
  77505. set alpha(value: number);
  77506. /**
  77507. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77508. */
  77509. get isHighlighted(): boolean;
  77510. set isHighlighted(value: boolean);
  77511. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77512. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77513. */
  77514. get scaleX(): number;
  77515. set scaleX(value: number);
  77516. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77517. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77518. */
  77519. get scaleY(): number;
  77520. set scaleY(value: number);
  77521. /** Gets or sets the rotation angle (0 by default)
  77522. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77523. */
  77524. get rotation(): number;
  77525. set rotation(value: number);
  77526. /** Gets or sets the transformation center on Y axis (0 by default)
  77527. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77528. */
  77529. get transformCenterY(): number;
  77530. set transformCenterY(value: number);
  77531. /** Gets or sets the transformation center on X axis (0 by default)
  77532. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77533. */
  77534. get transformCenterX(): number;
  77535. set transformCenterX(value: number);
  77536. /**
  77537. * Gets or sets the horizontal alignment
  77538. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77539. */
  77540. get horizontalAlignment(): number;
  77541. set horizontalAlignment(value: number);
  77542. /**
  77543. * Gets or sets the vertical alignment
  77544. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77545. */
  77546. get verticalAlignment(): number;
  77547. set verticalAlignment(value: number);
  77548. /**
  77549. * Gets or sets a fixed ratio for this control.
  77550. * When different from 0, the ratio is used to compute the "second" dimension.
  77551. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77552. * second dimension is computed as first dimension * fixedRatio
  77553. */
  77554. fixedRatio: number;
  77555. private _fixedRatioMasterIsWidth;
  77556. /**
  77557. * Gets or sets control width
  77558. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77559. */
  77560. get width(): string | number;
  77561. set width(value: string | number);
  77562. /**
  77563. * Gets or sets the control width in pixel
  77564. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77565. */
  77566. get widthInPixels(): number;
  77567. set widthInPixels(value: number);
  77568. /**
  77569. * Gets or sets control height
  77570. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77571. */
  77572. get height(): string | number;
  77573. set height(value: string | number);
  77574. /**
  77575. * Gets or sets control height in pixel
  77576. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77577. */
  77578. get heightInPixels(): number;
  77579. set heightInPixels(value: number);
  77580. /** Gets or set font family */
  77581. get fontFamily(): string;
  77582. set fontFamily(value: string);
  77583. /** Gets or sets font style */
  77584. get fontStyle(): string;
  77585. set fontStyle(value: string);
  77586. /** Gets or sets font weight */
  77587. get fontWeight(): string;
  77588. set fontWeight(value: string);
  77589. /**
  77590. * Gets or sets style
  77591. * @see https://doc.babylonjs.com/how_to/gui#styles
  77592. */
  77593. get style(): BABYLON.Nullable<Style>;
  77594. set style(value: BABYLON.Nullable<Style>);
  77595. /** @hidden */
  77596. get _isFontSizeInPercentage(): boolean;
  77597. /** Gets or sets font size in pixels */
  77598. get fontSizeInPixels(): number;
  77599. set fontSizeInPixels(value: number);
  77600. /** Gets or sets font size */
  77601. get fontSize(): string | number;
  77602. set fontSize(value: string | number);
  77603. /** Gets or sets foreground color */
  77604. get color(): string;
  77605. set color(value: string);
  77606. /** Gets or sets z index which is used to reorder controls on the z axis */
  77607. get zIndex(): number;
  77608. set zIndex(value: number);
  77609. /** Gets or sets a boolean indicating if the control can be rendered */
  77610. get notRenderable(): boolean;
  77611. set notRenderable(value: boolean);
  77612. /** Gets or sets a boolean indicating if the control is visible */
  77613. get isVisible(): boolean;
  77614. set isVisible(value: boolean);
  77615. /** Gets a boolean indicating that the control needs to update its rendering */
  77616. get isDirty(): boolean;
  77617. /**
  77618. * Gets the current linked mesh (or null if none)
  77619. */
  77620. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77621. /**
  77622. * Gets or sets a value indicating the padding to use on the left of the control
  77623. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77624. */
  77625. get paddingLeft(): string | number;
  77626. set paddingLeft(value: string | number);
  77627. /**
  77628. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77629. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77630. */
  77631. get paddingLeftInPixels(): number;
  77632. set paddingLeftInPixels(value: number);
  77633. /**
  77634. * Gets or sets a value indicating the padding to use on the right of the control
  77635. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77636. */
  77637. get paddingRight(): string | number;
  77638. set paddingRight(value: string | number);
  77639. /**
  77640. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77641. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77642. */
  77643. get paddingRightInPixels(): number;
  77644. set paddingRightInPixels(value: number);
  77645. /**
  77646. * Gets or sets a value indicating the padding to use on the top of the control
  77647. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77648. */
  77649. get paddingTop(): string | number;
  77650. set paddingTop(value: string | number);
  77651. /**
  77652. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77653. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77654. */
  77655. get paddingTopInPixels(): number;
  77656. set paddingTopInPixels(value: number);
  77657. /**
  77658. * Gets or sets a value indicating the padding to use on the bottom of the control
  77659. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77660. */
  77661. get paddingBottom(): string | number;
  77662. set paddingBottom(value: string | number);
  77663. /**
  77664. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77665. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77666. */
  77667. get paddingBottomInPixels(): number;
  77668. set paddingBottomInPixels(value: number);
  77669. /**
  77670. * Gets or sets a value indicating the left coordinate of the control
  77671. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77672. */
  77673. get left(): string | number;
  77674. set left(value: string | number);
  77675. /**
  77676. * Gets or sets a value indicating the left coordinate in pixels of the control
  77677. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77678. */
  77679. get leftInPixels(): number;
  77680. set leftInPixels(value: number);
  77681. /**
  77682. * Gets or sets a value indicating the top coordinate of the control
  77683. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77684. */
  77685. get top(): string | number;
  77686. set top(value: string | number);
  77687. /**
  77688. * Gets or sets a value indicating the top coordinate in pixels of the control
  77689. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77690. */
  77691. get topInPixels(): number;
  77692. set topInPixels(value: number);
  77693. /**
  77694. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77695. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77696. */
  77697. get linkOffsetX(): string | number;
  77698. set linkOffsetX(value: string | number);
  77699. /**
  77700. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77701. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77702. */
  77703. get linkOffsetXInPixels(): number;
  77704. set linkOffsetXInPixels(value: number);
  77705. /**
  77706. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77707. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77708. */
  77709. get linkOffsetY(): string | number;
  77710. set linkOffsetY(value: string | number);
  77711. /**
  77712. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77713. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77714. */
  77715. get linkOffsetYInPixels(): number;
  77716. set linkOffsetYInPixels(value: number);
  77717. /** Gets the center coordinate on X axis */
  77718. get centerX(): number;
  77719. /** Gets the center coordinate on Y axis */
  77720. get centerY(): number;
  77721. /** Gets or sets if control is Enabled*/
  77722. get isEnabled(): boolean;
  77723. set isEnabled(value: boolean);
  77724. /** Gets or sets background color of control if it's disabled*/
  77725. get disabledColor(): string;
  77726. set disabledColor(value: string);
  77727. /** Gets or sets front color of control if it's disabled*/
  77728. get disabledColorItem(): string;
  77729. set disabledColorItem(value: string);
  77730. /**
  77731. * Creates a new control
  77732. * @param name defines the name of the control
  77733. */
  77734. constructor(
  77735. /** defines the name of the control */
  77736. name?: string | undefined);
  77737. /** @hidden */
  77738. protected _getTypeName(): string;
  77739. /**
  77740. * Gets the first ascendant in the hierarchy of the given type
  77741. * @param className defines the required type
  77742. * @returns the ascendant or null if not found
  77743. */
  77744. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77745. /** @hidden */
  77746. _resetFontCache(): void;
  77747. /**
  77748. * Determines if a container is an ascendant of the current control
  77749. * @param container defines the container to look for
  77750. * @returns true if the container is one of the ascendant of the control
  77751. */
  77752. isAscendant(container: Control): boolean;
  77753. /**
  77754. * Gets coordinates in local control space
  77755. * @param globalCoordinates defines the coordinates to transform
  77756. * @returns the new coordinates in local space
  77757. */
  77758. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77759. /**
  77760. * Gets coordinates in local control space
  77761. * @param globalCoordinates defines the coordinates to transform
  77762. * @param result defines the target vector2 where to store the result
  77763. * @returns the current control
  77764. */
  77765. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77766. /**
  77767. * Gets coordinates in parent local control space
  77768. * @param globalCoordinates defines the coordinates to transform
  77769. * @returns the new coordinates in parent local space
  77770. */
  77771. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77772. /**
  77773. * Move the current control to a vector3 position projected onto the screen.
  77774. * @param position defines the target position
  77775. * @param scene defines the hosting scene
  77776. */
  77777. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77778. /**
  77779. * Will store all controls that have this control as ascendant in a given array
  77780. * @param results defines the array where to store the descendants
  77781. * @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
  77782. * @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
  77783. */
  77784. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77785. /**
  77786. * Will return all controls that have this control as ascendant
  77787. * @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
  77788. * @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
  77789. * @return all child controls
  77790. */
  77791. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77792. /**
  77793. * Link current control with a target mesh
  77794. * @param mesh defines the mesh to link with
  77795. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77796. */
  77797. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77798. /** @hidden */
  77799. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77800. /** @hidden */
  77801. _offsetLeft(offset: number): void;
  77802. /** @hidden */
  77803. _offsetTop(offset: number): void;
  77804. /** @hidden */
  77805. _markMatrixAsDirty(): void;
  77806. /** @hidden */
  77807. _flagDescendantsAsMatrixDirty(): void;
  77808. /** @hidden */
  77809. _intersectsRect(rect: Measure): boolean;
  77810. /** @hidden */
  77811. protected invalidateRect(): void;
  77812. /** @hidden */
  77813. _markAsDirty(force?: boolean): void;
  77814. /** @hidden */
  77815. _markAllAsDirty(): void;
  77816. /** @hidden */
  77817. _link(host: AdvancedDynamicTexture): void;
  77818. /** @hidden */
  77819. protected _transform(context?: CanvasRenderingContext2D): void;
  77820. /** @hidden */
  77821. _renderHighlight(context: CanvasRenderingContext2D): void;
  77822. /** @hidden */
  77823. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77824. /** @hidden */
  77825. protected _applyStates(context: CanvasRenderingContext2D): void;
  77826. /** @hidden */
  77827. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77828. /** @hidden */
  77829. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77830. protected _evaluateClippingState(parentMeasure: Measure): void;
  77831. /** @hidden */
  77832. _measure(): void;
  77833. /** @hidden */
  77834. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77835. /** @hidden */
  77836. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77837. /** @hidden */
  77838. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77839. /** @hidden */
  77840. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77841. private static _ClipMeasure;
  77842. private _tmpMeasureA;
  77843. private _clip;
  77844. /** @hidden */
  77845. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77846. /** @hidden */
  77847. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77848. /**
  77849. * Tests if a given coordinates belong to the current control
  77850. * @param x defines x coordinate to test
  77851. * @param y defines y coordinate to test
  77852. * @returns true if the coordinates are inside the control
  77853. */
  77854. contains(x: number, y: number): boolean;
  77855. /** @hidden */
  77856. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77857. /** @hidden */
  77858. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77859. /** @hidden */
  77860. _onPointerEnter(target: Control): boolean;
  77861. /** @hidden */
  77862. _onPointerOut(target: Control, force?: boolean): void;
  77863. /** @hidden */
  77864. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77865. /** @hidden */
  77866. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77867. /** @hidden */
  77868. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77869. /** @hidden */
  77870. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77871. /** @hidden */
  77872. _onCanvasBlur(): void;
  77873. /** @hidden */
  77874. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77875. private _prepareFont;
  77876. /** Releases associated resources */
  77877. dispose(): void;
  77878. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77879. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77880. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77881. private static _VERTICAL_ALIGNMENT_TOP;
  77882. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77883. private static _VERTICAL_ALIGNMENT_CENTER;
  77884. /** HORIZONTAL_ALIGNMENT_LEFT */
  77885. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77886. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77887. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77888. /** HORIZONTAL_ALIGNMENT_CENTER */
  77889. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77890. /** VERTICAL_ALIGNMENT_TOP */
  77891. static get VERTICAL_ALIGNMENT_TOP(): number;
  77892. /** VERTICAL_ALIGNMENT_BOTTOM */
  77893. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77894. /** VERTICAL_ALIGNMENT_CENTER */
  77895. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77896. private static _FontHeightSizes;
  77897. /** @hidden */
  77898. static _GetFontOffset(font: string): {
  77899. ascent: number;
  77900. height: number;
  77901. descent: number;
  77902. };
  77903. /**
  77904. * Creates a stack panel that can be used to render headers
  77905. * @param control defines the control to associate with the header
  77906. * @param text defines the text of the header
  77907. * @param size defines the size of the header
  77908. * @param options defines options used to configure the header
  77909. * @returns a new StackPanel
  77910. * @ignore
  77911. * @hidden
  77912. */
  77913. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77914. isHorizontal: boolean;
  77915. controlFirst: boolean;
  77916. }) => any;
  77917. /** @hidden */
  77918. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77919. }
  77920. }
  77921. declare module BABYLON.GUI {
  77922. /**
  77923. * Root class for 2D containers
  77924. * @see https://doc.babylonjs.com/how_to/gui#containers
  77925. */
  77926. export class Container extends Control {
  77927. name?: string | undefined;
  77928. /** @hidden */
  77929. _children: Control[];
  77930. /** @hidden */
  77931. protected _measureForChildren: Measure;
  77932. /** @hidden */
  77933. protected _background: string;
  77934. /** @hidden */
  77935. protected _adaptWidthToChildren: boolean;
  77936. /** @hidden */
  77937. protected _adaptHeightToChildren: boolean;
  77938. /**
  77939. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77940. */
  77941. logLayoutCycleErrors: boolean;
  77942. /**
  77943. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77944. */
  77945. maxLayoutCycle: number;
  77946. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77947. get adaptHeightToChildren(): boolean;
  77948. set adaptHeightToChildren(value: boolean);
  77949. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77950. get adaptWidthToChildren(): boolean;
  77951. set adaptWidthToChildren(value: boolean);
  77952. /** Gets or sets background color */
  77953. get background(): string;
  77954. set background(value: string);
  77955. /** Gets the list of children */
  77956. get children(): Control[];
  77957. /**
  77958. * Creates a new Container
  77959. * @param name defines the name of the container
  77960. */
  77961. constructor(name?: string | undefined);
  77962. protected _getTypeName(): string;
  77963. _flagDescendantsAsMatrixDirty(): void;
  77964. /**
  77965. * Gets a child using its name
  77966. * @param name defines the child name to look for
  77967. * @returns the child control if found
  77968. */
  77969. getChildByName(name: string): BABYLON.Nullable<Control>;
  77970. /**
  77971. * Gets a child using its type and its name
  77972. * @param name defines the child name to look for
  77973. * @param type defines the child type to look for
  77974. * @returns the child control if found
  77975. */
  77976. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77977. /**
  77978. * Search for a specific control in children
  77979. * @param control defines the control to look for
  77980. * @returns true if the control is in child list
  77981. */
  77982. containsControl(control: Control): boolean;
  77983. /**
  77984. * Adds a new control to the current container
  77985. * @param control defines the control to add
  77986. * @returns the current container
  77987. */
  77988. addControl(control: BABYLON.Nullable<Control>): Container;
  77989. /**
  77990. * Removes all controls from the current container
  77991. * @returns the current container
  77992. */
  77993. clearControls(): Container;
  77994. /**
  77995. * Removes a control from the current container
  77996. * @param control defines the control to remove
  77997. * @returns the current container
  77998. */
  77999. removeControl(control: Control): Container;
  78000. /** @hidden */
  78001. _reOrderControl(control: Control): void;
  78002. /** @hidden */
  78003. _offsetLeft(offset: number): void;
  78004. /** @hidden */
  78005. _offsetTop(offset: number): void;
  78006. /** @hidden */
  78007. _markAllAsDirty(): void;
  78008. /** @hidden */
  78009. protected _localDraw(context: CanvasRenderingContext2D): void;
  78010. /** @hidden */
  78011. _link(host: AdvancedDynamicTexture): void;
  78012. /** @hidden */
  78013. protected _beforeLayout(): void;
  78014. /** @hidden */
  78015. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78016. /** @hidden */
  78017. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78018. protected _postMeasure(): void;
  78019. /** @hidden */
  78020. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78021. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78022. /** @hidden */
  78023. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78024. /** @hidden */
  78025. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78026. /** Releases associated resources */
  78027. dispose(): void;
  78028. }
  78029. }
  78030. declare module BABYLON.GUI {
  78031. /** Class used to create rectangle container */
  78032. export class Rectangle extends Container {
  78033. name?: string | undefined;
  78034. private _thickness;
  78035. private _cornerRadius;
  78036. /** Gets or sets border thickness */
  78037. get thickness(): number;
  78038. set thickness(value: number);
  78039. /** Gets or sets the corner radius angle */
  78040. get cornerRadius(): number;
  78041. set cornerRadius(value: number);
  78042. /**
  78043. * Creates a new Rectangle
  78044. * @param name defines the control name
  78045. */
  78046. constructor(name?: string | undefined);
  78047. protected _getTypeName(): string;
  78048. protected _localDraw(context: CanvasRenderingContext2D): void;
  78049. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78050. private _drawRoundedRect;
  78051. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78052. }
  78053. }
  78054. declare module BABYLON.GUI {
  78055. /**
  78056. * Enum that determines the text-wrapping mode to use.
  78057. */
  78058. export enum TextWrapping {
  78059. /**
  78060. * Clip the text when it's larger than Control.width; this is the default mode.
  78061. */
  78062. Clip = 0,
  78063. /**
  78064. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78065. */
  78066. WordWrap = 1,
  78067. /**
  78068. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78069. */
  78070. Ellipsis = 2
  78071. }
  78072. /**
  78073. * Class used to create text block control
  78074. */
  78075. export class TextBlock extends Control {
  78076. /**
  78077. * Defines the name of the control
  78078. */
  78079. name?: string | undefined;
  78080. private _text;
  78081. private _textWrapping;
  78082. private _textHorizontalAlignment;
  78083. private _textVerticalAlignment;
  78084. private _lines;
  78085. private _resizeToFit;
  78086. private _lineSpacing;
  78087. private _outlineWidth;
  78088. private _outlineColor;
  78089. private _underline;
  78090. private _lineThrough;
  78091. /**
  78092. * An event triggered after the text is changed
  78093. */
  78094. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78095. /**
  78096. * An event triggered after the text was broken up into lines
  78097. */
  78098. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78099. /**
  78100. * Function used to split a string into words. By default, a string is split at each space character found
  78101. */
  78102. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78103. /**
  78104. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78105. */
  78106. get lines(): any[];
  78107. /**
  78108. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78109. */
  78110. get resizeToFit(): boolean;
  78111. /**
  78112. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78113. */
  78114. set resizeToFit(value: boolean);
  78115. /**
  78116. * Gets or sets a boolean indicating if text must be wrapped
  78117. */
  78118. get textWrapping(): TextWrapping | boolean;
  78119. /**
  78120. * Gets or sets a boolean indicating if text must be wrapped
  78121. */
  78122. set textWrapping(value: TextWrapping | boolean);
  78123. /**
  78124. * Gets or sets text to display
  78125. */
  78126. get text(): string;
  78127. /**
  78128. * Gets or sets text to display
  78129. */
  78130. set text(value: string);
  78131. /**
  78132. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78133. */
  78134. get textHorizontalAlignment(): number;
  78135. /**
  78136. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78137. */
  78138. set textHorizontalAlignment(value: number);
  78139. /**
  78140. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78141. */
  78142. get textVerticalAlignment(): number;
  78143. /**
  78144. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78145. */
  78146. set textVerticalAlignment(value: number);
  78147. /**
  78148. * Gets or sets line spacing value
  78149. */
  78150. set lineSpacing(value: string | number);
  78151. /**
  78152. * Gets or sets line spacing value
  78153. */
  78154. get lineSpacing(): string | number;
  78155. /**
  78156. * Gets or sets outlineWidth of the text to display
  78157. */
  78158. get outlineWidth(): number;
  78159. /**
  78160. * Gets or sets outlineWidth of the text to display
  78161. */
  78162. set outlineWidth(value: number);
  78163. /**
  78164. * Gets or sets a boolean indicating that text must have underline
  78165. */
  78166. get underline(): boolean;
  78167. /**
  78168. * Gets or sets a boolean indicating that text must have underline
  78169. */
  78170. set underline(value: boolean);
  78171. /**
  78172. * Gets or sets an boolean indicating that text must be crossed out
  78173. */
  78174. get lineThrough(): boolean;
  78175. /**
  78176. * Gets or sets an boolean indicating that text must be crossed out
  78177. */
  78178. set lineThrough(value: boolean);
  78179. /**
  78180. * Gets or sets outlineColor of the text to display
  78181. */
  78182. get outlineColor(): string;
  78183. /**
  78184. * Gets or sets outlineColor of the text to display
  78185. */
  78186. set outlineColor(value: string);
  78187. /**
  78188. * Creates a new TextBlock object
  78189. * @param name defines the name of the control
  78190. * @param text defines the text to display (emptry string by default)
  78191. */
  78192. constructor(
  78193. /**
  78194. * Defines the name of the control
  78195. */
  78196. name?: string | undefined, text?: string);
  78197. protected _getTypeName(): string;
  78198. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78199. private _drawText;
  78200. /** @hidden */
  78201. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78202. protected _applyStates(context: CanvasRenderingContext2D): void;
  78203. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78204. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78205. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78206. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78207. protected _renderLines(context: CanvasRenderingContext2D): void;
  78208. /**
  78209. * Given a width constraint applied on the text block, find the expected height
  78210. * @returns expected height
  78211. */
  78212. computeExpectedHeight(): number;
  78213. dispose(): void;
  78214. }
  78215. }
  78216. declare module BABYLON.GUI {
  78217. /**
  78218. * Class used to create 2D images
  78219. */
  78220. export class Image extends Control {
  78221. name?: string | undefined;
  78222. private _workingCanvas;
  78223. private _domImage;
  78224. private _imageWidth;
  78225. private _imageHeight;
  78226. private _loaded;
  78227. private _stretch;
  78228. private _source;
  78229. private _autoScale;
  78230. private _sourceLeft;
  78231. private _sourceTop;
  78232. private _sourceWidth;
  78233. private _sourceHeight;
  78234. private _svgAttributesComputationCompleted;
  78235. private _isSVG;
  78236. private _cellWidth;
  78237. private _cellHeight;
  78238. private _cellId;
  78239. private _populateNinePatchSlicesFromImage;
  78240. private _sliceLeft;
  78241. private _sliceRight;
  78242. private _sliceTop;
  78243. private _sliceBottom;
  78244. private _detectPointerOnOpaqueOnly;
  78245. private _imageDataCache;
  78246. /**
  78247. * BABYLON.Observable notified when the content is loaded
  78248. */
  78249. onImageLoadedObservable: BABYLON.Observable<Image>;
  78250. /**
  78251. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78252. */
  78253. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78254. /**
  78255. * Gets a boolean indicating that the content is loaded
  78256. */
  78257. get isLoaded(): boolean;
  78258. /**
  78259. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78260. */
  78261. get populateNinePatchSlicesFromImage(): boolean;
  78262. set populateNinePatchSlicesFromImage(value: boolean);
  78263. /**
  78264. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78265. * Beware using this as this will comsume more memory as the image has to be stored twice
  78266. */
  78267. get detectPointerOnOpaqueOnly(): boolean;
  78268. set detectPointerOnOpaqueOnly(value: boolean);
  78269. /**
  78270. * Gets or sets the left value for slicing (9-patch)
  78271. */
  78272. get sliceLeft(): number;
  78273. set sliceLeft(value: number);
  78274. /**
  78275. * Gets or sets the right value for slicing (9-patch)
  78276. */
  78277. get sliceRight(): number;
  78278. set sliceRight(value: number);
  78279. /**
  78280. * Gets or sets the top value for slicing (9-patch)
  78281. */
  78282. get sliceTop(): number;
  78283. set sliceTop(value: number);
  78284. /**
  78285. * Gets or sets the bottom value for slicing (9-patch)
  78286. */
  78287. get sliceBottom(): number;
  78288. set sliceBottom(value: number);
  78289. /**
  78290. * Gets or sets the left coordinate in the source image
  78291. */
  78292. get sourceLeft(): number;
  78293. set sourceLeft(value: number);
  78294. /**
  78295. * Gets or sets the top coordinate in the source image
  78296. */
  78297. get sourceTop(): number;
  78298. set sourceTop(value: number);
  78299. /**
  78300. * Gets or sets the width to capture in the source image
  78301. */
  78302. get sourceWidth(): number;
  78303. set sourceWidth(value: number);
  78304. /**
  78305. * Gets or sets the height to capture in the source image
  78306. */
  78307. get sourceHeight(): number;
  78308. set sourceHeight(value: number);
  78309. /** Indicates if the format of the image is SVG */
  78310. get isSVG(): boolean;
  78311. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78312. get svgAttributesComputationCompleted(): boolean;
  78313. /**
  78314. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78315. * @see https://doc.babylonjs.com/how_to/gui#image
  78316. */
  78317. get autoScale(): boolean;
  78318. set autoScale(value: boolean);
  78319. /** Gets or sets the streching mode used by the image */
  78320. get stretch(): number;
  78321. set stretch(value: number);
  78322. /** @hidden */
  78323. _rotate90(n: number, preserveProperties?: boolean): Image;
  78324. private _handleRotationForSVGImage;
  78325. private _rotate90SourceProperties;
  78326. /**
  78327. * Gets or sets the internal DOM image used to render the control
  78328. */
  78329. set domImage(value: HTMLImageElement);
  78330. get domImage(): HTMLImageElement;
  78331. private _onImageLoaded;
  78332. private _extractNinePatchSliceDataFromImage;
  78333. /**
  78334. * Gets or sets image source url
  78335. */
  78336. set source(value: BABYLON.Nullable<string>);
  78337. /**
  78338. * Checks for svg document with icon id present
  78339. */
  78340. private _svgCheck;
  78341. /**
  78342. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78343. * given external svg file and icon id
  78344. */
  78345. private _getSVGAttribs;
  78346. /**
  78347. * Gets or sets the cell width to use when animation sheet is enabled
  78348. * @see https://doc.babylonjs.com/how_to/gui#image
  78349. */
  78350. get cellWidth(): number;
  78351. set cellWidth(value: number);
  78352. /**
  78353. * Gets or sets the cell height to use when animation sheet is enabled
  78354. * @see https://doc.babylonjs.com/how_to/gui#image
  78355. */
  78356. get cellHeight(): number;
  78357. set cellHeight(value: number);
  78358. /**
  78359. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78360. * @see https://doc.babylonjs.com/how_to/gui#image
  78361. */
  78362. get cellId(): number;
  78363. set cellId(value: number);
  78364. /**
  78365. * Creates a new Image
  78366. * @param name defines the control name
  78367. * @param url defines the image url
  78368. */
  78369. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78370. /**
  78371. * Tests if a given coordinates belong to the current control
  78372. * @param x defines x coordinate to test
  78373. * @param y defines y coordinate to test
  78374. * @returns true if the coordinates are inside the control
  78375. */
  78376. contains(x: number, y: number): boolean;
  78377. protected _getTypeName(): string;
  78378. /** Force the control to synchronize with its content */
  78379. synchronizeSizeWithContent(): void;
  78380. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78381. private _prepareWorkingCanvasForOpaqueDetection;
  78382. private _drawImage;
  78383. _draw(context: CanvasRenderingContext2D): void;
  78384. private _renderCornerPatch;
  78385. private _renderNinePatch;
  78386. dispose(): void;
  78387. /** STRETCH_NONE */
  78388. static readonly STRETCH_NONE: number;
  78389. /** STRETCH_FILL */
  78390. static readonly STRETCH_FILL: number;
  78391. /** STRETCH_UNIFORM */
  78392. static readonly STRETCH_UNIFORM: number;
  78393. /** STRETCH_EXTEND */
  78394. static readonly STRETCH_EXTEND: number;
  78395. /** NINE_PATCH */
  78396. static readonly STRETCH_NINE_PATCH: number;
  78397. }
  78398. }
  78399. declare module BABYLON.GUI {
  78400. /**
  78401. * Class used to create 2D buttons
  78402. */
  78403. export class Button extends Rectangle {
  78404. name?: string | undefined;
  78405. /**
  78406. * Function called to generate a pointer enter animation
  78407. */
  78408. pointerEnterAnimation: () => void;
  78409. /**
  78410. * Function called to generate a pointer out animation
  78411. */
  78412. pointerOutAnimation: () => void;
  78413. /**
  78414. * Function called to generate a pointer down animation
  78415. */
  78416. pointerDownAnimation: () => void;
  78417. /**
  78418. * Function called to generate a pointer up animation
  78419. */
  78420. pointerUpAnimation: () => void;
  78421. /**
  78422. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78423. */
  78424. delegatePickingToChildren: boolean;
  78425. private _image;
  78426. /**
  78427. * Returns the image part of the button (if any)
  78428. */
  78429. get image(): BABYLON.Nullable<Image>;
  78430. private _textBlock;
  78431. /**
  78432. * Returns the image part of the button (if any)
  78433. */
  78434. get textBlock(): BABYLON.Nullable<TextBlock>;
  78435. /**
  78436. * Creates a new Button
  78437. * @param name defines the name of the button
  78438. */
  78439. constructor(name?: string | undefined);
  78440. protected _getTypeName(): string;
  78441. /** @hidden */
  78442. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78443. /** @hidden */
  78444. _onPointerEnter(target: Control): boolean;
  78445. /** @hidden */
  78446. _onPointerOut(target: Control, force?: boolean): void;
  78447. /** @hidden */
  78448. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78449. /** @hidden */
  78450. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78451. /**
  78452. * Creates a new button made with an image and a text
  78453. * @param name defines the name of the button
  78454. * @param text defines the text of the button
  78455. * @param imageUrl defines the url of the image
  78456. * @returns a new Button
  78457. */
  78458. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78459. /**
  78460. * Creates a new button made with an image
  78461. * @param name defines the name of the button
  78462. * @param imageUrl defines the url of the image
  78463. * @returns a new Button
  78464. */
  78465. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78466. /**
  78467. * Creates a new button made with a text
  78468. * @param name defines the name of the button
  78469. * @param text defines the text of the button
  78470. * @returns a new Button
  78471. */
  78472. static CreateSimpleButton(name: string, text: string): Button;
  78473. /**
  78474. * Creates a new button made with an image and a centered text
  78475. * @param name defines the name of the button
  78476. * @param text defines the text of the button
  78477. * @param imageUrl defines the url of the image
  78478. * @returns a new Button
  78479. */
  78480. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78481. }
  78482. }
  78483. declare module BABYLON.GUI {
  78484. /**
  78485. * Class used to create a 2D stack panel container
  78486. */
  78487. export class StackPanel extends Container {
  78488. name?: string | undefined;
  78489. private _isVertical;
  78490. private _manualWidth;
  78491. private _manualHeight;
  78492. private _doNotTrackManualChanges;
  78493. /**
  78494. * Gets or sets a boolean indicating that layou warnings should be ignored
  78495. */
  78496. ignoreLayoutWarnings: boolean;
  78497. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78498. get isVertical(): boolean;
  78499. set isVertical(value: boolean);
  78500. /**
  78501. * Gets or sets panel width.
  78502. * This value should not be set when in horizontal mode as it will be computed automatically
  78503. */
  78504. set width(value: string | number);
  78505. get width(): string | number;
  78506. /**
  78507. * Gets or sets panel height.
  78508. * This value should not be set when in vertical mode as it will be computed automatically
  78509. */
  78510. set height(value: string | number);
  78511. get height(): string | number;
  78512. /**
  78513. * Creates a new StackPanel
  78514. * @param name defines control name
  78515. */
  78516. constructor(name?: string | undefined);
  78517. protected _getTypeName(): string;
  78518. /** @hidden */
  78519. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78520. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78521. protected _postMeasure(): void;
  78522. }
  78523. }
  78524. declare module BABYLON.GUI {
  78525. /**
  78526. * Class used to represent a 2D checkbox
  78527. */
  78528. export class Checkbox extends Control {
  78529. name?: string | undefined;
  78530. private _isChecked;
  78531. private _background;
  78532. private _checkSizeRatio;
  78533. private _thickness;
  78534. /** Gets or sets border thickness */
  78535. get thickness(): number;
  78536. set thickness(value: number);
  78537. /**
  78538. * BABYLON.Observable raised when isChecked property changes
  78539. */
  78540. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78541. /** Gets or sets a value indicating the ratio between overall size and check size */
  78542. get checkSizeRatio(): number;
  78543. set checkSizeRatio(value: number);
  78544. /** Gets or sets background color */
  78545. get background(): string;
  78546. set background(value: string);
  78547. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78548. get isChecked(): boolean;
  78549. set isChecked(value: boolean);
  78550. /**
  78551. * Creates a new CheckBox
  78552. * @param name defines the control name
  78553. */
  78554. constructor(name?: string | undefined);
  78555. protected _getTypeName(): string;
  78556. /** @hidden */
  78557. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78558. /** @hidden */
  78559. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78560. /**
  78561. * Utility function to easily create a checkbox with a header
  78562. * @param title defines the label to use for the header
  78563. * @param onValueChanged defines the callback to call when value changes
  78564. * @returns a StackPanel containing the checkbox and a textBlock
  78565. */
  78566. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78567. }
  78568. }
  78569. declare module BABYLON.GUI {
  78570. /**
  78571. * Class used to store key control properties
  78572. */
  78573. export class KeyPropertySet {
  78574. /** Width */
  78575. width?: string;
  78576. /** Height */
  78577. height?: string;
  78578. /** Left padding */
  78579. paddingLeft?: string;
  78580. /** Right padding */
  78581. paddingRight?: string;
  78582. /** Top padding */
  78583. paddingTop?: string;
  78584. /** Bottom padding */
  78585. paddingBottom?: string;
  78586. /** Foreground color */
  78587. color?: string;
  78588. /** Background color */
  78589. background?: string;
  78590. }
  78591. /**
  78592. * Class used to create virtual keyboard
  78593. */
  78594. export class VirtualKeyboard extends StackPanel {
  78595. /** BABYLON.Observable raised when a key is pressed */
  78596. onKeyPressObservable: BABYLON.Observable<string>;
  78597. /** Gets or sets default key button width */
  78598. defaultButtonWidth: string;
  78599. /** Gets or sets default key button height */
  78600. defaultButtonHeight: string;
  78601. /** Gets or sets default key button left padding */
  78602. defaultButtonPaddingLeft: string;
  78603. /** Gets or sets default key button right padding */
  78604. defaultButtonPaddingRight: string;
  78605. /** Gets or sets default key button top padding */
  78606. defaultButtonPaddingTop: string;
  78607. /** Gets or sets default key button bottom padding */
  78608. defaultButtonPaddingBottom: string;
  78609. /** Gets or sets default key button foreground color */
  78610. defaultButtonColor: string;
  78611. /** Gets or sets default key button background color */
  78612. defaultButtonBackground: string;
  78613. /** Gets or sets shift button foreground color */
  78614. shiftButtonColor: string;
  78615. /** Gets or sets shift button thickness*/
  78616. selectedShiftThickness: number;
  78617. /** Gets shift key state */
  78618. shiftState: number;
  78619. protected _getTypeName(): string;
  78620. private _createKey;
  78621. /**
  78622. * Adds a new row of keys
  78623. * @param keys defines the list of keys to add
  78624. * @param propertySets defines the associated property sets
  78625. */
  78626. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78627. /**
  78628. * Set the shift key to a specific state
  78629. * @param shiftState defines the new shift state
  78630. */
  78631. applyShiftState(shiftState: number): void;
  78632. private _currentlyConnectedInputText;
  78633. private _connectedInputTexts;
  78634. private _onKeyPressObserver;
  78635. /** Gets the input text control currently attached to the keyboard */
  78636. get connectedInputText(): BABYLON.Nullable<InputText>;
  78637. /**
  78638. * Connects the keyboard with an input text control
  78639. *
  78640. * @param input defines the target control
  78641. */
  78642. connect(input: InputText): void;
  78643. /**
  78644. * Disconnects the keyboard from connected InputText controls
  78645. *
  78646. * @param input optionally defines a target control, otherwise all are disconnected
  78647. */
  78648. disconnect(input?: InputText): void;
  78649. private _removeConnectedInputObservables;
  78650. /**
  78651. * Release all resources
  78652. */
  78653. dispose(): void;
  78654. /**
  78655. * Creates a new keyboard using a default layout
  78656. *
  78657. * @param name defines control name
  78658. * @returns a new VirtualKeyboard
  78659. */
  78660. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78661. }
  78662. }
  78663. declare module BABYLON.GUI {
  78664. /**
  78665. * Class used to create input text control
  78666. */
  78667. export class InputText extends Control implements IFocusableControl {
  78668. name?: string | undefined;
  78669. private _text;
  78670. private _placeholderText;
  78671. private _background;
  78672. private _focusedBackground;
  78673. private _focusedColor;
  78674. private _placeholderColor;
  78675. private _thickness;
  78676. private _margin;
  78677. private _autoStretchWidth;
  78678. private _maxWidth;
  78679. private _isFocused;
  78680. private _blinkTimeout;
  78681. private _blinkIsEven;
  78682. private _cursorOffset;
  78683. private _scrollLeft;
  78684. private _textWidth;
  78685. private _clickedCoordinate;
  78686. private _deadKey;
  78687. private _addKey;
  78688. private _currentKey;
  78689. private _isTextHighlightOn;
  78690. private _textHighlightColor;
  78691. private _highligherOpacity;
  78692. private _highlightedText;
  78693. private _startHighlightIndex;
  78694. private _endHighlightIndex;
  78695. private _cursorIndex;
  78696. private _onFocusSelectAll;
  78697. private _isPointerDown;
  78698. private _onClipboardObserver;
  78699. private _onPointerDblTapObserver;
  78700. /** @hidden */
  78701. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78702. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78703. promptMessage: string;
  78704. /** Force disable prompt on mobile device */
  78705. disableMobilePrompt: boolean;
  78706. /** BABYLON.Observable raised when the text changes */
  78707. onTextChangedObservable: BABYLON.Observable<InputText>;
  78708. /** BABYLON.Observable raised just before an entered character is to be added */
  78709. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78710. /** BABYLON.Observable raised when the control gets the focus */
  78711. onFocusObservable: BABYLON.Observable<InputText>;
  78712. /** BABYLON.Observable raised when the control loses the focus */
  78713. onBlurObservable: BABYLON.Observable<InputText>;
  78714. /**Observable raised when the text is highlighted */
  78715. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78716. /**Observable raised when copy event is triggered */
  78717. onTextCopyObservable: BABYLON.Observable<InputText>;
  78718. /** BABYLON.Observable raised when cut event is triggered */
  78719. onTextCutObservable: BABYLON.Observable<InputText>;
  78720. /** BABYLON.Observable raised when paste event is triggered */
  78721. onTextPasteObservable: BABYLON.Observable<InputText>;
  78722. /** BABYLON.Observable raised when a key event was processed */
  78723. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78724. /** Gets or sets the maximum width allowed by the control */
  78725. get maxWidth(): string | number;
  78726. /** Gets the maximum width allowed by the control in pixels */
  78727. get maxWidthInPixels(): number;
  78728. set maxWidth(value: string | number);
  78729. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78730. get highligherOpacity(): number;
  78731. set highligherOpacity(value: number);
  78732. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78733. get onFocusSelectAll(): boolean;
  78734. set onFocusSelectAll(value: boolean);
  78735. /** Gets or sets the text hightlight color */
  78736. get textHighlightColor(): string;
  78737. set textHighlightColor(value: string);
  78738. /** Gets or sets control margin */
  78739. get margin(): string;
  78740. /** Gets control margin in pixels */
  78741. get marginInPixels(): number;
  78742. set margin(value: string);
  78743. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78744. get autoStretchWidth(): boolean;
  78745. set autoStretchWidth(value: boolean);
  78746. /** Gets or sets border thickness */
  78747. get thickness(): number;
  78748. set thickness(value: number);
  78749. /** Gets or sets the background color when focused */
  78750. get focusedBackground(): string;
  78751. set focusedBackground(value: string);
  78752. /** Gets or sets the background color when focused */
  78753. get focusedColor(): string;
  78754. set focusedColor(value: string);
  78755. /** Gets or sets the background color */
  78756. get background(): string;
  78757. set background(value: string);
  78758. /** Gets or sets the placeholder color */
  78759. get placeholderColor(): string;
  78760. set placeholderColor(value: string);
  78761. /** Gets or sets the text displayed when the control is empty */
  78762. get placeholderText(): string;
  78763. set placeholderText(value: string);
  78764. /** Gets or sets the dead key flag */
  78765. get deadKey(): boolean;
  78766. set deadKey(flag: boolean);
  78767. /** Gets or sets the highlight text */
  78768. get highlightedText(): string;
  78769. set highlightedText(text: string);
  78770. /** Gets or sets if the current key should be added */
  78771. get addKey(): boolean;
  78772. set addKey(flag: boolean);
  78773. /** Gets or sets the value of the current key being entered */
  78774. get currentKey(): string;
  78775. set currentKey(key: string);
  78776. /** Gets or sets the text displayed in the control */
  78777. get text(): string;
  78778. set text(value: string);
  78779. /** Gets or sets control width */
  78780. get width(): string | number;
  78781. set width(value: string | number);
  78782. /**
  78783. * Creates a new InputText
  78784. * @param name defines the control name
  78785. * @param text defines the text of the control
  78786. */
  78787. constructor(name?: string | undefined, text?: string);
  78788. /** @hidden */
  78789. onBlur(): void;
  78790. /** @hidden */
  78791. onFocus(): void;
  78792. protected _getTypeName(): string;
  78793. /**
  78794. * Function called to get the list of controls that should not steal the focus from this control
  78795. * @returns an array of controls
  78796. */
  78797. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78798. /** @hidden */
  78799. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78800. /** @hidden */
  78801. private _updateValueFromCursorIndex;
  78802. /** @hidden */
  78803. private _processDblClick;
  78804. /** @hidden */
  78805. private _selectAllText;
  78806. /**
  78807. * Handles the keyboard event
  78808. * @param evt Defines the KeyboardEvent
  78809. */
  78810. processKeyboard(evt: KeyboardEvent): void;
  78811. /** @hidden */
  78812. private _onCopyText;
  78813. /** @hidden */
  78814. private _onCutText;
  78815. /** @hidden */
  78816. private _onPasteText;
  78817. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78818. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78819. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78820. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78821. protected _beforeRenderText(text: string): string;
  78822. dispose(): void;
  78823. }
  78824. }
  78825. declare module BABYLON.GUI {
  78826. /**
  78827. * Class used to create a 2D grid container
  78828. */
  78829. export class Grid extends Container {
  78830. name?: string | undefined;
  78831. private _rowDefinitions;
  78832. private _columnDefinitions;
  78833. private _cells;
  78834. private _childControls;
  78835. /**
  78836. * Gets the number of columns
  78837. */
  78838. get columnCount(): number;
  78839. /**
  78840. * Gets the number of rows
  78841. */
  78842. get rowCount(): number;
  78843. /** Gets the list of children */
  78844. get children(): Control[];
  78845. /** Gets the list of cells (e.g. the containers) */
  78846. get cells(): {
  78847. [key: string]: Container;
  78848. };
  78849. /**
  78850. * Gets the definition of a specific row
  78851. * @param index defines the index of the row
  78852. * @returns the row definition
  78853. */
  78854. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78855. /**
  78856. * Gets the definition of a specific column
  78857. * @param index defines the index of the column
  78858. * @returns the column definition
  78859. */
  78860. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78861. /**
  78862. * Adds a new row to the grid
  78863. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78864. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78865. * @returns the current grid
  78866. */
  78867. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78868. /**
  78869. * Adds a new column to the grid
  78870. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78871. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78872. * @returns the current grid
  78873. */
  78874. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78875. /**
  78876. * Update a row definition
  78877. * @param index defines the index of the row to update
  78878. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78879. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78880. * @returns the current grid
  78881. */
  78882. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78883. /**
  78884. * Update a column definition
  78885. * @param index defines the index of the column to update
  78886. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78887. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78888. * @returns the current grid
  78889. */
  78890. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78891. /**
  78892. * Gets the list of children stored in a specific cell
  78893. * @param row defines the row to check
  78894. * @param column defines the column to check
  78895. * @returns the list of controls
  78896. */
  78897. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78898. /**
  78899. * Gets a string representing the child cell info (row x column)
  78900. * @param child defines the control to get info from
  78901. * @returns a string containing the child cell info (row x column)
  78902. */
  78903. getChildCellInfo(child: Control): string;
  78904. private _removeCell;
  78905. private _offsetCell;
  78906. /**
  78907. * Remove a column definition at specified index
  78908. * @param index defines the index of the column to remove
  78909. * @returns the current grid
  78910. */
  78911. removeColumnDefinition(index: number): Grid;
  78912. /**
  78913. * Remove a row definition at specified index
  78914. * @param index defines the index of the row to remove
  78915. * @returns the current grid
  78916. */
  78917. removeRowDefinition(index: number): Grid;
  78918. /**
  78919. * Adds a new control to the current grid
  78920. * @param control defines the control to add
  78921. * @param row defines the row where to add the control (0 by default)
  78922. * @param column defines the column where to add the control (0 by default)
  78923. * @returns the current grid
  78924. */
  78925. addControl(control: Control, row?: number, column?: number): Grid;
  78926. /**
  78927. * Removes a control from the current container
  78928. * @param control defines the control to remove
  78929. * @returns the current container
  78930. */
  78931. removeControl(control: Control): Container;
  78932. /**
  78933. * Creates a new Grid
  78934. * @param name defines control name
  78935. */
  78936. constructor(name?: string | undefined);
  78937. protected _getTypeName(): string;
  78938. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78939. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78940. _flagDescendantsAsMatrixDirty(): void;
  78941. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78942. /** Releases associated resources */
  78943. dispose(): void;
  78944. }
  78945. }
  78946. declare module BABYLON.GUI {
  78947. /** Class used to create color pickers */
  78948. export class ColorPicker extends Control {
  78949. name?: string | undefined;
  78950. private static _Epsilon;
  78951. private _colorWheelCanvas;
  78952. private _value;
  78953. private _tmpColor;
  78954. private _pointerStartedOnSquare;
  78955. private _pointerStartedOnWheel;
  78956. private _squareLeft;
  78957. private _squareTop;
  78958. private _squareSize;
  78959. private _h;
  78960. private _s;
  78961. private _v;
  78962. private _lastPointerDownID;
  78963. /**
  78964. * BABYLON.Observable raised when the value changes
  78965. */
  78966. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78967. /** Gets or sets the color of the color picker */
  78968. get value(): BABYLON.Color3;
  78969. set value(value: BABYLON.Color3);
  78970. /**
  78971. * Gets or sets control width
  78972. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78973. */
  78974. get width(): string | number;
  78975. set width(value: string | number);
  78976. /**
  78977. * Gets or sets control height
  78978. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78979. */
  78980. get height(): string | number;
  78981. /** Gets or sets control height */
  78982. set height(value: string | number);
  78983. /** Gets or sets control size */
  78984. get size(): string | number;
  78985. set size(value: string | number);
  78986. /**
  78987. * Creates a new ColorPicker
  78988. * @param name defines the control name
  78989. */
  78990. constructor(name?: string | undefined);
  78991. protected _getTypeName(): string;
  78992. /** @hidden */
  78993. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78994. private _updateSquareProps;
  78995. private _drawGradientSquare;
  78996. private _drawCircle;
  78997. private _createColorWheelCanvas;
  78998. /** @hidden */
  78999. _draw(context: CanvasRenderingContext2D): void;
  79000. private _pointerIsDown;
  79001. private _updateValueFromPointer;
  79002. private _isPointOnSquare;
  79003. private _isPointOnWheel;
  79004. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79005. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79006. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79007. _onCanvasBlur(): void;
  79008. /**
  79009. * This function expands the color picker by creating a color picker dialog with manual
  79010. * color value input and the ability to save colors into an array to be used later in
  79011. * subsequent launches of the dialogue.
  79012. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79013. * @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.
  79014. * @returns picked color as a hex string and the saved colors array as hex strings.
  79015. */
  79016. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79017. pickerWidth?: string;
  79018. pickerHeight?: string;
  79019. headerHeight?: string;
  79020. lastColor?: string;
  79021. swatchLimit?: number;
  79022. numSwatchesPerLine?: number;
  79023. savedColors?: Array<string>;
  79024. }): Promise<{
  79025. savedColors?: string[];
  79026. pickedColor: string;
  79027. }>;
  79028. }
  79029. }
  79030. declare module BABYLON.GUI {
  79031. /** Class used to create 2D ellipse containers */
  79032. export class Ellipse extends Container {
  79033. name?: string | undefined;
  79034. private _thickness;
  79035. /** Gets or sets border thickness */
  79036. get thickness(): number;
  79037. set thickness(value: number);
  79038. /**
  79039. * Creates a new Ellipse
  79040. * @param name defines the control name
  79041. */
  79042. constructor(name?: string | undefined);
  79043. protected _getTypeName(): string;
  79044. protected _localDraw(context: CanvasRenderingContext2D): void;
  79045. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79046. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79047. }
  79048. }
  79049. declare module BABYLON.GUI {
  79050. /**
  79051. * Class used to create a password control
  79052. */
  79053. export class InputPassword extends InputText {
  79054. protected _beforeRenderText(text: string): string;
  79055. }
  79056. }
  79057. declare module BABYLON.GUI {
  79058. /** Class used to render 2D lines */
  79059. export class Line extends Control {
  79060. name?: string | undefined;
  79061. private _lineWidth;
  79062. private _x1;
  79063. private _y1;
  79064. private _x2;
  79065. private _y2;
  79066. private _dash;
  79067. private _connectedControl;
  79068. private _connectedControlDirtyObserver;
  79069. /** Gets or sets the dash pattern */
  79070. get dash(): Array<number>;
  79071. set dash(value: Array<number>);
  79072. /** Gets or sets the control connected with the line end */
  79073. get connectedControl(): Control;
  79074. set connectedControl(value: Control);
  79075. /** Gets or sets start coordinates on X axis */
  79076. get x1(): string | number;
  79077. set x1(value: string | number);
  79078. /** Gets or sets start coordinates on Y axis */
  79079. get y1(): string | number;
  79080. set y1(value: string | number);
  79081. /** Gets or sets end coordinates on X axis */
  79082. get x2(): string | number;
  79083. set x2(value: string | number);
  79084. /** Gets or sets end coordinates on Y axis */
  79085. get y2(): string | number;
  79086. set y2(value: string | number);
  79087. /** Gets or sets line width */
  79088. get lineWidth(): number;
  79089. set lineWidth(value: number);
  79090. /** Gets or sets horizontal alignment */
  79091. set horizontalAlignment(value: number);
  79092. /** Gets or sets vertical alignment */
  79093. set verticalAlignment(value: number);
  79094. private get _effectiveX2();
  79095. private get _effectiveY2();
  79096. /**
  79097. * Creates a new Line
  79098. * @param name defines the control name
  79099. */
  79100. constructor(name?: string | undefined);
  79101. protected _getTypeName(): string;
  79102. _draw(context: CanvasRenderingContext2D): void;
  79103. _measure(): void;
  79104. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79105. /**
  79106. * Move one end of the line given 3D cartesian coordinates.
  79107. * @param position Targeted world position
  79108. * @param scene BABYLON.Scene
  79109. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79110. */
  79111. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79112. /**
  79113. * Move one end of the line to a position in screen absolute space.
  79114. * @param projectedPosition Position in screen absolute space (X, Y)
  79115. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79116. */
  79117. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79118. }
  79119. }
  79120. declare module BABYLON.GUI {
  79121. /**
  79122. * Class used to store a point for a MultiLine object.
  79123. * The point can be pure 2D coordinates, a mesh or a control
  79124. */
  79125. export class MultiLinePoint {
  79126. private _multiLine;
  79127. private _x;
  79128. private _y;
  79129. private _control;
  79130. private _mesh;
  79131. private _controlObserver;
  79132. private _meshObserver;
  79133. /** @hidden */
  79134. _point: BABYLON.Vector2;
  79135. /**
  79136. * Creates a new MultiLinePoint
  79137. * @param multiLine defines the source MultiLine object
  79138. */
  79139. constructor(multiLine: MultiLine);
  79140. /** Gets or sets x coordinate */
  79141. get x(): string | number;
  79142. set x(value: string | number);
  79143. /** Gets or sets y coordinate */
  79144. get y(): string | number;
  79145. set y(value: string | number);
  79146. /** Gets or sets the control associated with this point */
  79147. get control(): BABYLON.Nullable<Control>;
  79148. set control(value: BABYLON.Nullable<Control>);
  79149. /** Gets or sets the mesh associated with this point */
  79150. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79151. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79152. /** Resets links */
  79153. resetLinks(): void;
  79154. /**
  79155. * Gets a translation vector
  79156. * @returns the translation vector
  79157. */
  79158. translate(): BABYLON.Vector2;
  79159. private _translatePoint;
  79160. /** Release associated resources */
  79161. dispose(): void;
  79162. }
  79163. }
  79164. declare module BABYLON.GUI {
  79165. /**
  79166. * Class used to create multi line control
  79167. */
  79168. export class MultiLine extends Control {
  79169. name?: string | undefined;
  79170. private _lineWidth;
  79171. private _dash;
  79172. private _points;
  79173. private _minX;
  79174. private _minY;
  79175. private _maxX;
  79176. private _maxY;
  79177. /**
  79178. * Creates a new MultiLine
  79179. * @param name defines the control name
  79180. */
  79181. constructor(name?: string | undefined);
  79182. /** Gets or sets dash pattern */
  79183. get dash(): Array<number>;
  79184. set dash(value: Array<number>);
  79185. /**
  79186. * Gets point stored at specified index
  79187. * @param index defines the index to look for
  79188. * @returns the requested point if found
  79189. */
  79190. getAt(index: number): MultiLinePoint;
  79191. /** Function called when a point is updated */
  79192. onPointUpdate: () => void;
  79193. /**
  79194. * Adds new points to the point collection
  79195. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79196. * @returns the list of created MultiLinePoint
  79197. */
  79198. add(...items: (AbstractMesh | Control | {
  79199. x: string | number;
  79200. y: string | number;
  79201. })[]): MultiLinePoint[];
  79202. /**
  79203. * Adds a new point to the point collection
  79204. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79205. * @returns the created MultiLinePoint
  79206. */
  79207. push(item?: (AbstractMesh | Control | {
  79208. x: string | number;
  79209. y: string | number;
  79210. })): MultiLinePoint;
  79211. /**
  79212. * Remove a specific value or point from the active point collection
  79213. * @param value defines the value or point to remove
  79214. */
  79215. remove(value: number | MultiLinePoint): void;
  79216. /**
  79217. * Resets this object to initial state (no point)
  79218. */
  79219. reset(): void;
  79220. /**
  79221. * Resets all links
  79222. */
  79223. resetLinks(): void;
  79224. /** Gets or sets line width */
  79225. get lineWidth(): number;
  79226. set lineWidth(value: number);
  79227. set horizontalAlignment(value: number);
  79228. set verticalAlignment(value: number);
  79229. protected _getTypeName(): string;
  79230. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79231. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79232. _measure(): void;
  79233. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79234. dispose(): void;
  79235. }
  79236. }
  79237. declare module BABYLON.GUI {
  79238. /**
  79239. * Class used to create radio button controls
  79240. */
  79241. export class RadioButton extends Control {
  79242. name?: string | undefined;
  79243. private _isChecked;
  79244. private _background;
  79245. private _checkSizeRatio;
  79246. private _thickness;
  79247. /** Gets or sets border thickness */
  79248. get thickness(): number;
  79249. set thickness(value: number);
  79250. /** Gets or sets group name */
  79251. group: string;
  79252. /** BABYLON.Observable raised when isChecked is changed */
  79253. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79254. /** Gets or sets a value indicating the ratio between overall size and check size */
  79255. get checkSizeRatio(): number;
  79256. set checkSizeRatio(value: number);
  79257. /** Gets or sets background color */
  79258. get background(): string;
  79259. set background(value: string);
  79260. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79261. get isChecked(): boolean;
  79262. set isChecked(value: boolean);
  79263. /**
  79264. * Creates a new RadioButton
  79265. * @param name defines the control name
  79266. */
  79267. constructor(name?: string | undefined);
  79268. protected _getTypeName(): string;
  79269. _draw(context: CanvasRenderingContext2D): void;
  79270. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79271. /**
  79272. * Utility function to easily create a radio button with a header
  79273. * @param title defines the label to use for the header
  79274. * @param group defines the group to use for the radio button
  79275. * @param isChecked defines the initial state of the radio button
  79276. * @param onValueChanged defines the callback to call when value changes
  79277. * @returns a StackPanel containing the radio button and a textBlock
  79278. */
  79279. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79280. }
  79281. }
  79282. declare module BABYLON.GUI {
  79283. /**
  79284. * Class used to create slider controls
  79285. */
  79286. export class BaseSlider extends Control {
  79287. name?: string | undefined;
  79288. protected _thumbWidth: ValueAndUnit;
  79289. private _minimum;
  79290. private _maximum;
  79291. private _value;
  79292. private _isVertical;
  79293. protected _barOffset: ValueAndUnit;
  79294. private _isThumbClamped;
  79295. protected _displayThumb: boolean;
  79296. private _step;
  79297. private _lastPointerDownID;
  79298. protected _effectiveBarOffset: number;
  79299. protected _renderLeft: number;
  79300. protected _renderTop: number;
  79301. protected _renderWidth: number;
  79302. protected _renderHeight: number;
  79303. protected _backgroundBoxLength: number;
  79304. protected _backgroundBoxThickness: number;
  79305. protected _effectiveThumbThickness: number;
  79306. /** BABYLON.Observable raised when the sldier value changes */
  79307. onValueChangedObservable: BABYLON.Observable<number>;
  79308. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79309. get displayThumb(): boolean;
  79310. set displayThumb(value: boolean);
  79311. /** Gets or sets a step to apply to values (0 by default) */
  79312. get step(): number;
  79313. set step(value: number);
  79314. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79315. get barOffset(): string | number;
  79316. /** Gets main bar offset in pixels*/
  79317. get barOffsetInPixels(): number;
  79318. set barOffset(value: string | number);
  79319. /** Gets or sets thumb width */
  79320. get thumbWidth(): string | number;
  79321. /** Gets thumb width in pixels */
  79322. get thumbWidthInPixels(): number;
  79323. set thumbWidth(value: string | number);
  79324. /** Gets or sets minimum value */
  79325. get minimum(): number;
  79326. set minimum(value: number);
  79327. /** Gets or sets maximum value */
  79328. get maximum(): number;
  79329. set maximum(value: number);
  79330. /** Gets or sets current value */
  79331. get value(): number;
  79332. set value(value: number);
  79333. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79334. get isVertical(): boolean;
  79335. set isVertical(value: boolean);
  79336. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79337. get isThumbClamped(): boolean;
  79338. set isThumbClamped(value: boolean);
  79339. /**
  79340. * Creates a new BaseSlider
  79341. * @param name defines the control name
  79342. */
  79343. constructor(name?: string | undefined);
  79344. protected _getTypeName(): string;
  79345. protected _getThumbPosition(): number;
  79346. protected _getThumbThickness(type: string): number;
  79347. protected _prepareRenderingData(type: string): void;
  79348. private _pointerIsDown;
  79349. /** @hidden */
  79350. protected _updateValueFromPointer(x: number, y: number): void;
  79351. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79352. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79353. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79354. _onCanvasBlur(): void;
  79355. }
  79356. }
  79357. declare module BABYLON.GUI {
  79358. /**
  79359. * Class used to create slider controls
  79360. */
  79361. export class Slider extends BaseSlider {
  79362. name?: string | undefined;
  79363. private _background;
  79364. private _borderColor;
  79365. private _thumbColor;
  79366. private _isThumbCircle;
  79367. protected _displayValueBar: boolean;
  79368. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79369. get displayValueBar(): boolean;
  79370. set displayValueBar(value: boolean);
  79371. /** Gets or sets border color */
  79372. get borderColor(): string;
  79373. set borderColor(value: string);
  79374. /** Gets or sets background color */
  79375. get background(): string;
  79376. set background(value: string);
  79377. /** Gets or sets thumb's color */
  79378. get thumbColor(): string;
  79379. set thumbColor(value: string);
  79380. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79381. get isThumbCircle(): boolean;
  79382. set isThumbCircle(value: boolean);
  79383. /**
  79384. * Creates a new Slider
  79385. * @param name defines the control name
  79386. */
  79387. constructor(name?: string | undefined);
  79388. protected _getTypeName(): string;
  79389. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79390. }
  79391. }
  79392. declare module BABYLON.GUI {
  79393. /** Class used to create a RadioGroup
  79394. * which contains groups of radio buttons
  79395. */
  79396. export class SelectorGroup {
  79397. /** name of SelectorGroup */
  79398. name: string;
  79399. private _groupPanel;
  79400. private _selectors;
  79401. private _groupHeader;
  79402. /**
  79403. * Creates a new SelectorGroup
  79404. * @param name of group, used as a group heading
  79405. */
  79406. constructor(
  79407. /** name of SelectorGroup */
  79408. name: string);
  79409. /** Gets the groupPanel of the SelectorGroup */
  79410. get groupPanel(): StackPanel;
  79411. /** Gets the selectors array */
  79412. get selectors(): StackPanel[];
  79413. /** Gets and sets the group header */
  79414. get header(): string;
  79415. set header(label: string);
  79416. /** @hidden */
  79417. private _addGroupHeader;
  79418. /** @hidden*/
  79419. _getSelector(selectorNb: number): StackPanel | undefined;
  79420. /** Removes the selector at the given position
  79421. * @param selectorNb the position of the selector within the group
  79422. */
  79423. removeSelector(selectorNb: number): void;
  79424. }
  79425. /** Class used to create a CheckboxGroup
  79426. * which contains groups of checkbox buttons
  79427. */
  79428. export class CheckboxGroup extends SelectorGroup {
  79429. /** Adds a checkbox as a control
  79430. * @param text is the label for the selector
  79431. * @param func is the function called when the Selector is checked
  79432. * @param checked is true when Selector is checked
  79433. */
  79434. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79435. /** @hidden */
  79436. _setSelectorLabel(selectorNb: number, label: string): void;
  79437. /** @hidden */
  79438. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79439. /** @hidden */
  79440. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79441. /** @hidden */
  79442. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79443. }
  79444. /** Class used to create a RadioGroup
  79445. * which contains groups of radio buttons
  79446. */
  79447. export class RadioGroup extends SelectorGroup {
  79448. private _selectNb;
  79449. /** Adds a radio button as a control
  79450. * @param label is the label for the selector
  79451. * @param func is the function called when the Selector is checked
  79452. * @param checked is true when Selector is checked
  79453. */
  79454. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79455. /** @hidden */
  79456. _setSelectorLabel(selectorNb: number, label: string): void;
  79457. /** @hidden */
  79458. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79459. /** @hidden */
  79460. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79461. /** @hidden */
  79462. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79463. }
  79464. /** Class used to create a SliderGroup
  79465. * which contains groups of slider buttons
  79466. */
  79467. export class SliderGroup extends SelectorGroup {
  79468. /**
  79469. * Adds a slider to the SelectorGroup
  79470. * @param label is the label for the SliderBar
  79471. * @param func is the function called when the Slider moves
  79472. * @param unit is a string describing the units used, eg degrees or metres
  79473. * @param min is the minimum value for the Slider
  79474. * @param max is the maximum value for the Slider
  79475. * @param value is the start value for the Slider between min and max
  79476. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79477. */
  79478. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79479. /** @hidden */
  79480. _setSelectorLabel(selectorNb: number, label: string): void;
  79481. /** @hidden */
  79482. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79483. /** @hidden */
  79484. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79485. /** @hidden */
  79486. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79487. }
  79488. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79489. * @see https://doc.babylonjs.com/how_to/selector
  79490. */
  79491. export class SelectionPanel extends Rectangle {
  79492. /** name of SelectionPanel */
  79493. name: string;
  79494. /** an array of SelectionGroups */
  79495. groups: SelectorGroup[];
  79496. private _panel;
  79497. private _buttonColor;
  79498. private _buttonBackground;
  79499. private _headerColor;
  79500. private _barColor;
  79501. private _barHeight;
  79502. private _spacerHeight;
  79503. private _labelColor;
  79504. private _groups;
  79505. private _bars;
  79506. /**
  79507. * Creates a new SelectionPanel
  79508. * @param name of SelectionPanel
  79509. * @param groups is an array of SelectionGroups
  79510. */
  79511. constructor(
  79512. /** name of SelectionPanel */
  79513. name: string,
  79514. /** an array of SelectionGroups */
  79515. groups?: SelectorGroup[]);
  79516. protected _getTypeName(): string;
  79517. /** Gets the (stack) panel of the SelectionPanel */
  79518. get panel(): StackPanel;
  79519. /** Gets or sets the headerColor */
  79520. get headerColor(): string;
  79521. set headerColor(color: string);
  79522. private _setHeaderColor;
  79523. /** Gets or sets the button color */
  79524. get buttonColor(): string;
  79525. set buttonColor(color: string);
  79526. private _setbuttonColor;
  79527. /** Gets or sets the label color */
  79528. get labelColor(): string;
  79529. set labelColor(color: string);
  79530. private _setLabelColor;
  79531. /** Gets or sets the button background */
  79532. get buttonBackground(): string;
  79533. set buttonBackground(color: string);
  79534. private _setButtonBackground;
  79535. /** Gets or sets the color of separator bar */
  79536. get barColor(): string;
  79537. set barColor(color: string);
  79538. private _setBarColor;
  79539. /** Gets or sets the height of separator bar */
  79540. get barHeight(): string;
  79541. set barHeight(value: string);
  79542. private _setBarHeight;
  79543. /** Gets or sets the height of spacers*/
  79544. get spacerHeight(): string;
  79545. set spacerHeight(value: string);
  79546. private _setSpacerHeight;
  79547. /** Adds a bar between groups */
  79548. private _addSpacer;
  79549. /** Add a group to the selection panel
  79550. * @param group is the selector group to add
  79551. */
  79552. addGroup(group: SelectorGroup): void;
  79553. /** Remove the group from the given position
  79554. * @param groupNb is the position of the group in the list
  79555. */
  79556. removeGroup(groupNb: number): void;
  79557. /** Change a group header label
  79558. * @param label is the new group header label
  79559. * @param groupNb is the number of the group to relabel
  79560. * */
  79561. setHeaderName(label: string, groupNb: number): void;
  79562. /** Change selector label to the one given
  79563. * @param label is the new selector label
  79564. * @param groupNb is the number of the groupcontaining the selector
  79565. * @param selectorNb is the number of the selector within a group to relabel
  79566. * */
  79567. relabel(label: string, groupNb: number, selectorNb: number): void;
  79568. /** For a given group position remove the selector at the given position
  79569. * @param groupNb is the number of the group to remove the selector from
  79570. * @param selectorNb is the number of the selector within the group
  79571. */
  79572. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79573. /** For a given group position of correct type add a checkbox button
  79574. * @param groupNb is the number of the group to remove the selector from
  79575. * @param label is the label for the selector
  79576. * @param func is the function called when the Selector is checked
  79577. * @param checked is true when Selector is checked
  79578. */
  79579. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79580. /** For a given group position of correct type add a radio button
  79581. * @param groupNb is the number of the group to remove the selector from
  79582. * @param label is the label for the selector
  79583. * @param func is the function called when the Selector is checked
  79584. * @param checked is true when Selector is checked
  79585. */
  79586. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79587. /**
  79588. * For a given slider group add a slider
  79589. * @param groupNb is the number of the group to add the slider to
  79590. * @param label is the label for the Slider
  79591. * @param func is the function called when the Slider moves
  79592. * @param unit is a string describing the units used, eg degrees or metres
  79593. * @param min is the minimum value for the Slider
  79594. * @param max is the maximum value for the Slider
  79595. * @param value is the start value for the Slider between min and max
  79596. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79597. */
  79598. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79599. }
  79600. }
  79601. declare module BABYLON.GUI {
  79602. /**
  79603. * Class used to hold a the container for ScrollViewer
  79604. * @hidden
  79605. */
  79606. export class _ScrollViewerWindow extends Container {
  79607. parentClientWidth: number;
  79608. parentClientHeight: number;
  79609. private _freezeControls;
  79610. private _parentMeasure;
  79611. private _oldLeft;
  79612. private _oldTop;
  79613. get freezeControls(): boolean;
  79614. set freezeControls(value: boolean);
  79615. private _bucketWidth;
  79616. private _bucketHeight;
  79617. private _buckets;
  79618. private _bucketLen;
  79619. get bucketWidth(): number;
  79620. get bucketHeight(): number;
  79621. setBucketSizes(width: number, height: number): void;
  79622. private _useBuckets;
  79623. private _makeBuckets;
  79624. private _dispatchInBuckets;
  79625. private _updateMeasures;
  79626. private _updateChildrenMeasures;
  79627. private _restoreMeasures;
  79628. /**
  79629. * Creates a new ScrollViewerWindow
  79630. * @param name of ScrollViewerWindow
  79631. */
  79632. constructor(name?: string);
  79633. protected _getTypeName(): string;
  79634. /** @hidden */
  79635. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79636. /** @hidden */
  79637. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79638. private _scrollChildren;
  79639. private _scrollChildrenWithBuckets;
  79640. /** @hidden */
  79641. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79642. protected _postMeasure(): void;
  79643. }
  79644. }
  79645. declare module BABYLON.GUI {
  79646. /**
  79647. * Class used to create slider controls
  79648. */
  79649. export class ScrollBar extends BaseSlider {
  79650. name?: string | undefined;
  79651. private _background;
  79652. private _borderColor;
  79653. private _tempMeasure;
  79654. /** Gets or sets border color */
  79655. get borderColor(): string;
  79656. set borderColor(value: string);
  79657. /** Gets or sets background color */
  79658. get background(): string;
  79659. set background(value: string);
  79660. /**
  79661. * Creates a new Slider
  79662. * @param name defines the control name
  79663. */
  79664. constructor(name?: string | undefined);
  79665. protected _getTypeName(): string;
  79666. protected _getThumbThickness(): number;
  79667. _draw(context: CanvasRenderingContext2D): void;
  79668. private _first;
  79669. private _originX;
  79670. private _originY;
  79671. /** @hidden */
  79672. protected _updateValueFromPointer(x: number, y: number): void;
  79673. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79674. }
  79675. }
  79676. declare module BABYLON.GUI {
  79677. /**
  79678. * Class used to create slider controls
  79679. */
  79680. export class ImageScrollBar extends BaseSlider {
  79681. name?: string | undefined;
  79682. private _backgroundBaseImage;
  79683. private _backgroundImage;
  79684. private _thumbImage;
  79685. private _thumbBaseImage;
  79686. private _thumbLength;
  79687. private _thumbHeight;
  79688. private _barImageHeight;
  79689. private _tempMeasure;
  79690. /** Number of 90° rotation to apply on the images when in vertical mode */
  79691. num90RotationInVerticalMode: number;
  79692. /**
  79693. * Gets or sets the image used to render the background for horizontal bar
  79694. */
  79695. get backgroundImage(): Image;
  79696. set backgroundImage(value: Image);
  79697. /**
  79698. * Gets or sets the image used to render the thumb
  79699. */
  79700. get thumbImage(): Image;
  79701. set thumbImage(value: Image);
  79702. /**
  79703. * Gets or sets the length of the thumb
  79704. */
  79705. get thumbLength(): number;
  79706. set thumbLength(value: number);
  79707. /**
  79708. * Gets or sets the height of the thumb
  79709. */
  79710. get thumbHeight(): number;
  79711. set thumbHeight(value: number);
  79712. /**
  79713. * Gets or sets the height of the bar image
  79714. */
  79715. get barImageHeight(): number;
  79716. set barImageHeight(value: number);
  79717. /**
  79718. * Creates a new ImageScrollBar
  79719. * @param name defines the control name
  79720. */
  79721. constructor(name?: string | undefined);
  79722. protected _getTypeName(): string;
  79723. protected _getThumbThickness(): number;
  79724. _draw(context: CanvasRenderingContext2D): void;
  79725. private _first;
  79726. private _originX;
  79727. private _originY;
  79728. /** @hidden */
  79729. protected _updateValueFromPointer(x: number, y: number): void;
  79730. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79731. }
  79732. }
  79733. declare module BABYLON.GUI {
  79734. /**
  79735. * Class used to hold a viewer window and sliders in a grid
  79736. */
  79737. export class ScrollViewer extends Rectangle {
  79738. private _grid;
  79739. private _horizontalBarSpace;
  79740. private _verticalBarSpace;
  79741. private _dragSpace;
  79742. private _horizontalBar;
  79743. private _verticalBar;
  79744. private _barColor;
  79745. private _barBackground;
  79746. private _barImage;
  79747. private _horizontalBarImage;
  79748. private _verticalBarImage;
  79749. private _barBackgroundImage;
  79750. private _horizontalBarBackgroundImage;
  79751. private _verticalBarBackgroundImage;
  79752. private _barSize;
  79753. private _window;
  79754. private _pointerIsOver;
  79755. private _wheelPrecision;
  79756. private _onWheelObserver;
  79757. private _clientWidth;
  79758. private _clientHeight;
  79759. private _useImageBar;
  79760. private _thumbLength;
  79761. private _thumbHeight;
  79762. private _barImageHeight;
  79763. private _horizontalBarImageHeight;
  79764. private _verticalBarImageHeight;
  79765. private _oldWindowContentsWidth;
  79766. private _oldWindowContentsHeight;
  79767. /**
  79768. * Gets the horizontal scrollbar
  79769. */
  79770. get horizontalBar(): ScrollBar | ImageScrollBar;
  79771. /**
  79772. * Gets the vertical scrollbar
  79773. */
  79774. get verticalBar(): ScrollBar | ImageScrollBar;
  79775. /**
  79776. * Adds a new control to the current container
  79777. * @param control defines the control to add
  79778. * @returns the current container
  79779. */
  79780. addControl(control: BABYLON.Nullable<Control>): Container;
  79781. /**
  79782. * Removes a control from the current container
  79783. * @param control defines the control to remove
  79784. * @returns the current container
  79785. */
  79786. removeControl(control: Control): Container;
  79787. /** Gets the list of children */
  79788. get children(): Control[];
  79789. _flagDescendantsAsMatrixDirty(): void;
  79790. /**
  79791. * Freezes or unfreezes the controls in the window.
  79792. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79793. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79794. */
  79795. get freezeControls(): boolean;
  79796. set freezeControls(value: boolean);
  79797. /** Gets the bucket width */
  79798. get bucketWidth(): number;
  79799. /** Gets the bucket height */
  79800. get bucketHeight(): number;
  79801. /**
  79802. * Sets the bucket sizes.
  79803. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79804. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79805. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79806. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79807. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79808. * used), that's why it is not enabled by default.
  79809. * @param width width of the bucket
  79810. * @param height height of the bucket
  79811. */
  79812. setBucketSizes(width: number, height: number): void;
  79813. private _forceHorizontalBar;
  79814. private _forceVerticalBar;
  79815. /**
  79816. * Forces the horizontal scroll bar to be displayed
  79817. */
  79818. get forceHorizontalBar(): boolean;
  79819. set forceHorizontalBar(value: boolean);
  79820. /**
  79821. * Forces the vertical scroll bar to be displayed
  79822. */
  79823. get forceVerticalBar(): boolean;
  79824. set forceVerticalBar(value: boolean);
  79825. /**
  79826. * Creates a new ScrollViewer
  79827. * @param name of ScrollViewer
  79828. */
  79829. constructor(name?: string, isImageBased?: boolean);
  79830. /** Reset the scroll viewer window to initial size */
  79831. resetWindow(): void;
  79832. protected _getTypeName(): string;
  79833. private _buildClientSizes;
  79834. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79835. protected _postMeasure(): void;
  79836. /**
  79837. * Gets or sets the mouse wheel precision
  79838. * from 0 to 1 with a default value of 0.05
  79839. * */
  79840. get wheelPrecision(): number;
  79841. set wheelPrecision(value: number);
  79842. /** Gets or sets the scroll bar container background color */
  79843. get scrollBackground(): string;
  79844. set scrollBackground(color: string);
  79845. /** Gets or sets the bar color */
  79846. get barColor(): string;
  79847. set barColor(color: string);
  79848. /** Gets or sets the bar image */
  79849. get thumbImage(): Image;
  79850. set thumbImage(value: Image);
  79851. /** Gets or sets the horizontal bar image */
  79852. get horizontalThumbImage(): Image;
  79853. set horizontalThumbImage(value: Image);
  79854. /** Gets or sets the vertical bar image */
  79855. get verticalThumbImage(): Image;
  79856. set verticalThumbImage(value: Image);
  79857. /** Gets or sets the size of the bar */
  79858. get barSize(): number;
  79859. set barSize(value: number);
  79860. /** Gets or sets the length of the thumb */
  79861. get thumbLength(): number;
  79862. set thumbLength(value: number);
  79863. /** Gets or sets the height of the thumb */
  79864. get thumbHeight(): number;
  79865. set thumbHeight(value: number);
  79866. /** Gets or sets the height of the bar image */
  79867. get barImageHeight(): number;
  79868. set barImageHeight(value: number);
  79869. /** Gets or sets the height of the horizontal bar image */
  79870. get horizontalBarImageHeight(): number;
  79871. set horizontalBarImageHeight(value: number);
  79872. /** Gets or sets the height of the vertical bar image */
  79873. get verticalBarImageHeight(): number;
  79874. set verticalBarImageHeight(value: number);
  79875. /** Gets or sets the bar background */
  79876. get barBackground(): string;
  79877. set barBackground(color: string);
  79878. /** Gets or sets the bar background image */
  79879. get barImage(): Image;
  79880. set barImage(value: Image);
  79881. /** Gets or sets the horizontal bar background image */
  79882. get horizontalBarImage(): Image;
  79883. set horizontalBarImage(value: Image);
  79884. /** Gets or sets the vertical bar background image */
  79885. get verticalBarImage(): Image;
  79886. set verticalBarImage(value: Image);
  79887. private _setWindowPosition;
  79888. /** @hidden */
  79889. private _updateScroller;
  79890. _link(host: AdvancedDynamicTexture): void;
  79891. /** @hidden */
  79892. private _addBar;
  79893. /** @hidden */
  79894. private _attachWheel;
  79895. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79896. /** Releases associated resources */
  79897. dispose(): void;
  79898. }
  79899. }
  79900. declare module BABYLON.GUI {
  79901. /** Class used to render a grid */
  79902. export class DisplayGrid extends Control {
  79903. name?: string | undefined;
  79904. private _cellWidth;
  79905. private _cellHeight;
  79906. private _minorLineTickness;
  79907. private _minorLineColor;
  79908. private _majorLineTickness;
  79909. private _majorLineColor;
  79910. private _majorLineFrequency;
  79911. private _background;
  79912. private _displayMajorLines;
  79913. private _displayMinorLines;
  79914. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79915. get displayMinorLines(): boolean;
  79916. set displayMinorLines(value: boolean);
  79917. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79918. get displayMajorLines(): boolean;
  79919. set displayMajorLines(value: boolean);
  79920. /** Gets or sets background color (Black by default) */
  79921. get background(): string;
  79922. set background(value: string);
  79923. /** Gets or sets the width of each cell (20 by default) */
  79924. get cellWidth(): number;
  79925. set cellWidth(value: number);
  79926. /** Gets or sets the height of each cell (20 by default) */
  79927. get cellHeight(): number;
  79928. set cellHeight(value: number);
  79929. /** Gets or sets the tickness of minor lines (1 by default) */
  79930. get minorLineTickness(): number;
  79931. set minorLineTickness(value: number);
  79932. /** Gets or sets the color of minor lines (DarkGray by default) */
  79933. get minorLineColor(): string;
  79934. set minorLineColor(value: string);
  79935. /** Gets or sets the tickness of major lines (2 by default) */
  79936. get majorLineTickness(): number;
  79937. set majorLineTickness(value: number);
  79938. /** Gets or sets the color of major lines (White by default) */
  79939. get majorLineColor(): string;
  79940. set majorLineColor(value: string);
  79941. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79942. get majorLineFrequency(): number;
  79943. set majorLineFrequency(value: number);
  79944. /**
  79945. * Creates a new GridDisplayRectangle
  79946. * @param name defines the control name
  79947. */
  79948. constructor(name?: string | undefined);
  79949. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79950. protected _getTypeName(): string;
  79951. }
  79952. }
  79953. declare module BABYLON.GUI {
  79954. /**
  79955. * Class used to create slider controls based on images
  79956. */
  79957. export class ImageBasedSlider extends BaseSlider {
  79958. name?: string | undefined;
  79959. private _backgroundImage;
  79960. private _thumbImage;
  79961. private _valueBarImage;
  79962. private _tempMeasure;
  79963. get displayThumb(): boolean;
  79964. set displayThumb(value: boolean);
  79965. /**
  79966. * Gets or sets the image used to render the background
  79967. */
  79968. get backgroundImage(): Image;
  79969. set backgroundImage(value: Image);
  79970. /**
  79971. * Gets or sets the image used to render the value bar
  79972. */
  79973. get valueBarImage(): Image;
  79974. set valueBarImage(value: Image);
  79975. /**
  79976. * Gets or sets the image used to render the thumb
  79977. */
  79978. get thumbImage(): Image;
  79979. set thumbImage(value: Image);
  79980. /**
  79981. * Creates a new ImageBasedSlider
  79982. * @param name defines the control name
  79983. */
  79984. constructor(name?: string | undefined);
  79985. protected _getTypeName(): string;
  79986. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79987. }
  79988. }
  79989. declare module BABYLON.GUI {
  79990. /**
  79991. * Forcing an export so that this code will execute
  79992. * @hidden
  79993. */
  79994. const name = "Statics";
  79995. }
  79996. declare module BABYLON.GUI {
  79997. /**
  79998. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79999. */
  80000. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80001. /**
  80002. * Define the instrumented AdvancedDynamicTexture.
  80003. */
  80004. texture: AdvancedDynamicTexture;
  80005. private _captureRenderTime;
  80006. private _renderTime;
  80007. private _captureLayoutTime;
  80008. private _layoutTime;
  80009. private _onBeginRenderObserver;
  80010. private _onEndRenderObserver;
  80011. private _onBeginLayoutObserver;
  80012. private _onEndLayoutObserver;
  80013. /**
  80014. * Gets the perf counter used to capture render time
  80015. */
  80016. get renderTimeCounter(): BABYLON.PerfCounter;
  80017. /**
  80018. * Gets the perf counter used to capture layout time
  80019. */
  80020. get layoutTimeCounter(): BABYLON.PerfCounter;
  80021. /**
  80022. * Enable or disable the render time capture
  80023. */
  80024. get captureRenderTime(): boolean;
  80025. set captureRenderTime(value: boolean);
  80026. /**
  80027. * Enable or disable the layout time capture
  80028. */
  80029. get captureLayoutTime(): boolean;
  80030. set captureLayoutTime(value: boolean);
  80031. /**
  80032. * Instantiates a new advanced dynamic texture instrumentation.
  80033. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80034. * @param texture Defines the AdvancedDynamicTexture to instrument
  80035. */
  80036. constructor(
  80037. /**
  80038. * Define the instrumented AdvancedDynamicTexture.
  80039. */
  80040. texture: AdvancedDynamicTexture);
  80041. /**
  80042. * Dispose and release associated resources.
  80043. */
  80044. dispose(): void;
  80045. }
  80046. }
  80047. declare module BABYLON.GUI {
  80048. /**
  80049. * Class used to load GUI via XML.
  80050. */
  80051. export class XmlLoader {
  80052. private _nodes;
  80053. private _nodeTypes;
  80054. private _isLoaded;
  80055. private _objectAttributes;
  80056. private _parentClass;
  80057. /**
  80058. * Create a new xml loader
  80059. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80060. */
  80061. constructor(parentClass?: null);
  80062. private _getChainElement;
  80063. private _getClassAttribute;
  80064. private _createGuiElement;
  80065. private _parseGrid;
  80066. private _parseElement;
  80067. private _prepareSourceElement;
  80068. private _parseElementsFromSource;
  80069. private _parseXml;
  80070. /**
  80071. * Gets if the loading has finished.
  80072. * @returns whether the loading has finished or not
  80073. */
  80074. isLoaded(): boolean;
  80075. /**
  80076. * Gets a loaded node / control by id.
  80077. * @param id the Controls id set in the xml
  80078. * @returns element of type Control
  80079. */
  80080. getNodeById(id: string): any;
  80081. /**
  80082. * Gets all loaded nodes / controls
  80083. * @returns Array of controls
  80084. */
  80085. getNodes(): any;
  80086. /**
  80087. * Initiates the xml layout loading
  80088. * @param xmlFile defines the xml layout to load
  80089. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80090. * @param callback defines the callback called on layout load.
  80091. */
  80092. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80093. }
  80094. }
  80095. declare module BABYLON.GUI {
  80096. /**
  80097. * Class used to create containers for controls
  80098. */
  80099. export class Container3D extends Control3D {
  80100. private _blockLayout;
  80101. /**
  80102. * Gets the list of child controls
  80103. */
  80104. protected _children: Control3D[];
  80105. /**
  80106. * Gets the list of child controls
  80107. */
  80108. get children(): Array<Control3D>;
  80109. /**
  80110. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80111. * This is helpful to optimize layout operation when adding multiple children in a row
  80112. */
  80113. get blockLayout(): boolean;
  80114. set blockLayout(value: boolean);
  80115. /**
  80116. * Creates a new container
  80117. * @param name defines the container name
  80118. */
  80119. constructor(name?: string);
  80120. /**
  80121. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80122. * @returns the current container
  80123. */
  80124. updateLayout(): Container3D;
  80125. /**
  80126. * Gets a boolean indicating if the given control is in the children of this control
  80127. * @param control defines the control to check
  80128. * @returns true if the control is in the child list
  80129. */
  80130. containsControl(control: Control3D): boolean;
  80131. /**
  80132. * Adds a control to the children of this control
  80133. * @param control defines the control to add
  80134. * @returns the current container
  80135. */
  80136. addControl(control: Control3D): Container3D;
  80137. /**
  80138. * This function will be called everytime a new control is added
  80139. */
  80140. protected _arrangeChildren(): void;
  80141. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80142. /**
  80143. * Removes a control from the children of this control
  80144. * @param control defines the control to remove
  80145. * @returns the current container
  80146. */
  80147. removeControl(control: Control3D): Container3D;
  80148. protected _getTypeName(): string;
  80149. /**
  80150. * Releases all associated resources
  80151. */
  80152. dispose(): void;
  80153. /** Control rotation will remain unchanged */
  80154. static readonly UNSET_ORIENTATION: number;
  80155. /** Control will rotate to make it look at sphere central axis */
  80156. static readonly FACEORIGIN_ORIENTATION: number;
  80157. /** Control will rotate to make it look back at sphere central axis */
  80158. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80159. /** Control will rotate to look at z axis (0, 0, 1) */
  80160. static readonly FACEFORWARD_ORIENTATION: number;
  80161. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80162. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80163. }
  80164. }
  80165. declare module BABYLON.GUI {
  80166. /**
  80167. * Class used to manage 3D user interface
  80168. * @see https://doc.babylonjs.com/how_to/gui3d
  80169. */
  80170. export class GUI3DManager implements BABYLON.IDisposable {
  80171. private _scene;
  80172. private _sceneDisposeObserver;
  80173. private _utilityLayer;
  80174. private _rootContainer;
  80175. private _pointerObserver;
  80176. private _pointerOutObserver;
  80177. /** @hidden */
  80178. _lastPickedControl: Control3D;
  80179. /** @hidden */
  80180. _lastControlOver: {
  80181. [pointerId: number]: Control3D;
  80182. };
  80183. /** @hidden */
  80184. _lastControlDown: {
  80185. [pointerId: number]: Control3D;
  80186. };
  80187. /**
  80188. * BABYLON.Observable raised when the point picked by the pointer events changed
  80189. */
  80190. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80191. /** @hidden */
  80192. _sharedMaterials: {
  80193. [key: string]: BABYLON.Material;
  80194. };
  80195. /** Gets the hosting scene */
  80196. get scene(): BABYLON.Scene;
  80197. /** Gets associated utility layer */
  80198. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80199. /**
  80200. * Creates a new GUI3DManager
  80201. * @param scene
  80202. */
  80203. constructor(scene?: BABYLON.Scene);
  80204. private _handlePointerOut;
  80205. private _doPicking;
  80206. /**
  80207. * Gets the root container
  80208. */
  80209. get rootContainer(): Container3D;
  80210. /**
  80211. * Gets a boolean indicating if the given control is in the root child list
  80212. * @param control defines the control to check
  80213. * @returns true if the control is in the root child list
  80214. */
  80215. containsControl(control: Control3D): boolean;
  80216. /**
  80217. * Adds a control to the root child list
  80218. * @param control defines the control to add
  80219. * @returns the current manager
  80220. */
  80221. addControl(control: Control3D): GUI3DManager;
  80222. /**
  80223. * Removes a control from the root child list
  80224. * @param control defines the control to remove
  80225. * @returns the current container
  80226. */
  80227. removeControl(control: Control3D): GUI3DManager;
  80228. /**
  80229. * Releases all associated resources
  80230. */
  80231. dispose(): void;
  80232. }
  80233. }
  80234. declare module BABYLON.GUI {
  80235. /**
  80236. * Class used to transport BABYLON.Vector3 information for pointer events
  80237. */
  80238. export class Vector3WithInfo extends BABYLON.Vector3 {
  80239. /** defines the current mouse button index */
  80240. buttonIndex: number;
  80241. /**
  80242. * Creates a new Vector3WithInfo
  80243. * @param source defines the vector3 data to transport
  80244. * @param buttonIndex defines the current mouse button index
  80245. */
  80246. constructor(source: BABYLON.Vector3,
  80247. /** defines the current mouse button index */
  80248. buttonIndex?: number);
  80249. }
  80250. }
  80251. declare module BABYLON.GUI {
  80252. /**
  80253. * Class used as base class for controls
  80254. */
  80255. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80256. /** Defines the control name */
  80257. name?: string | undefined;
  80258. /** @hidden */
  80259. _host: GUI3DManager;
  80260. private _node;
  80261. private _downCount;
  80262. private _enterCount;
  80263. private _downPointerIds;
  80264. private _isVisible;
  80265. /** Gets or sets the control position in world space */
  80266. get position(): BABYLON.Vector3;
  80267. set position(value: BABYLON.Vector3);
  80268. /** Gets or sets the control scaling in world space */
  80269. get scaling(): BABYLON.Vector3;
  80270. set scaling(value: BABYLON.Vector3);
  80271. /** Callback used to start pointer enter animation */
  80272. pointerEnterAnimation: () => void;
  80273. /** Callback used to start pointer out animation */
  80274. pointerOutAnimation: () => void;
  80275. /** Callback used to start pointer down animation */
  80276. pointerDownAnimation: () => void;
  80277. /** Callback used to start pointer up animation */
  80278. pointerUpAnimation: () => void;
  80279. /**
  80280. * An event triggered when the pointer move over the control
  80281. */
  80282. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80283. /**
  80284. * An event triggered when the pointer move out of the control
  80285. */
  80286. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80287. /**
  80288. * An event triggered when the pointer taps the control
  80289. */
  80290. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80291. /**
  80292. * An event triggered when pointer is up
  80293. */
  80294. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80295. /**
  80296. * An event triggered when a control is clicked on (with a mouse)
  80297. */
  80298. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80299. /**
  80300. * An event triggered when pointer enters the control
  80301. */
  80302. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80303. /**
  80304. * Gets or sets the parent container
  80305. */
  80306. parent: BABYLON.Nullable<Container3D>;
  80307. private _behaviors;
  80308. /**
  80309. * Gets the list of attached behaviors
  80310. * @see https://doc.babylonjs.com/features/behaviour
  80311. */
  80312. get behaviors(): BABYLON.Behavior<Control3D>[];
  80313. /**
  80314. * Attach a behavior to the control
  80315. * @see https://doc.babylonjs.com/features/behaviour
  80316. * @param behavior defines the behavior to attach
  80317. * @returns the current control
  80318. */
  80319. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80320. /**
  80321. * Remove an attached behavior
  80322. * @see https://doc.babylonjs.com/features/behaviour
  80323. * @param behavior defines the behavior to attach
  80324. * @returns the current control
  80325. */
  80326. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80327. /**
  80328. * Gets an attached behavior by name
  80329. * @param name defines the name of the behavior to look for
  80330. * @see https://doc.babylonjs.com/features/behaviour
  80331. * @returns null if behavior was not found else the requested behavior
  80332. */
  80333. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80334. /** Gets or sets a boolean indicating if the control is visible */
  80335. get isVisible(): boolean;
  80336. set isVisible(value: boolean);
  80337. /**
  80338. * Creates a new control
  80339. * @param name defines the control name
  80340. */
  80341. constructor(
  80342. /** Defines the control name */
  80343. name?: string | undefined);
  80344. /**
  80345. * Gets a string representing the class name
  80346. */
  80347. get typeName(): string;
  80348. /**
  80349. * Get the current class name of the control.
  80350. * @returns current class name
  80351. */
  80352. getClassName(): string;
  80353. protected _getTypeName(): string;
  80354. /**
  80355. * Gets the transform node used by this control
  80356. */
  80357. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80358. /**
  80359. * Gets the mesh used to render this control
  80360. */
  80361. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80362. /**
  80363. * Link the control as child of the given node
  80364. * @param node defines the node to link to. Use null to unlink the control
  80365. * @returns the current control
  80366. */
  80367. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80368. /** @hidden **/
  80369. _prepareNode(scene: BABYLON.Scene): void;
  80370. /**
  80371. * Node creation.
  80372. * Can be overriden by children
  80373. * @param scene defines the scene where the node must be attached
  80374. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80375. */
  80376. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80377. /**
  80378. * Affect a material to the given mesh
  80379. * @param mesh defines the mesh which will represent the control
  80380. */
  80381. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80382. /** @hidden */
  80383. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80384. /** @hidden */
  80385. _onPointerEnter(target: Control3D): boolean;
  80386. /** @hidden */
  80387. _onPointerOut(target: Control3D): void;
  80388. /** @hidden */
  80389. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80390. /** @hidden */
  80391. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80392. /** @hidden */
  80393. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80394. /** @hidden */
  80395. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80396. /** @hidden */
  80397. _disposeNode(): void;
  80398. /**
  80399. * Releases all associated resources
  80400. */
  80401. dispose(): void;
  80402. }
  80403. }
  80404. declare module BABYLON.GUI {
  80405. /**
  80406. * Class used as a root to all buttons
  80407. */
  80408. export class AbstractButton3D extends Control3D {
  80409. /**
  80410. * Creates a new button
  80411. * @param name defines the control name
  80412. */
  80413. constructor(name?: string);
  80414. protected _getTypeName(): string;
  80415. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80416. }
  80417. }
  80418. declare module BABYLON.GUI {
  80419. /**
  80420. * Class used to create a button in 3D
  80421. */
  80422. export class Button3D extends AbstractButton3D {
  80423. /** @hidden */
  80424. protected _currentMaterial: BABYLON.Material;
  80425. private _facadeTexture;
  80426. private _content;
  80427. private _contentResolution;
  80428. private _contentScaleRatio;
  80429. /**
  80430. * Gets or sets the texture resolution used to render content (512 by default)
  80431. */
  80432. get contentResolution(): BABYLON.int;
  80433. set contentResolution(value: BABYLON.int);
  80434. /**
  80435. * Gets or sets the texture scale ratio used to render content (2 by default)
  80436. */
  80437. get contentScaleRatio(): number;
  80438. set contentScaleRatio(value: number);
  80439. protected _disposeFacadeTexture(): void;
  80440. protected _resetContent(): void;
  80441. /**
  80442. * Creates a new button
  80443. * @param name defines the control name
  80444. */
  80445. constructor(name?: string);
  80446. /**
  80447. * Gets or sets the GUI 2D content used to display the button's facade
  80448. */
  80449. get content(): Control;
  80450. set content(value: Control);
  80451. /**
  80452. * Apply the facade texture (created from the content property).
  80453. * This function can be overloaded by child classes
  80454. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80455. */
  80456. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80457. protected _getTypeName(): string;
  80458. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80459. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80460. /**
  80461. * Releases all associated resources
  80462. */
  80463. dispose(): void;
  80464. }
  80465. }
  80466. declare module BABYLON.GUI {
  80467. /**
  80468. * Abstract class used to create a container panel deployed on the surface of a volume
  80469. */
  80470. export abstract class VolumeBasedPanel extends Container3D {
  80471. private _columns;
  80472. private _rows;
  80473. private _rowThenColum;
  80474. private _orientation;
  80475. protected _cellWidth: number;
  80476. protected _cellHeight: number;
  80477. /**
  80478. * Gets or sets the distance between elements
  80479. */
  80480. margin: number;
  80481. /**
  80482. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80483. * | Value | Type | Description |
  80484. * | ----- | ----------------------------------- | ----------- |
  80485. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80486. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80487. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80488. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80489. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80490. */
  80491. get orientation(): number;
  80492. set orientation(value: number);
  80493. /**
  80494. * Gets or sets the number of columns requested (10 by default).
  80495. * The panel will automatically compute the number of rows based on number of child controls.
  80496. */
  80497. get columns(): BABYLON.int;
  80498. set columns(value: BABYLON.int);
  80499. /**
  80500. * Gets or sets a the number of rows requested.
  80501. * The panel will automatically compute the number of columns based on number of child controls.
  80502. */
  80503. get rows(): BABYLON.int;
  80504. set rows(value: BABYLON.int);
  80505. /**
  80506. * Creates new VolumeBasedPanel
  80507. */
  80508. constructor();
  80509. protected _arrangeChildren(): void;
  80510. /** Child classes must implement this function to provide correct control positioning */
  80511. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80512. /** Child classes can implement this function to provide additional processing */
  80513. protected _finalProcessing(): void;
  80514. }
  80515. }
  80516. declare module BABYLON.GUI {
  80517. /**
  80518. * Class used to create a container panel deployed on the surface of a cylinder
  80519. */
  80520. export class CylinderPanel extends VolumeBasedPanel {
  80521. private _radius;
  80522. /**
  80523. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80524. */
  80525. get radius(): BABYLON.float;
  80526. set radius(value: BABYLON.float);
  80527. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80528. private _cylindricalMapping;
  80529. }
  80530. }
  80531. declare module BABYLON.GUI {
  80532. /** @hidden */
  80533. export var fluentVertexShader: {
  80534. name: string;
  80535. shader: string;
  80536. };
  80537. }
  80538. declare module BABYLON.GUI {
  80539. /** @hidden */
  80540. export var fluentPixelShader: {
  80541. name: string;
  80542. shader: string;
  80543. };
  80544. }
  80545. declare module BABYLON.GUI {
  80546. /** @hidden */
  80547. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80548. INNERGLOW: boolean;
  80549. BORDER: boolean;
  80550. HOVERLIGHT: boolean;
  80551. TEXTURE: boolean;
  80552. constructor();
  80553. }
  80554. /**
  80555. * Class used to render controls with fluent desgin
  80556. */
  80557. export class FluentMaterial extends BABYLON.PushMaterial {
  80558. /**
  80559. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80560. */
  80561. innerGlowColorIntensity: number;
  80562. /**
  80563. * Gets or sets the inner glow color (white by default)
  80564. */
  80565. innerGlowColor: BABYLON.Color3;
  80566. /**
  80567. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80568. */
  80569. albedoColor: BABYLON.Color3;
  80570. /**
  80571. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80572. */
  80573. renderBorders: boolean;
  80574. /**
  80575. * Gets or sets border width (default is 0.5)
  80576. */
  80577. borderWidth: number;
  80578. /**
  80579. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80580. */
  80581. edgeSmoothingValue: number;
  80582. /**
  80583. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80584. */
  80585. borderMinValue: number;
  80586. /**
  80587. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80588. */
  80589. renderHoverLight: boolean;
  80590. /**
  80591. * Gets or sets the radius used to render the hover light (default is 1.0)
  80592. */
  80593. hoverRadius: number;
  80594. /**
  80595. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80596. */
  80597. hoverColor: BABYLON.Color4;
  80598. /**
  80599. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80600. */
  80601. hoverPosition: BABYLON.Vector3;
  80602. private _albedoTexture;
  80603. /** Gets or sets the texture to use for albedo color */
  80604. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80605. /**
  80606. * Creates a new Fluent material
  80607. * @param name defines the name of the material
  80608. * @param scene defines the hosting scene
  80609. */
  80610. constructor(name: string, scene: BABYLON.Scene);
  80611. needAlphaBlending(): boolean;
  80612. needAlphaTesting(): boolean;
  80613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80614. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80615. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80616. getActiveTextures(): BABYLON.BaseTexture[];
  80617. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80618. dispose(forceDisposeEffect?: boolean): void;
  80619. clone(name: string): FluentMaterial;
  80620. serialize(): any;
  80621. getClassName(): string;
  80622. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80623. }
  80624. }
  80625. declare module BABYLON.GUI {
  80626. /**
  80627. * Class used to create a holographic button in 3D
  80628. */
  80629. export class HolographicButton extends Button3D {
  80630. private _backPlate;
  80631. private _textPlate;
  80632. private _frontPlate;
  80633. private _text;
  80634. private _imageUrl;
  80635. private _shareMaterials;
  80636. private _frontMaterial;
  80637. private _backMaterial;
  80638. private _plateMaterial;
  80639. private _pickedPointObserver;
  80640. private _tooltipFade;
  80641. private _tooltipTextBlock;
  80642. private _tooltipTexture;
  80643. private _tooltipMesh;
  80644. private _tooltipHoverObserver;
  80645. private _tooltipOutObserver;
  80646. private _disposeTooltip;
  80647. /**
  80648. * Rendering ground id of all the mesh in the button
  80649. */
  80650. set renderingGroupId(id: number);
  80651. get renderingGroupId(): number;
  80652. /**
  80653. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80654. */
  80655. set tooltipText(text: BABYLON.Nullable<string>);
  80656. get tooltipText(): BABYLON.Nullable<string>;
  80657. /**
  80658. * Gets or sets text for the button
  80659. */
  80660. get text(): string;
  80661. set text(value: string);
  80662. /**
  80663. * Gets or sets the image url for the button
  80664. */
  80665. get imageUrl(): string;
  80666. set imageUrl(value: string);
  80667. /**
  80668. * Gets the back material used by this button
  80669. */
  80670. get backMaterial(): FluentMaterial;
  80671. /**
  80672. * Gets the front material used by this button
  80673. */
  80674. get frontMaterial(): FluentMaterial;
  80675. /**
  80676. * Gets the plate material used by this button
  80677. */
  80678. get plateMaterial(): BABYLON.StandardMaterial;
  80679. /**
  80680. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80681. */
  80682. get shareMaterials(): boolean;
  80683. /**
  80684. * Creates a new button
  80685. * @param name defines the control name
  80686. */
  80687. constructor(name?: string, shareMaterials?: boolean);
  80688. protected _getTypeName(): string;
  80689. private _rebuildContent;
  80690. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80691. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80692. private _createBackMaterial;
  80693. private _createFrontMaterial;
  80694. private _createPlateMaterial;
  80695. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80696. /**
  80697. * Releases all associated resources
  80698. */
  80699. dispose(): void;
  80700. }
  80701. }
  80702. declare module BABYLON.GUI {
  80703. /**
  80704. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80705. */
  80706. export class MeshButton3D extends Button3D {
  80707. /** @hidden */
  80708. protected _currentMesh: BABYLON.Mesh;
  80709. /**
  80710. * Creates a new 3D button based on a mesh
  80711. * @param mesh mesh to become a 3D button
  80712. * @param name defines the control name
  80713. */
  80714. constructor(mesh: BABYLON.Mesh, name?: string);
  80715. protected _getTypeName(): string;
  80716. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80717. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80718. }
  80719. }
  80720. declare module BABYLON.GUI {
  80721. /**
  80722. * Class used to create a container panel deployed on the surface of a plane
  80723. */
  80724. export class PlanePanel extends VolumeBasedPanel {
  80725. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80726. }
  80727. }
  80728. declare module BABYLON.GUI {
  80729. /**
  80730. * Class used to create a container panel where items get randomized planar mapping
  80731. */
  80732. export class ScatterPanel extends VolumeBasedPanel {
  80733. private _iteration;
  80734. /**
  80735. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80736. */
  80737. get iteration(): BABYLON.float;
  80738. set iteration(value: BABYLON.float);
  80739. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80740. private _scatterMapping;
  80741. protected _finalProcessing(): void;
  80742. }
  80743. }
  80744. declare module BABYLON.GUI {
  80745. /**
  80746. * Class used to create a container panel deployed on the surface of a sphere
  80747. */
  80748. export class SpherePanel extends VolumeBasedPanel {
  80749. private _radius;
  80750. /**
  80751. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80752. */
  80753. get radius(): BABYLON.float;
  80754. set radius(value: BABYLON.float);
  80755. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80756. private _sphericalMapping;
  80757. }
  80758. }
  80759. declare module BABYLON.GUI {
  80760. /**
  80761. * Class used to create a stack panel in 3D on XY plane
  80762. */
  80763. export class StackPanel3D extends Container3D {
  80764. private _isVertical;
  80765. /**
  80766. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80767. */
  80768. get isVertical(): boolean;
  80769. set isVertical(value: boolean);
  80770. /**
  80771. * Gets or sets the distance between elements
  80772. */
  80773. margin: number;
  80774. /**
  80775. * Creates new StackPanel
  80776. * @param isVertical
  80777. */
  80778. constructor(isVertical?: boolean);
  80779. protected _arrangeChildren(): void;
  80780. }
  80781. }
  80782. declare module BABYLON {
  80783. /**
  80784. * Configuration for glTF validation
  80785. */
  80786. export interface IGLTFValidationConfiguration {
  80787. /**
  80788. * The url of the glTF validator.
  80789. */
  80790. url: string;
  80791. }
  80792. /**
  80793. * glTF validation
  80794. */
  80795. export class GLTFValidation {
  80796. /**
  80797. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80798. */
  80799. static Configuration: IGLTFValidationConfiguration;
  80800. private static _LoadScriptPromise;
  80801. /**
  80802. * Validate a glTF asset using the glTF-Validator.
  80803. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80804. * @param rootUrl The root url for the glTF
  80805. * @param fileName The file name for the glTF
  80806. * @param getExternalResource The callback to get external resources for the glTF validator
  80807. * @returns A promise that resolves with the glTF validation results once complete
  80808. */
  80809. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80810. }
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * Mode that determines the coordinate system to use.
  80815. */
  80816. export enum GLTFLoaderCoordinateSystemMode {
  80817. /**
  80818. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80819. */
  80820. AUTO = 0,
  80821. /**
  80822. * Sets the useRightHandedSystem flag on the scene.
  80823. */
  80824. FORCE_RIGHT_HANDED = 1
  80825. }
  80826. /**
  80827. * Mode that determines what animations will start.
  80828. */
  80829. export enum GLTFLoaderAnimationStartMode {
  80830. /**
  80831. * No animation will start.
  80832. */
  80833. NONE = 0,
  80834. /**
  80835. * The first animation will start.
  80836. */
  80837. FIRST = 1,
  80838. /**
  80839. * All animations will start.
  80840. */
  80841. ALL = 2
  80842. }
  80843. /**
  80844. * Interface that contains the data for the glTF asset.
  80845. */
  80846. export interface IGLTFLoaderData {
  80847. /**
  80848. * The object that represents the glTF JSON.
  80849. */
  80850. json: Object;
  80851. /**
  80852. * The BIN chunk of a binary glTF.
  80853. */
  80854. bin: Nullable<IDataBuffer>;
  80855. }
  80856. /**
  80857. * Interface for extending the loader.
  80858. */
  80859. export interface IGLTFLoaderExtension {
  80860. /**
  80861. * The name of this extension.
  80862. */
  80863. readonly name: string;
  80864. /**
  80865. * Defines whether this extension is enabled.
  80866. */
  80867. enabled: boolean;
  80868. /**
  80869. * Defines the order of this extension.
  80870. * The loader sorts the extensions using these values when loading.
  80871. */
  80872. order?: number;
  80873. }
  80874. /**
  80875. * Loader state.
  80876. */
  80877. export enum GLTFLoaderState {
  80878. /**
  80879. * The asset is loading.
  80880. */
  80881. LOADING = 0,
  80882. /**
  80883. * The asset is ready for rendering.
  80884. */
  80885. READY = 1,
  80886. /**
  80887. * The asset is completely loaded.
  80888. */
  80889. COMPLETE = 2
  80890. }
  80891. /** @hidden */
  80892. export interface IImportMeshAsyncOutput {
  80893. meshes: AbstractMesh[];
  80894. particleSystems: IParticleSystem[];
  80895. skeletons: Skeleton[];
  80896. animationGroups: AnimationGroup[];
  80897. lights: Light[];
  80898. transformNodes: TransformNode[];
  80899. }
  80900. /** @hidden */
  80901. export interface IGLTFLoader extends IDisposable {
  80902. readonly state: Nullable<GLTFLoaderState>;
  80903. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80904. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80905. }
  80906. /**
  80907. * File loader for loading glTF files into a scene.
  80908. */
  80909. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80910. /** @hidden */
  80911. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80912. /** @hidden */
  80913. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80914. /**
  80915. * Raised when the asset has been parsed
  80916. */
  80917. onParsedObservable: Observable<IGLTFLoaderData>;
  80918. private _onParsedObserver;
  80919. /**
  80920. * Raised when the asset has been parsed
  80921. */
  80922. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80923. /**
  80924. * 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.
  80925. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80926. * Defaults to true.
  80927. * @hidden
  80928. */
  80929. static IncrementalLoading: boolean;
  80930. /**
  80931. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80932. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80933. * @hidden
  80934. */
  80935. static HomogeneousCoordinates: boolean;
  80936. /**
  80937. * The coordinate system mode. Defaults to AUTO.
  80938. */
  80939. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80940. /**
  80941. * The animation start mode. Defaults to FIRST.
  80942. */
  80943. animationStartMode: GLTFLoaderAnimationStartMode;
  80944. /**
  80945. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80946. */
  80947. compileMaterials: boolean;
  80948. /**
  80949. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80950. */
  80951. useClipPlane: boolean;
  80952. /**
  80953. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80954. */
  80955. compileShadowGenerators: boolean;
  80956. /**
  80957. * Defines if the Alpha blended materials are only applied as coverage.
  80958. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80959. * If true, no extra effects are applied to transparent pixels.
  80960. */
  80961. transparencyAsCoverage: boolean;
  80962. /**
  80963. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80964. * Enabling will disable offline support and glTF validator.
  80965. * Defaults to false.
  80966. */
  80967. useRangeRequests: boolean;
  80968. /**
  80969. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80970. */
  80971. createInstances: boolean;
  80972. /**
  80973. * 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.
  80974. */
  80975. alwaysComputeBoundingBox: boolean;
  80976. /**
  80977. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80978. */
  80979. loadAllMaterials: boolean;
  80980. /**
  80981. * Function called before loading a url referenced by the asset.
  80982. */
  80983. preprocessUrlAsync: (url: string) => Promise<string>;
  80984. /**
  80985. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80986. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80987. */
  80988. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80989. private _onMeshLoadedObserver;
  80990. /**
  80991. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80992. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80993. */
  80994. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80995. /**
  80996. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80997. */
  80998. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80999. private _onTextureLoadedObserver;
  81000. /**
  81001. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81002. */
  81003. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81004. /**
  81005. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81006. */
  81007. readonly onMaterialLoadedObservable: Observable<Material>;
  81008. private _onMaterialLoadedObserver;
  81009. /**
  81010. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81011. */
  81012. set onMaterialLoaded(callback: (material: Material) => void);
  81013. /**
  81014. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81015. */
  81016. readonly onCameraLoadedObservable: Observable<Camera>;
  81017. private _onCameraLoadedObserver;
  81018. /**
  81019. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81020. */
  81021. set onCameraLoaded(callback: (camera: Camera) => void);
  81022. /**
  81023. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81024. * For assets with LODs, raised when all of the LODs are complete.
  81025. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81026. */
  81027. readonly onCompleteObservable: Observable<void>;
  81028. private _onCompleteObserver;
  81029. /**
  81030. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81031. * For assets with LODs, raised when all of the LODs are complete.
  81032. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81033. */
  81034. set onComplete(callback: () => void);
  81035. /**
  81036. * Observable raised when an error occurs.
  81037. */
  81038. readonly onErrorObservable: Observable<any>;
  81039. private _onErrorObserver;
  81040. /**
  81041. * Callback raised when an error occurs.
  81042. */
  81043. set onError(callback: (reason: any) => void);
  81044. /**
  81045. * Observable raised after the loader is disposed.
  81046. */
  81047. readonly onDisposeObservable: Observable<void>;
  81048. private _onDisposeObserver;
  81049. /**
  81050. * Callback raised after the loader is disposed.
  81051. */
  81052. set onDispose(callback: () => void);
  81053. /**
  81054. * Observable raised after a loader extension is created.
  81055. * Set additional options for a loader extension in this event.
  81056. */
  81057. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81058. private _onExtensionLoadedObserver;
  81059. /**
  81060. * Callback raised after a loader extension is created.
  81061. */
  81062. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81063. /**
  81064. * Defines if the loader logging is enabled.
  81065. */
  81066. get loggingEnabled(): boolean;
  81067. set loggingEnabled(value: boolean);
  81068. /**
  81069. * Defines if the loader should capture performance counters.
  81070. */
  81071. get capturePerformanceCounters(): boolean;
  81072. set capturePerformanceCounters(value: boolean);
  81073. /**
  81074. * Defines if the loader should validate the asset.
  81075. */
  81076. validate: boolean;
  81077. /**
  81078. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81079. */
  81080. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81081. private _onValidatedObserver;
  81082. /**
  81083. * Callback raised after a loader extension is created.
  81084. */
  81085. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81086. private _loader;
  81087. private _progressCallback?;
  81088. private _requests;
  81089. private static magicBase64Encoded;
  81090. /**
  81091. * Name of the loader ("gltf")
  81092. */
  81093. name: string;
  81094. /** @hidden */
  81095. extensions: ISceneLoaderPluginExtensions;
  81096. /**
  81097. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81098. */
  81099. dispose(): void;
  81100. /** @hidden */
  81101. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81102. /** @hidden */
  81103. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81104. /** @hidden */
  81105. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81106. meshes: AbstractMesh[];
  81107. particleSystems: IParticleSystem[];
  81108. skeletons: Skeleton[];
  81109. animationGroups: AnimationGroup[];
  81110. }>;
  81111. /** @hidden */
  81112. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81113. /** @hidden */
  81114. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81115. /** @hidden */
  81116. canDirectLoad(data: string): boolean;
  81117. /** @hidden */
  81118. directLoad(scene: Scene, data: string): Promise<any>;
  81119. /**
  81120. * The callback that allows custom handling of the root url based on the response url.
  81121. * @param rootUrl the original root url
  81122. * @param responseURL the response url if available
  81123. * @returns the new root url
  81124. */
  81125. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81126. /** @hidden */
  81127. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81128. /**
  81129. * The loader state or null if the loader is not active.
  81130. */
  81131. get loaderState(): Nullable<GLTFLoaderState>;
  81132. /**
  81133. * Returns a promise that resolves when the asset is completely loaded.
  81134. * @returns a promise that resolves when the asset is completely loaded.
  81135. */
  81136. whenCompleteAsync(): Promise<void>;
  81137. /** @hidden */
  81138. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81139. /** @hidden */
  81140. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81141. private _onProgress;
  81142. private _validate;
  81143. private _getLoader;
  81144. private _parseJson;
  81145. private _unpackBinaryAsync;
  81146. private _unpackBinaryV1Async;
  81147. private _unpackBinaryV2Async;
  81148. private static _parseVersion;
  81149. private static _compareVersion;
  81150. private static readonly _logSpaces;
  81151. private _logIndentLevel;
  81152. private _loggingEnabled;
  81153. /** @hidden */
  81154. _log: (message: string) => void;
  81155. /** @hidden */
  81156. _logOpen(message: string): void;
  81157. /** @hidden */
  81158. _logClose(): void;
  81159. private _logEnabled;
  81160. private _logDisabled;
  81161. private _capturePerformanceCounters;
  81162. /** @hidden */
  81163. _startPerformanceCounter: (counterName: string) => void;
  81164. /** @hidden */
  81165. _endPerformanceCounter: (counterName: string) => void;
  81166. private _startPerformanceCounterEnabled;
  81167. private _startPerformanceCounterDisabled;
  81168. private _endPerformanceCounterEnabled;
  81169. private _endPerformanceCounterDisabled;
  81170. }
  81171. }
  81172. declare module BABYLON.GLTF1 {
  81173. /**
  81174. * Enums
  81175. * @hidden
  81176. */
  81177. export enum EComponentType {
  81178. BYTE = 5120,
  81179. UNSIGNED_BYTE = 5121,
  81180. SHORT = 5122,
  81181. UNSIGNED_SHORT = 5123,
  81182. FLOAT = 5126
  81183. }
  81184. /** @hidden */
  81185. export enum EShaderType {
  81186. FRAGMENT = 35632,
  81187. VERTEX = 35633
  81188. }
  81189. /** @hidden */
  81190. export enum EParameterType {
  81191. BYTE = 5120,
  81192. UNSIGNED_BYTE = 5121,
  81193. SHORT = 5122,
  81194. UNSIGNED_SHORT = 5123,
  81195. INT = 5124,
  81196. UNSIGNED_INT = 5125,
  81197. FLOAT = 5126,
  81198. FLOAT_VEC2 = 35664,
  81199. FLOAT_VEC3 = 35665,
  81200. FLOAT_VEC4 = 35666,
  81201. INT_VEC2 = 35667,
  81202. INT_VEC3 = 35668,
  81203. INT_VEC4 = 35669,
  81204. BOOL = 35670,
  81205. BOOL_VEC2 = 35671,
  81206. BOOL_VEC3 = 35672,
  81207. BOOL_VEC4 = 35673,
  81208. FLOAT_MAT2 = 35674,
  81209. FLOAT_MAT3 = 35675,
  81210. FLOAT_MAT4 = 35676,
  81211. SAMPLER_2D = 35678
  81212. }
  81213. /** @hidden */
  81214. export enum ETextureWrapMode {
  81215. CLAMP_TO_EDGE = 33071,
  81216. MIRRORED_REPEAT = 33648,
  81217. REPEAT = 10497
  81218. }
  81219. /** @hidden */
  81220. export enum ETextureFilterType {
  81221. NEAREST = 9728,
  81222. LINEAR = 9728,
  81223. NEAREST_MIPMAP_NEAREST = 9984,
  81224. LINEAR_MIPMAP_NEAREST = 9985,
  81225. NEAREST_MIPMAP_LINEAR = 9986,
  81226. LINEAR_MIPMAP_LINEAR = 9987
  81227. }
  81228. /** @hidden */
  81229. export enum ETextureFormat {
  81230. ALPHA = 6406,
  81231. RGB = 6407,
  81232. RGBA = 6408,
  81233. LUMINANCE = 6409,
  81234. LUMINANCE_ALPHA = 6410
  81235. }
  81236. /** @hidden */
  81237. export enum ECullingType {
  81238. FRONT = 1028,
  81239. BACK = 1029,
  81240. FRONT_AND_BACK = 1032
  81241. }
  81242. /** @hidden */
  81243. export enum EBlendingFunction {
  81244. ZERO = 0,
  81245. ONE = 1,
  81246. SRC_COLOR = 768,
  81247. ONE_MINUS_SRC_COLOR = 769,
  81248. DST_COLOR = 774,
  81249. ONE_MINUS_DST_COLOR = 775,
  81250. SRC_ALPHA = 770,
  81251. ONE_MINUS_SRC_ALPHA = 771,
  81252. DST_ALPHA = 772,
  81253. ONE_MINUS_DST_ALPHA = 773,
  81254. CONSTANT_COLOR = 32769,
  81255. ONE_MINUS_CONSTANT_COLOR = 32770,
  81256. CONSTANT_ALPHA = 32771,
  81257. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81258. SRC_ALPHA_SATURATE = 776
  81259. }
  81260. /** @hidden */
  81261. export interface IGLTFProperty {
  81262. extensions?: {
  81263. [key: string]: any;
  81264. };
  81265. extras?: Object;
  81266. }
  81267. /** @hidden */
  81268. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81269. name?: string;
  81270. }
  81271. /** @hidden */
  81272. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81273. bufferView: string;
  81274. byteOffset: number;
  81275. byteStride: number;
  81276. count: number;
  81277. type: string;
  81278. componentType: EComponentType;
  81279. max?: number[];
  81280. min?: number[];
  81281. name?: string;
  81282. }
  81283. /** @hidden */
  81284. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81285. buffer: string;
  81286. byteOffset: number;
  81287. byteLength: number;
  81288. byteStride: number;
  81289. target?: number;
  81290. }
  81291. /** @hidden */
  81292. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81293. uri: string;
  81294. byteLength?: number;
  81295. type?: string;
  81296. }
  81297. /** @hidden */
  81298. export interface IGLTFShader extends IGLTFChildRootProperty {
  81299. uri: string;
  81300. type: EShaderType;
  81301. }
  81302. /** @hidden */
  81303. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81304. attributes: string[];
  81305. fragmentShader: string;
  81306. vertexShader: string;
  81307. }
  81308. /** @hidden */
  81309. export interface IGLTFTechniqueParameter {
  81310. type: number;
  81311. count?: number;
  81312. semantic?: string;
  81313. node?: string;
  81314. value?: number | boolean | string | Array<any>;
  81315. source?: string;
  81316. babylonValue?: any;
  81317. }
  81318. /** @hidden */
  81319. export interface IGLTFTechniqueCommonProfile {
  81320. lightingModel: string;
  81321. texcoordBindings: Object;
  81322. parameters?: Array<any>;
  81323. }
  81324. /** @hidden */
  81325. export interface IGLTFTechniqueStatesFunctions {
  81326. blendColor?: number[];
  81327. blendEquationSeparate?: number[];
  81328. blendFuncSeparate?: number[];
  81329. colorMask: boolean[];
  81330. cullFace: number[];
  81331. }
  81332. /** @hidden */
  81333. export interface IGLTFTechniqueStates {
  81334. enable: number[];
  81335. functions: IGLTFTechniqueStatesFunctions;
  81336. }
  81337. /** @hidden */
  81338. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81339. parameters: {
  81340. [key: string]: IGLTFTechniqueParameter;
  81341. };
  81342. program: string;
  81343. attributes: {
  81344. [key: string]: string;
  81345. };
  81346. uniforms: {
  81347. [key: string]: string;
  81348. };
  81349. states: IGLTFTechniqueStates;
  81350. }
  81351. /** @hidden */
  81352. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81353. technique?: string;
  81354. values: string[];
  81355. }
  81356. /** @hidden */
  81357. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81358. attributes: {
  81359. [key: string]: string;
  81360. };
  81361. indices: string;
  81362. material: string;
  81363. mode?: number;
  81364. }
  81365. /** @hidden */
  81366. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81367. primitives: IGLTFMeshPrimitive[];
  81368. }
  81369. /** @hidden */
  81370. export interface IGLTFImage extends IGLTFChildRootProperty {
  81371. uri: string;
  81372. }
  81373. /** @hidden */
  81374. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81375. magFilter?: number;
  81376. minFilter?: number;
  81377. wrapS?: number;
  81378. wrapT?: number;
  81379. }
  81380. /** @hidden */
  81381. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81382. sampler: string;
  81383. source: string;
  81384. format?: ETextureFormat;
  81385. internalFormat?: ETextureFormat;
  81386. target?: number;
  81387. type?: number;
  81388. babylonTexture?: Texture;
  81389. }
  81390. /** @hidden */
  81391. export interface IGLTFAmbienLight {
  81392. color?: number[];
  81393. }
  81394. /** @hidden */
  81395. export interface IGLTFDirectionalLight {
  81396. color?: number[];
  81397. }
  81398. /** @hidden */
  81399. export interface IGLTFPointLight {
  81400. color?: number[];
  81401. constantAttenuation?: number;
  81402. linearAttenuation?: number;
  81403. quadraticAttenuation?: number;
  81404. }
  81405. /** @hidden */
  81406. export interface IGLTFSpotLight {
  81407. color?: number[];
  81408. constantAttenuation?: number;
  81409. fallOfAngle?: number;
  81410. fallOffExponent?: number;
  81411. linearAttenuation?: number;
  81412. quadraticAttenuation?: number;
  81413. }
  81414. /** @hidden */
  81415. export interface IGLTFLight extends IGLTFChildRootProperty {
  81416. type: string;
  81417. }
  81418. /** @hidden */
  81419. export interface IGLTFCameraOrthographic {
  81420. xmag: number;
  81421. ymag: number;
  81422. zfar: number;
  81423. znear: number;
  81424. }
  81425. /** @hidden */
  81426. export interface IGLTFCameraPerspective {
  81427. aspectRatio: number;
  81428. yfov: number;
  81429. zfar: number;
  81430. znear: number;
  81431. }
  81432. /** @hidden */
  81433. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81434. type: string;
  81435. }
  81436. /** @hidden */
  81437. export interface IGLTFAnimationChannelTarget {
  81438. id: string;
  81439. path: string;
  81440. }
  81441. /** @hidden */
  81442. export interface IGLTFAnimationChannel {
  81443. sampler: string;
  81444. target: IGLTFAnimationChannelTarget;
  81445. }
  81446. /** @hidden */
  81447. export interface IGLTFAnimationSampler {
  81448. input: string;
  81449. output: string;
  81450. interpolation?: string;
  81451. }
  81452. /** @hidden */
  81453. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81454. channels?: IGLTFAnimationChannel[];
  81455. parameters?: {
  81456. [key: string]: string;
  81457. };
  81458. samplers?: {
  81459. [key: string]: IGLTFAnimationSampler;
  81460. };
  81461. }
  81462. /** @hidden */
  81463. export interface IGLTFNodeInstanceSkin {
  81464. skeletons: string[];
  81465. skin: string;
  81466. meshes: string[];
  81467. }
  81468. /** @hidden */
  81469. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81470. bindShapeMatrix: number[];
  81471. inverseBindMatrices: string;
  81472. jointNames: string[];
  81473. babylonSkeleton?: Skeleton;
  81474. }
  81475. /** @hidden */
  81476. export interface IGLTFNode extends IGLTFChildRootProperty {
  81477. camera?: string;
  81478. children: string[];
  81479. skin?: string;
  81480. jointName?: string;
  81481. light?: string;
  81482. matrix: number[];
  81483. mesh?: string;
  81484. meshes?: string[];
  81485. rotation?: number[];
  81486. scale?: number[];
  81487. translation?: number[];
  81488. babylonNode?: Node;
  81489. }
  81490. /** @hidden */
  81491. export interface IGLTFScene extends IGLTFChildRootProperty {
  81492. nodes: string[];
  81493. }
  81494. /** @hidden */
  81495. export interface IGLTFRuntime {
  81496. extensions: {
  81497. [key: string]: any;
  81498. };
  81499. accessors: {
  81500. [key: string]: IGLTFAccessor;
  81501. };
  81502. buffers: {
  81503. [key: string]: IGLTFBuffer;
  81504. };
  81505. bufferViews: {
  81506. [key: string]: IGLTFBufferView;
  81507. };
  81508. meshes: {
  81509. [key: string]: IGLTFMesh;
  81510. };
  81511. lights: {
  81512. [key: string]: IGLTFLight;
  81513. };
  81514. cameras: {
  81515. [key: string]: IGLTFCamera;
  81516. };
  81517. nodes: {
  81518. [key: string]: IGLTFNode;
  81519. };
  81520. images: {
  81521. [key: string]: IGLTFImage;
  81522. };
  81523. textures: {
  81524. [key: string]: IGLTFTexture;
  81525. };
  81526. shaders: {
  81527. [key: string]: IGLTFShader;
  81528. };
  81529. programs: {
  81530. [key: string]: IGLTFProgram;
  81531. };
  81532. samplers: {
  81533. [key: string]: IGLTFSampler;
  81534. };
  81535. techniques: {
  81536. [key: string]: IGLTFTechnique;
  81537. };
  81538. materials: {
  81539. [key: string]: IGLTFMaterial;
  81540. };
  81541. animations: {
  81542. [key: string]: IGLTFAnimation;
  81543. };
  81544. skins: {
  81545. [key: string]: IGLTFSkins;
  81546. };
  81547. currentScene?: Object;
  81548. scenes: {
  81549. [key: string]: IGLTFScene;
  81550. };
  81551. extensionsUsed: string[];
  81552. extensionsRequired?: string[];
  81553. buffersCount: number;
  81554. shaderscount: number;
  81555. scene: Scene;
  81556. rootUrl: string;
  81557. loadedBufferCount: number;
  81558. loadedBufferViews: {
  81559. [name: string]: ArrayBufferView;
  81560. };
  81561. loadedShaderCount: number;
  81562. importOnlyMeshes: boolean;
  81563. importMeshesNames?: string[];
  81564. dummyNodes: Node[];
  81565. forAssetContainer: boolean;
  81566. }
  81567. /** @hidden */
  81568. export interface INodeToRoot {
  81569. bone: Bone;
  81570. node: IGLTFNode;
  81571. id: string;
  81572. }
  81573. /** @hidden */
  81574. export interface IJointNode {
  81575. node: IGLTFNode;
  81576. id: string;
  81577. }
  81578. }
  81579. declare module BABYLON.GLTF1 {
  81580. /**
  81581. * Utils functions for GLTF
  81582. * @hidden
  81583. */
  81584. export class GLTFUtils {
  81585. /**
  81586. * Sets the given "parameter" matrix
  81587. * @param scene: the Scene object
  81588. * @param source: the source node where to pick the matrix
  81589. * @param parameter: the GLTF technique parameter
  81590. * @param uniformName: the name of the shader's uniform
  81591. * @param shaderMaterial: the shader material
  81592. */
  81593. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81594. /**
  81595. * Sets the given "parameter" matrix
  81596. * @param shaderMaterial: the shader material
  81597. * @param uniform: the name of the shader's uniform
  81598. * @param value: the value of the uniform
  81599. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81600. */
  81601. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81602. /**
  81603. * Returns the wrap mode of the texture
  81604. * @param mode: the mode value
  81605. */
  81606. static GetWrapMode(mode: number): number;
  81607. /**
  81608. * Returns the byte stride giving an accessor
  81609. * @param accessor: the GLTF accessor objet
  81610. */
  81611. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81612. /**
  81613. * Returns the texture filter mode giving a mode value
  81614. * @param mode: the filter mode value
  81615. */
  81616. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81617. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81618. /**
  81619. * Returns a buffer from its accessor
  81620. * @param gltfRuntime: the GLTF runtime
  81621. * @param accessor: the GLTF accessor
  81622. */
  81623. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81624. /**
  81625. * Decodes a buffer view into a string
  81626. * @param view: the buffer view
  81627. */
  81628. static DecodeBufferToText(view: ArrayBufferView): string;
  81629. /**
  81630. * Returns the default material of gltf. Related to
  81631. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81632. * @param scene: the Babylon.js scene
  81633. */
  81634. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81635. private static _DefaultMaterial;
  81636. }
  81637. }
  81638. declare module BABYLON.GLTF1 {
  81639. /**
  81640. * Implementation of the base glTF spec
  81641. * @hidden
  81642. */
  81643. export class GLTFLoaderBase {
  81644. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81645. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81646. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81647. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81648. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81649. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81650. }
  81651. /**
  81652. * glTF V1 Loader
  81653. * @hidden
  81654. */
  81655. export class GLTFLoader implements IGLTFLoader {
  81656. static Extensions: {
  81657. [name: string]: GLTFLoaderExtension;
  81658. };
  81659. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81660. state: Nullable<GLTFLoaderState>;
  81661. dispose(): void;
  81662. private _importMeshAsync;
  81663. /**
  81664. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81665. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81666. * @param scene the scene the meshes should be added to
  81667. * @param forAssetContainer defines if the entities must be stored in the scene
  81668. * @param data gltf data containing information of the meshes in a loaded file
  81669. * @param rootUrl root url to load from
  81670. * @param onProgress event that fires when loading progress has occured
  81671. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81672. */
  81673. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81674. private _loadAsync;
  81675. /**
  81676. * Imports all objects from a loaded gltf file and adds them to the scene
  81677. * @param scene the scene the objects should be added to
  81678. * @param data gltf data containing information of the meshes in a loaded file
  81679. * @param rootUrl root url to load from
  81680. * @param onProgress event that fires when loading progress has occured
  81681. * @returns a promise which completes when objects have been loaded to the scene
  81682. */
  81683. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81684. private _loadShadersAsync;
  81685. private _loadBuffersAsync;
  81686. private _createNodes;
  81687. }
  81688. /** @hidden */
  81689. export abstract class GLTFLoaderExtension {
  81690. private _name;
  81691. constructor(name: string);
  81692. get name(): string;
  81693. /**
  81694. * Defines an override for loading the runtime
  81695. * Return true to stop further extensions from loading the runtime
  81696. */
  81697. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81698. /**
  81699. * Defines an onverride for creating gltf runtime
  81700. * Return true to stop further extensions from creating the runtime
  81701. */
  81702. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81703. /**
  81704. * Defines an override for loading buffers
  81705. * Return true to stop further extensions from loading this buffer
  81706. */
  81707. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81708. /**
  81709. * Defines an override for loading texture buffers
  81710. * Return true to stop further extensions from loading this texture data
  81711. */
  81712. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81713. /**
  81714. * Defines an override for creating textures
  81715. * Return true to stop further extensions from loading this texture
  81716. */
  81717. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81718. /**
  81719. * Defines an override for loading shader strings
  81720. * Return true to stop further extensions from loading this shader data
  81721. */
  81722. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81723. /**
  81724. * Defines an override for loading materials
  81725. * Return true to stop further extensions from loading this material
  81726. */
  81727. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81728. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81729. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81730. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81731. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81732. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81733. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81734. private static LoadTextureBufferAsync;
  81735. private static CreateTextureAsync;
  81736. private static ApplyExtensions;
  81737. }
  81738. }
  81739. declare module BABYLON.GLTF1 {
  81740. /** @hidden */
  81741. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81742. private _bin;
  81743. constructor();
  81744. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81745. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81746. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81747. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81748. }
  81749. }
  81750. declare module BABYLON.GLTF1 {
  81751. /** @hidden */
  81752. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81753. constructor();
  81754. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81755. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81756. private _loadTexture;
  81757. }
  81758. }
  81759. declare module BABYLON.GLTF2.Loader {
  81760. /**
  81761. * Loader interface with an index field.
  81762. */
  81763. export interface IArrayItem {
  81764. /**
  81765. * The index of this item in the array.
  81766. */
  81767. index: number;
  81768. }
  81769. /**
  81770. * Loader interface with additional members.
  81771. */
  81772. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81773. /** @hidden */
  81774. _data?: Promise<ArrayBufferView>;
  81775. /** @hidden */
  81776. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81777. }
  81778. /**
  81779. * Loader interface with additional members.
  81780. */
  81781. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81782. }
  81783. /** @hidden */
  81784. export interface _IAnimationSamplerData {
  81785. input: Float32Array;
  81786. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81787. output: Float32Array;
  81788. }
  81789. /**
  81790. * Loader interface with additional members.
  81791. */
  81792. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81793. /** @hidden */
  81794. _data?: Promise<_IAnimationSamplerData>;
  81795. }
  81796. /**
  81797. * Loader interface with additional members.
  81798. */
  81799. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81800. channels: IAnimationChannel[];
  81801. samplers: IAnimationSampler[];
  81802. /** @hidden */
  81803. _babylonAnimationGroup?: AnimationGroup;
  81804. }
  81805. /**
  81806. * Loader interface with additional members.
  81807. */
  81808. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81809. /** @hidden */
  81810. _data?: Promise<ArrayBufferView>;
  81811. }
  81812. /**
  81813. * Loader interface with additional members.
  81814. */
  81815. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81816. /** @hidden */
  81817. _data?: Promise<ArrayBufferView>;
  81818. /** @hidden */
  81819. _babylonBuffer?: Promise<Buffer>;
  81820. }
  81821. /**
  81822. * Loader interface with additional members.
  81823. */
  81824. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81825. }
  81826. /**
  81827. * Loader interface with additional members.
  81828. */
  81829. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81830. /** @hidden */
  81831. _data?: Promise<ArrayBufferView>;
  81832. }
  81833. /**
  81834. * Loader interface with additional members.
  81835. */
  81836. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81837. }
  81838. /**
  81839. * Loader interface with additional members.
  81840. */
  81841. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81842. }
  81843. /**
  81844. * Loader interface with additional members.
  81845. */
  81846. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81847. baseColorTexture?: ITextureInfo;
  81848. metallicRoughnessTexture?: ITextureInfo;
  81849. }
  81850. /**
  81851. * Loader interface with additional members.
  81852. */
  81853. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81854. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81855. normalTexture?: IMaterialNormalTextureInfo;
  81856. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81857. emissiveTexture?: ITextureInfo;
  81858. /** @hidden */
  81859. _data?: {
  81860. [babylonDrawMode: number]: {
  81861. babylonMaterial: Material;
  81862. babylonMeshes: AbstractMesh[];
  81863. promise: Promise<void>;
  81864. };
  81865. };
  81866. }
  81867. /**
  81868. * Loader interface with additional members.
  81869. */
  81870. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81871. primitives: IMeshPrimitive[];
  81872. }
  81873. /**
  81874. * Loader interface with additional members.
  81875. */
  81876. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81877. /** @hidden */
  81878. _instanceData?: {
  81879. babylonSourceMesh: Mesh;
  81880. promise: Promise<any>;
  81881. };
  81882. }
  81883. /**
  81884. * Loader interface with additional members.
  81885. */
  81886. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81887. /**
  81888. * The parent glTF node.
  81889. */
  81890. parent?: INode;
  81891. /** @hidden */
  81892. _babylonTransformNode?: TransformNode;
  81893. /** @hidden */
  81894. _primitiveBabylonMeshes?: AbstractMesh[];
  81895. /** @hidden */
  81896. _babylonBones?: Bone[];
  81897. /** @hidden */
  81898. _numMorphTargets?: number;
  81899. }
  81900. /** @hidden */
  81901. export interface _ISamplerData {
  81902. noMipMaps: boolean;
  81903. samplingMode: number;
  81904. wrapU: number;
  81905. wrapV: number;
  81906. }
  81907. /**
  81908. * Loader interface with additional members.
  81909. */
  81910. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81911. /** @hidden */
  81912. _data?: _ISamplerData;
  81913. }
  81914. /**
  81915. * Loader interface with additional members.
  81916. */
  81917. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81918. }
  81919. /**
  81920. * Loader interface with additional members.
  81921. */
  81922. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81923. /** @hidden */
  81924. _data?: {
  81925. babylonSkeleton: Skeleton;
  81926. promise: Promise<void>;
  81927. };
  81928. }
  81929. /**
  81930. * Loader interface with additional members.
  81931. */
  81932. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81933. }
  81934. /**
  81935. * Loader interface with additional members.
  81936. */
  81937. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81938. }
  81939. /**
  81940. * Loader interface with additional members.
  81941. */
  81942. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81943. accessors?: IAccessor[];
  81944. animations?: IAnimation[];
  81945. buffers?: IBuffer[];
  81946. bufferViews?: IBufferView[];
  81947. cameras?: ICamera[];
  81948. images?: IImage[];
  81949. materials?: IMaterial[];
  81950. meshes?: IMesh[];
  81951. nodes?: INode[];
  81952. samplers?: ISampler[];
  81953. scenes?: IScene[];
  81954. skins?: ISkin[];
  81955. textures?: ITexture[];
  81956. }
  81957. }
  81958. declare module BABYLON.GLTF2 {
  81959. /**
  81960. * Interface for a glTF loader extension.
  81961. */
  81962. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81963. /**
  81964. * Called after the loader state changes to LOADING.
  81965. */
  81966. onLoading?(): void;
  81967. /**
  81968. * Called after the loader state changes to READY.
  81969. */
  81970. onReady?(): void;
  81971. /**
  81972. * Define this method to modify the default behavior when loading scenes.
  81973. * @param context The context when loading the asset
  81974. * @param scene The glTF scene property
  81975. * @returns A promise that resolves when the load is complete or null if not handled
  81976. */
  81977. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81978. /**
  81979. * Define this method to modify the default behavior when loading nodes.
  81980. * @param context The context when loading the asset
  81981. * @param node The glTF node property
  81982. * @param assign A function called synchronously after parsing the glTF properties
  81983. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81984. */
  81985. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81986. /**
  81987. * Define this method to modify the default behavior when loading cameras.
  81988. * @param context The context when loading the asset
  81989. * @param camera The glTF camera property
  81990. * @param assign A function called synchronously after parsing the glTF properties
  81991. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81992. */
  81993. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81994. /**
  81995. * @hidden
  81996. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81997. * @param context The context when loading the asset
  81998. * @param primitive The glTF mesh primitive property
  81999. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82000. */
  82001. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82002. /**
  82003. * @hidden
  82004. * Define this method to modify the default behavior when loading data for mesh primitives.
  82005. * @param context The context when loading the asset
  82006. * @param name The mesh name when loading the asset
  82007. * @param node The glTF node when loading the asset
  82008. * @param mesh The glTF mesh when loading the asset
  82009. * @param primitive The glTF mesh primitive property
  82010. * @param assign A function called synchronously after parsing the glTF properties
  82011. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82012. */
  82013. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82014. /**
  82015. * @hidden
  82016. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82017. * @param context The context when loading the asset
  82018. * @param material The glTF material property
  82019. * @param assign A function called synchronously after parsing the glTF properties
  82020. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82021. */
  82022. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82023. /**
  82024. * Define this method to modify the default behavior when creating materials.
  82025. * @param context The context when loading the asset
  82026. * @param material The glTF material property
  82027. * @param babylonDrawMode The draw mode for the Babylon material
  82028. * @returns The Babylon material or null if not handled
  82029. */
  82030. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82031. /**
  82032. * Define this method to modify the default behavior when loading material properties.
  82033. * @param context The context when loading the asset
  82034. * @param material The glTF material property
  82035. * @param babylonMaterial The Babylon material
  82036. * @returns A promise that resolves when the load is complete or null if not handled
  82037. */
  82038. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82039. /**
  82040. * Define this method to modify the default behavior when loading texture infos.
  82041. * @param context The context when loading the asset
  82042. * @param textureInfo The glTF texture info property
  82043. * @param assign A function called synchronously after parsing the glTF properties
  82044. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82045. */
  82046. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82047. /**
  82048. * @hidden
  82049. * Define this method to modify the default behavior when loading textures.
  82050. * @param context The context when loading the asset
  82051. * @param texture The glTF texture property
  82052. * @param assign A function called synchronously after parsing the glTF properties
  82053. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82054. */
  82055. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82056. /**
  82057. * Define this method to modify the default behavior when loading animations.
  82058. * @param context The context when loading the asset
  82059. * @param animation The glTF animation property
  82060. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82061. */
  82062. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82063. /**
  82064. * @hidden
  82065. * Define this method to modify the default behavior when loading skins.
  82066. * @param context The context when loading the asset
  82067. * @param node The glTF node property
  82068. * @param skin The glTF skin property
  82069. * @returns A promise that resolves when the load is complete or null if not handled
  82070. */
  82071. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82072. /**
  82073. * @hidden
  82074. * Define this method to modify the default behavior when loading uris.
  82075. * @param context The context when loading the asset
  82076. * @param property The glTF property associated with the uri
  82077. * @param uri The uri to load
  82078. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82079. */
  82080. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82081. /**
  82082. * Define this method to modify the default behavior when loading buffer views.
  82083. * @param context The context when loading the asset
  82084. * @param bufferView The glTF buffer view property
  82085. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82086. */
  82087. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82088. /**
  82089. * Define this method to modify the default behavior when loading buffers.
  82090. * @param context The context when loading the asset
  82091. * @param buffer The glTF buffer property
  82092. * @param byteOffset The byte offset to load
  82093. * @param byteLength The byte length to load
  82094. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82095. */
  82096. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82097. }
  82098. }
  82099. declare module BABYLON.GLTF2 {
  82100. /**
  82101. * Helper class for working with arrays when loading the glTF asset
  82102. */
  82103. export class ArrayItem {
  82104. /**
  82105. * Gets an item from the given array.
  82106. * @param context The context when loading the asset
  82107. * @param array The array to get the item from
  82108. * @param index The index to the array
  82109. * @returns The array item
  82110. */
  82111. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82112. /**
  82113. * Assign an `index` field to each item of the given array.
  82114. * @param array The array of items
  82115. */
  82116. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82117. }
  82118. /**
  82119. * The glTF 2.0 loader
  82120. */
  82121. export class GLTFLoader implements IGLTFLoader {
  82122. /** @hidden */
  82123. _completePromises: Promise<any>[];
  82124. /** @hidden */
  82125. _forAssetContainer: boolean;
  82126. /** Storage */
  82127. _babylonLights: Light[];
  82128. /** @hidden */
  82129. _disableInstancedMesh: number;
  82130. private _disposed;
  82131. private _parent;
  82132. private _state;
  82133. private _extensions;
  82134. private _rootUrl;
  82135. private _fileName;
  82136. private _uniqueRootUrl;
  82137. private _gltf;
  82138. private _bin;
  82139. private _babylonScene;
  82140. private _rootBabylonMesh;
  82141. private _defaultBabylonMaterialData;
  82142. private static _RegisteredExtensions;
  82143. /**
  82144. * The default glTF sampler.
  82145. */
  82146. static readonly DefaultSampler: ISampler;
  82147. /**
  82148. * Registers a loader extension.
  82149. * @param name The name of the loader extension.
  82150. * @param factory The factory function that creates the loader extension.
  82151. */
  82152. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82153. /**
  82154. * Unregisters a loader extension.
  82155. * @param name The name of the loader extension.
  82156. * @returns A boolean indicating whether the extension has been unregistered
  82157. */
  82158. static UnregisterExtension(name: string): boolean;
  82159. /**
  82160. * The loader state.
  82161. */
  82162. get state(): Nullable<GLTFLoaderState>;
  82163. /**
  82164. * The object that represents the glTF JSON.
  82165. */
  82166. get gltf(): IGLTF;
  82167. /**
  82168. * The BIN chunk of a binary glTF.
  82169. */
  82170. get bin(): Nullable<IDataBuffer>;
  82171. /**
  82172. * The parent file loader.
  82173. */
  82174. get parent(): GLTFFileLoader;
  82175. /**
  82176. * The Babylon scene when loading the asset.
  82177. */
  82178. get babylonScene(): Scene;
  82179. /**
  82180. * The root Babylon mesh when loading the asset.
  82181. */
  82182. get rootBabylonMesh(): Mesh;
  82183. /** @hidden */
  82184. constructor(parent: GLTFFileLoader);
  82185. /** @hidden */
  82186. dispose(): void;
  82187. /** @hidden */
  82188. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82189. /** @hidden */
  82190. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82191. private _loadAsync;
  82192. private _loadData;
  82193. private _setupData;
  82194. private _loadExtensions;
  82195. private _checkExtensions;
  82196. private _setState;
  82197. private _createRootNode;
  82198. /**
  82199. * Loads a glTF scene.
  82200. * @param context The context when loading the asset
  82201. * @param scene The glTF scene property
  82202. * @returns A promise that resolves when the load is complete
  82203. */
  82204. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82205. private _forEachPrimitive;
  82206. private _getMeshes;
  82207. private _getTransformNodes;
  82208. private _getSkeletons;
  82209. private _getAnimationGroups;
  82210. private _startAnimations;
  82211. /**
  82212. * Loads a glTF node.
  82213. * @param context The context when loading the asset
  82214. * @param node The glTF node property
  82215. * @param assign A function called synchronously after parsing the glTF properties
  82216. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82217. */
  82218. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82219. private _loadMeshAsync;
  82220. /**
  82221. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82222. * @param context The context when loading the asset
  82223. * @param name The mesh name when loading the asset
  82224. * @param node The glTF node when loading the asset
  82225. * @param mesh The glTF mesh when loading the asset
  82226. * @param primitive The glTF mesh primitive property
  82227. * @param assign A function called synchronously after parsing the glTF properties
  82228. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82229. */
  82230. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82231. private _loadVertexDataAsync;
  82232. private _createMorphTargets;
  82233. private _loadMorphTargetsAsync;
  82234. private _loadMorphTargetVertexDataAsync;
  82235. private static _LoadTransform;
  82236. private _loadSkinAsync;
  82237. private _loadBones;
  82238. private _loadBone;
  82239. private _loadSkinInverseBindMatricesDataAsync;
  82240. private _updateBoneMatrices;
  82241. private _getNodeMatrix;
  82242. /**
  82243. * Loads a glTF camera.
  82244. * @param context The context when loading the asset
  82245. * @param camera The glTF camera property
  82246. * @param assign A function called synchronously after parsing the glTF properties
  82247. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82248. */
  82249. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82250. private _loadAnimationsAsync;
  82251. /**
  82252. * Loads a glTF animation.
  82253. * @param context The context when loading the asset
  82254. * @param animation The glTF animation property
  82255. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82256. */
  82257. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82258. /**
  82259. * @hidden Loads a glTF animation channel.
  82260. * @param context The context when loading the asset
  82261. * @param animationContext The context of the animation when loading the asset
  82262. * @param animation The glTF animation property
  82263. * @param channel The glTF animation channel property
  82264. * @param babylonAnimationGroup The babylon animation group property
  82265. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82266. * @returns A void promise when the channel load is complete
  82267. */
  82268. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82269. private _loadAnimationSamplerAsync;
  82270. private _loadBufferAsync;
  82271. /**
  82272. * Loads a glTF buffer view.
  82273. * @param context The context when loading the asset
  82274. * @param bufferView The glTF buffer view property
  82275. * @returns A promise that resolves with the loaded data when the load is complete
  82276. */
  82277. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82278. private _loadAccessorAsync;
  82279. /** @hidden */
  82280. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82281. private _loadIndicesAccessorAsync;
  82282. private _loadVertexBufferViewAsync;
  82283. private _loadVertexAccessorAsync;
  82284. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82285. /** @hidden */
  82286. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82287. private _createDefaultMaterial;
  82288. /**
  82289. * Creates a Babylon material from a glTF material.
  82290. * @param context The context when loading the asset
  82291. * @param material The glTF material property
  82292. * @param babylonDrawMode The draw mode for the Babylon material
  82293. * @returns The Babylon material
  82294. */
  82295. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82296. /**
  82297. * Loads properties from a glTF material into a Babylon material.
  82298. * @param context The context when loading the asset
  82299. * @param material The glTF material property
  82300. * @param babylonMaterial The Babylon material
  82301. * @returns A promise that resolves when the load is complete
  82302. */
  82303. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82304. /**
  82305. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82306. * @param context The context when loading the asset
  82307. * @param material The glTF material property
  82308. * @param babylonMaterial The Babylon material
  82309. * @returns A promise that resolves when the load is complete
  82310. */
  82311. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82312. /**
  82313. * Loads the alpha properties from a glTF material into a Babylon material.
  82314. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82315. * @param context The context when loading the asset
  82316. * @param material The glTF material property
  82317. * @param babylonMaterial The Babylon material
  82318. */
  82319. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82320. /**
  82321. * Loads a glTF texture info.
  82322. * @param context The context when loading the asset
  82323. * @param textureInfo The glTF texture info property
  82324. * @param assign A function called synchronously after parsing the glTF properties
  82325. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82326. */
  82327. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82328. /** @hidden */
  82329. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82330. /** @hidden */
  82331. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82332. private _loadSampler;
  82333. /**
  82334. * Loads a glTF image.
  82335. * @param context The context when loading the asset
  82336. * @param image The glTF image property
  82337. * @returns A promise that resolves with the loaded data when the load is complete
  82338. */
  82339. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82340. /**
  82341. * Loads a glTF uri.
  82342. * @param context The context when loading the asset
  82343. * @param property The glTF property associated with the uri
  82344. * @param uri The base64 or relative uri
  82345. * @returns A promise that resolves with the loaded data when the load is complete
  82346. */
  82347. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82348. /**
  82349. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82350. * @param babylonObject the Babylon object with metadata
  82351. * @param pointer the JSON pointer
  82352. */
  82353. static AddPointerMetadata(babylonObject: {
  82354. metadata: any;
  82355. }, pointer: string): void;
  82356. private static _GetTextureWrapMode;
  82357. private static _GetTextureSamplingMode;
  82358. private static _GetTypedArrayConstructor;
  82359. private static _GetTypedArray;
  82360. private static _GetNumComponents;
  82361. private static _ValidateUri;
  82362. /** @hidden */
  82363. static _GetDrawMode(context: string, mode: number | undefined): number;
  82364. private _compileMaterialsAsync;
  82365. private _compileShadowGeneratorsAsync;
  82366. private _forEachExtensions;
  82367. private _applyExtensions;
  82368. private _extensionsOnLoading;
  82369. private _extensionsOnReady;
  82370. private _extensionsLoadSceneAsync;
  82371. private _extensionsLoadNodeAsync;
  82372. private _extensionsLoadCameraAsync;
  82373. private _extensionsLoadVertexDataAsync;
  82374. private _extensionsLoadMeshPrimitiveAsync;
  82375. private _extensionsLoadMaterialAsync;
  82376. private _extensionsCreateMaterial;
  82377. private _extensionsLoadMaterialPropertiesAsync;
  82378. private _extensionsLoadTextureInfoAsync;
  82379. private _extensionsLoadTextureAsync;
  82380. private _extensionsLoadAnimationAsync;
  82381. private _extensionsLoadSkinAsync;
  82382. private _extensionsLoadUriAsync;
  82383. private _extensionsLoadBufferViewAsync;
  82384. private _extensionsLoadBufferAsync;
  82385. /**
  82386. * Helper method called by a loader extension to load an glTF extension.
  82387. * @param context The context when loading the asset
  82388. * @param property The glTF property to load the extension from
  82389. * @param extensionName The name of the extension to load
  82390. * @param actionAsync The action to run
  82391. * @returns The promise returned by actionAsync or null if the extension does not exist
  82392. */
  82393. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82394. /**
  82395. * Helper method called by a loader extension to load a glTF extra.
  82396. * @param context The context when loading the asset
  82397. * @param property The glTF property to load the extra from
  82398. * @param extensionName The name of the extension to load
  82399. * @param actionAsync The action to run
  82400. * @returns The promise returned by actionAsync or null if the extra does not exist
  82401. */
  82402. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82403. /**
  82404. * Checks for presence of an extension.
  82405. * @param name The name of the extension to check
  82406. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82407. */
  82408. isExtensionUsed(name: string): boolean;
  82409. /**
  82410. * Increments the indentation level and logs a message.
  82411. * @param message The message to log
  82412. */
  82413. logOpen(message: string): void;
  82414. /**
  82415. * Decrements the indentation level.
  82416. */
  82417. logClose(): void;
  82418. /**
  82419. * Logs a message
  82420. * @param message The message to log
  82421. */
  82422. log(message: string): void;
  82423. /**
  82424. * Starts a performance counter.
  82425. * @param counterName The name of the performance counter
  82426. */
  82427. startPerformanceCounter(counterName: string): void;
  82428. /**
  82429. * Ends a performance counter.
  82430. * @param counterName The name of the performance counter
  82431. */
  82432. endPerformanceCounter(counterName: string): void;
  82433. }
  82434. }
  82435. declare module BABYLON.GLTF2.Loader.Extensions {
  82436. /** @hidden */
  82437. interface IEXTLightsImageBased_LightImageBased {
  82438. _babylonTexture?: BaseTexture;
  82439. _loaded?: Promise<void>;
  82440. }
  82441. /**
  82442. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82443. */
  82444. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82445. /**
  82446. * The name of this extension.
  82447. */
  82448. readonly name: string;
  82449. /**
  82450. * Defines whether this extension is enabled.
  82451. */
  82452. enabled: boolean;
  82453. private _loader;
  82454. private _lights?;
  82455. /** @hidden */
  82456. constructor(loader: GLTFLoader);
  82457. /** @hidden */
  82458. dispose(): void;
  82459. /** @hidden */
  82460. onLoading(): void;
  82461. /** @hidden */
  82462. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82463. private _loadLightAsync;
  82464. }
  82465. }
  82466. declare module BABYLON.GLTF2.Loader.Extensions {
  82467. /**
  82468. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82469. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82470. * !!! Experimental Extension Subject to Changes !!!
  82471. */
  82472. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82473. /**
  82474. * The name of this extension.
  82475. */
  82476. readonly name: string;
  82477. /**
  82478. * Defines whether this extension is enabled.
  82479. */
  82480. enabled: boolean;
  82481. private _loader;
  82482. /** @hidden */
  82483. constructor(loader: GLTFLoader);
  82484. /** @hidden */
  82485. dispose(): void;
  82486. /** @hidden */
  82487. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82488. }
  82489. }
  82490. declare module BABYLON.GLTF2.Loader.Extensions {
  82491. /**
  82492. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82493. */
  82494. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82495. /** The name of this extension. */
  82496. readonly name: string;
  82497. /** Defines whether this extension is enabled. */
  82498. enabled: boolean;
  82499. private _loader;
  82500. /** @hidden */
  82501. constructor(loader: GLTFLoader);
  82502. /** @hidden */
  82503. dispose(): void;
  82504. /** @hidden */
  82505. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82506. }
  82507. }
  82508. declare module BABYLON.GLTF2.Loader.Extensions {
  82509. /**
  82510. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82511. */
  82512. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82513. /**
  82514. * The name of this extension.
  82515. */
  82516. readonly name: string;
  82517. /**
  82518. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82519. */
  82520. dracoCompression?: DracoCompression;
  82521. /**
  82522. * Defines whether this extension is enabled.
  82523. */
  82524. enabled: boolean;
  82525. private _loader;
  82526. /** @hidden */
  82527. constructor(loader: GLTFLoader);
  82528. /** @hidden */
  82529. dispose(): void;
  82530. /** @hidden */
  82531. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82532. }
  82533. }
  82534. declare module BABYLON.GLTF2.Loader.Extensions {
  82535. /**
  82536. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82537. */
  82538. export class KHR_lights implements IGLTFLoaderExtension {
  82539. /**
  82540. * The name of this extension.
  82541. */
  82542. readonly name: string;
  82543. /**
  82544. * Defines whether this extension is enabled.
  82545. */
  82546. enabled: boolean;
  82547. private _loader;
  82548. private _lights?;
  82549. /** @hidden */
  82550. constructor(loader: GLTFLoader);
  82551. /** @hidden */
  82552. dispose(): void;
  82553. /** @hidden */
  82554. onLoading(): void;
  82555. /** @hidden */
  82556. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82557. }
  82558. }
  82559. declare module BABYLON.GLTF2.Loader.Extensions {
  82560. /**
  82561. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82562. */
  82563. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82564. /**
  82565. * The name of this extension.
  82566. */
  82567. readonly name: string;
  82568. /**
  82569. * Defines whether this extension is enabled.
  82570. */
  82571. enabled: boolean;
  82572. /**
  82573. * Defines a number that determines the order the extensions are applied.
  82574. */
  82575. order: number;
  82576. private _loader;
  82577. /** @hidden */
  82578. constructor(loader: GLTFLoader);
  82579. /** @hidden */
  82580. dispose(): void;
  82581. /** @hidden */
  82582. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82583. private _loadSpecularGlossinessPropertiesAsync;
  82584. }
  82585. }
  82586. declare module BABYLON.GLTF2.Loader.Extensions {
  82587. /**
  82588. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82589. */
  82590. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82591. /**
  82592. * The name of this extension.
  82593. */
  82594. readonly name: string;
  82595. /**
  82596. * Defines whether this extension is enabled.
  82597. */
  82598. enabled: boolean;
  82599. /**
  82600. * Defines a number that determines the order the extensions are applied.
  82601. */
  82602. order: number;
  82603. private _loader;
  82604. /** @hidden */
  82605. constructor(loader: GLTFLoader);
  82606. /** @hidden */
  82607. dispose(): void;
  82608. /** @hidden */
  82609. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82610. private _loadUnlitPropertiesAsync;
  82611. }
  82612. }
  82613. declare module BABYLON.GLTF2.Loader.Extensions {
  82614. /**
  82615. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82616. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82617. * !!! Experimental Extension Subject to Changes !!!
  82618. */
  82619. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82620. /**
  82621. * The name of this extension.
  82622. */
  82623. readonly name: string;
  82624. /**
  82625. * Defines whether this extension is enabled.
  82626. */
  82627. enabled: boolean;
  82628. /**
  82629. * Defines a number that determines the order the extensions are applied.
  82630. */
  82631. order: number;
  82632. private _loader;
  82633. /** @hidden */
  82634. constructor(loader: GLTFLoader);
  82635. /** @hidden */
  82636. dispose(): void;
  82637. /** @hidden */
  82638. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82639. private _loadClearCoatPropertiesAsync;
  82640. }
  82641. }
  82642. declare module BABYLON.GLTF2.Loader.Extensions {
  82643. /**
  82644. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82645. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82646. * !!! Experimental Extension Subject to Changes !!!
  82647. */
  82648. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82649. /**
  82650. * The name of this extension.
  82651. */
  82652. readonly name: string;
  82653. /**
  82654. * Defines whether this extension is enabled.
  82655. */
  82656. enabled: boolean;
  82657. /**
  82658. * Defines a number that determines the order the extensions are applied.
  82659. */
  82660. order: number;
  82661. private _loader;
  82662. /** @hidden */
  82663. constructor(loader: GLTFLoader);
  82664. /** @hidden */
  82665. dispose(): void;
  82666. /** @hidden */
  82667. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82668. private _loadSheenPropertiesAsync;
  82669. }
  82670. }
  82671. declare module BABYLON.GLTF2.Loader.Extensions {
  82672. /**
  82673. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82674. * !!! Experimental Extension Subject to Changes !!!
  82675. */
  82676. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82677. /**
  82678. * The name of this extension.
  82679. */
  82680. readonly name: string;
  82681. /**
  82682. * Defines whether this extension is enabled.
  82683. */
  82684. enabled: boolean;
  82685. /**
  82686. * Defines a number that determines the order the extensions are applied.
  82687. */
  82688. order: number;
  82689. private _loader;
  82690. /** @hidden */
  82691. constructor(loader: GLTFLoader);
  82692. /** @hidden */
  82693. dispose(): void;
  82694. /** @hidden */
  82695. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82696. private _loadSpecularPropertiesAsync;
  82697. }
  82698. }
  82699. declare module BABYLON.GLTF2.Loader.Extensions {
  82700. /**
  82701. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82702. * !!! Experimental Extension Subject to Changes !!!
  82703. */
  82704. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82705. /**
  82706. * Default ior Value from the spec.
  82707. */
  82708. private static readonly _DEFAULT_IOR;
  82709. /**
  82710. * The name of this extension.
  82711. */
  82712. readonly name: string;
  82713. /**
  82714. * Defines whether this extension is enabled.
  82715. */
  82716. enabled: boolean;
  82717. /**
  82718. * Defines a number that determines the order the extensions are applied.
  82719. */
  82720. order: number;
  82721. private _loader;
  82722. /** @hidden */
  82723. constructor(loader: GLTFLoader);
  82724. /** @hidden */
  82725. dispose(): void;
  82726. /** @hidden */
  82727. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82728. private _loadIorPropertiesAsync;
  82729. }
  82730. }
  82731. declare module BABYLON.GLTF2.Loader.Extensions {
  82732. /**
  82733. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82734. * !!! Experimental Extension Subject to Changes !!!
  82735. */
  82736. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82737. /**
  82738. * The name of this extension.
  82739. */
  82740. readonly name: string;
  82741. /**
  82742. * Defines whether this extension is enabled.
  82743. */
  82744. enabled: boolean;
  82745. private _loader;
  82746. private _variants?;
  82747. /** @hidden */
  82748. constructor(loader: GLTFLoader);
  82749. /** @hidden */
  82750. dispose(): void;
  82751. /**
  82752. * Gets the list of available variant names for this asset.
  82753. * @param rootMesh The glTF root mesh
  82754. * @returns the list of all the variant names for this model
  82755. */
  82756. static GetAvailableVariants(rootMesh: Mesh): string[];
  82757. /**
  82758. * Gets the list of available variant names for this asset.
  82759. * @param rootMesh The glTF root mesh
  82760. * @returns the list of all the variant names for this model
  82761. */
  82762. getAvailableVariants(rootMesh: Mesh): string[];
  82763. /**
  82764. * Select a variant given a variant name or a list of variant names.
  82765. * @param rootMesh The glTF root mesh
  82766. * @param variantName The variant name(s) to select.
  82767. */
  82768. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82769. /**
  82770. * Select a variant given a variant name or a list of variant names.
  82771. * @param rootMesh The glTF root mesh
  82772. * @param variantName The variant name(s) to select.
  82773. */
  82774. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82775. /**
  82776. * Reset back to the original before selecting a variant.
  82777. * @param rootMesh The glTF root mesh
  82778. */
  82779. static Reset(rootMesh: Mesh): void;
  82780. /**
  82781. * Reset back to the original before selecting a variant.
  82782. * @param rootMesh The glTF root mesh
  82783. */
  82784. reset(rootMesh: Mesh): void;
  82785. /**
  82786. * Gets the last selected variant name(s) or null if original.
  82787. * @param rootMesh The glTF root mesh
  82788. * @returns The selected variant name(s).
  82789. */
  82790. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82791. /**
  82792. * Gets the last selected variant name(s) or null if original.
  82793. * @param rootMesh The glTF root mesh
  82794. * @returns The selected variant name(s).
  82795. */
  82796. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82797. private static _GetExtensionMetadata;
  82798. /** @hidden */
  82799. onLoading(): void;
  82800. /** @hidden */
  82801. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82802. }
  82803. }
  82804. declare module BABYLON.GLTF2.Loader.Extensions {
  82805. /**
  82806. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82807. * !!! Experimental Extension Subject to Changes !!!
  82808. */
  82809. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82810. /**
  82811. * The name of this extension.
  82812. */
  82813. readonly name: string;
  82814. /**
  82815. * Defines whether this extension is enabled.
  82816. */
  82817. enabled: boolean;
  82818. /**
  82819. * Defines a number that determines the order the extensions are applied.
  82820. */
  82821. order: number;
  82822. private _loader;
  82823. /** @hidden */
  82824. constructor(loader: GLTFLoader);
  82825. /** @hidden */
  82826. dispose(): void;
  82827. /** @hidden */
  82828. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82829. private _loadTransparentPropertiesAsync;
  82830. }
  82831. }
  82832. declare module BABYLON.GLTF2.Loader.Extensions {
  82833. /**
  82834. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82835. */
  82836. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82837. /**
  82838. * The name of this extension.
  82839. */
  82840. readonly name: string;
  82841. /**
  82842. * Defines whether this extension is enabled.
  82843. */
  82844. enabled: boolean;
  82845. /** @hidden */
  82846. constructor(loader: GLTFLoader);
  82847. /** @hidden */
  82848. dispose(): void;
  82849. }
  82850. }
  82851. declare module BABYLON.GLTF2.Loader.Extensions {
  82852. /**
  82853. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82854. * !!! Experimental Extension Subject to Changes !!!
  82855. */
  82856. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82857. /** The name of this extension. */
  82858. readonly name: string;
  82859. /** Defines whether this extension is enabled. */
  82860. enabled: boolean;
  82861. private _loader;
  82862. /** @hidden */
  82863. constructor(loader: GLTFLoader);
  82864. /** @hidden */
  82865. dispose(): void;
  82866. /** @hidden */
  82867. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82868. }
  82869. }
  82870. declare module BABYLON.GLTF2.Loader.Extensions {
  82871. /**
  82872. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82873. */
  82874. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82875. /**
  82876. * The name of this extension.
  82877. */
  82878. readonly name: string;
  82879. /**
  82880. * Defines whether this extension is enabled.
  82881. */
  82882. enabled: boolean;
  82883. private _loader;
  82884. /** @hidden */
  82885. constructor(loader: GLTFLoader);
  82886. /** @hidden */
  82887. dispose(): void;
  82888. /** @hidden */
  82889. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82890. }
  82891. }
  82892. declare module BABYLON.GLTF2.Loader.Extensions {
  82893. /**
  82894. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82895. * !!! Experimental Extension Subject to Changes !!!
  82896. */
  82897. export class KHR_xmp implements IGLTFLoaderExtension {
  82898. /**
  82899. * The name of this extension.
  82900. */
  82901. readonly name: string;
  82902. /**
  82903. * Defines whether this extension is enabled.
  82904. */
  82905. enabled: boolean;
  82906. /**
  82907. * Defines a number that determines the order the extensions are applied.
  82908. */
  82909. order: number;
  82910. private _loader;
  82911. /** @hidden */
  82912. constructor(loader: GLTFLoader);
  82913. /** @hidden */
  82914. dispose(): void;
  82915. /**
  82916. * Called after the loader state changes to LOADING.
  82917. */
  82918. onLoading(): void;
  82919. }
  82920. }
  82921. declare module BABYLON.GLTF2.Loader.Extensions {
  82922. /**
  82923. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82924. */
  82925. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82926. /**
  82927. * The name of this extension.
  82928. */
  82929. readonly name: string;
  82930. /**
  82931. * Defines whether this extension is enabled.
  82932. */
  82933. enabled: boolean;
  82934. private _loader;
  82935. private _clips;
  82936. private _emitters;
  82937. /** @hidden */
  82938. constructor(loader: GLTFLoader);
  82939. /** @hidden */
  82940. dispose(): void;
  82941. /** @hidden */
  82942. onLoading(): void;
  82943. /** @hidden */
  82944. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82945. /** @hidden */
  82946. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82947. /** @hidden */
  82948. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82949. private _loadClipAsync;
  82950. private _loadEmitterAsync;
  82951. private _getEventAction;
  82952. private _loadAnimationEventAsync;
  82953. }
  82954. }
  82955. declare module BABYLON.GLTF2.Loader.Extensions {
  82956. /**
  82957. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82958. */
  82959. export class MSFT_lod implements IGLTFLoaderExtension {
  82960. /**
  82961. * The name of this extension.
  82962. */
  82963. readonly name: string;
  82964. /**
  82965. * Defines whether this extension is enabled.
  82966. */
  82967. enabled: boolean;
  82968. /**
  82969. * Defines a number that determines the order the extensions are applied.
  82970. */
  82971. order: number;
  82972. /**
  82973. * Maximum number of LODs to load, starting from the lowest LOD.
  82974. */
  82975. maxLODsToLoad: number;
  82976. /**
  82977. * Observable raised when all node LODs of one level are loaded.
  82978. * The event data is the index of the loaded LOD starting from zero.
  82979. * Dispose the loader to cancel the loading of the next level of LODs.
  82980. */
  82981. onNodeLODsLoadedObservable: Observable<number>;
  82982. /**
  82983. * Observable raised when all material LODs of one level are loaded.
  82984. * The event data is the index of the loaded LOD starting from zero.
  82985. * Dispose the loader to cancel the loading of the next level of LODs.
  82986. */
  82987. onMaterialLODsLoadedObservable: Observable<number>;
  82988. private _loader;
  82989. private _bufferLODs;
  82990. private _nodeIndexLOD;
  82991. private _nodeSignalLODs;
  82992. private _nodePromiseLODs;
  82993. private _nodeBufferLODs;
  82994. private _materialIndexLOD;
  82995. private _materialSignalLODs;
  82996. private _materialPromiseLODs;
  82997. private _materialBufferLODs;
  82998. /** @hidden */
  82999. constructor(loader: GLTFLoader);
  83000. /** @hidden */
  83001. dispose(): void;
  83002. /** @hidden */
  83003. onReady(): void;
  83004. /** @hidden */
  83005. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83006. /** @hidden */
  83007. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83008. /** @hidden */
  83009. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83010. /** @hidden */
  83011. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83012. /** @hidden */
  83013. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83014. private _loadBufferLOD;
  83015. /**
  83016. * Gets an array of LOD properties from lowest to highest.
  83017. */
  83018. private _getLODs;
  83019. private _disposeTransformNode;
  83020. private _disposeMaterials;
  83021. }
  83022. }
  83023. declare module BABYLON.GLTF2.Loader.Extensions {
  83024. /** @hidden */
  83025. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83026. readonly name: string;
  83027. enabled: boolean;
  83028. private _loader;
  83029. constructor(loader: GLTFLoader);
  83030. dispose(): void;
  83031. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83032. }
  83033. }
  83034. declare module BABYLON.GLTF2.Loader.Extensions {
  83035. /** @hidden */
  83036. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83037. readonly name: string;
  83038. enabled: boolean;
  83039. private _loader;
  83040. constructor(loader: GLTFLoader);
  83041. dispose(): void;
  83042. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83043. }
  83044. }
  83045. declare module BABYLON.GLTF2.Loader.Extensions {
  83046. /**
  83047. * Store glTF extras (if present) in BJS objects' metadata
  83048. */
  83049. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83050. /**
  83051. * The name of this extension.
  83052. */
  83053. readonly name: string;
  83054. /**
  83055. * Defines whether this extension is enabled.
  83056. */
  83057. enabled: boolean;
  83058. private _loader;
  83059. private _assignExtras;
  83060. /** @hidden */
  83061. constructor(loader: GLTFLoader);
  83062. /** @hidden */
  83063. dispose(): void;
  83064. /** @hidden */
  83065. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83066. /** @hidden */
  83067. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83068. /** @hidden */
  83069. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83070. }
  83071. }
  83072. declare module BABYLON {
  83073. /**
  83074. * Class reading and parsing the MTL file bundled with the obj file.
  83075. */
  83076. export class MTLFileLoader {
  83077. /**
  83078. * Invert Y-Axis of referenced textures on load
  83079. */
  83080. static INVERT_TEXTURE_Y: boolean;
  83081. /**
  83082. * All material loaded from the mtl will be set here
  83083. */
  83084. materials: StandardMaterial[];
  83085. /**
  83086. * This function will read the mtl file and create each material described inside
  83087. * This function could be improve by adding :
  83088. * -some component missing (Ni, Tf...)
  83089. * -including the specific options available
  83090. *
  83091. * @param scene defines the scene the material will be created in
  83092. * @param data defines the mtl data to parse
  83093. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83094. * @param forAssetContainer defines if the material should be registered in the scene
  83095. */
  83096. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83097. /**
  83098. * Gets the texture for the material.
  83099. *
  83100. * If the material is imported from input file,
  83101. * We sanitize the url to ensure it takes the textre from aside the material.
  83102. *
  83103. * @param rootUrl The root url to load from
  83104. * @param value The value stored in the mtl
  83105. * @return The Texture
  83106. */
  83107. private static _getTexture;
  83108. }
  83109. }
  83110. declare module BABYLON {
  83111. /**
  83112. * Options for loading OBJ/MTL files
  83113. */
  83114. type MeshLoadOptions = {
  83115. /**
  83116. * Defines if UVs are optimized by default during load.
  83117. */
  83118. OptimizeWithUV: boolean;
  83119. /**
  83120. * Defines custom scaling of UV coordinates of loaded meshes.
  83121. */
  83122. UVScaling: Vector2;
  83123. /**
  83124. * Invert model on y-axis (does a model scaling inversion)
  83125. */
  83126. InvertY: boolean;
  83127. /**
  83128. * Invert Y-Axis of referenced textures on load
  83129. */
  83130. InvertTextureY: boolean;
  83131. /**
  83132. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83133. */
  83134. ImportVertexColors: boolean;
  83135. /**
  83136. * Compute the normals for the model, even if normals are present in the file.
  83137. */
  83138. ComputeNormals: boolean;
  83139. /**
  83140. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83141. */
  83142. SkipMaterials: boolean;
  83143. /**
  83144. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83145. */
  83146. MaterialLoadingFailsSilently: boolean;
  83147. };
  83148. /**
  83149. * OBJ file type loader.
  83150. * This is a babylon scene loader plugin.
  83151. */
  83152. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83153. /**
  83154. * Defines if UVs are optimized by default during load.
  83155. */
  83156. static OPTIMIZE_WITH_UV: boolean;
  83157. /**
  83158. * Invert model on y-axis (does a model scaling inversion)
  83159. */
  83160. static INVERT_Y: boolean;
  83161. /**
  83162. * Invert Y-Axis of referenced textures on load
  83163. */
  83164. static get INVERT_TEXTURE_Y(): boolean;
  83165. static set INVERT_TEXTURE_Y(value: boolean);
  83166. /**
  83167. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83168. */
  83169. static IMPORT_VERTEX_COLORS: boolean;
  83170. /**
  83171. * Compute the normals for the model, even if normals are present in the file.
  83172. */
  83173. static COMPUTE_NORMALS: boolean;
  83174. /**
  83175. * Defines custom scaling of UV coordinates of loaded meshes.
  83176. */
  83177. static UV_SCALING: Vector2;
  83178. /**
  83179. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83180. */
  83181. static SKIP_MATERIALS: boolean;
  83182. /**
  83183. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83184. *
  83185. * Defaults to true for backwards compatibility.
  83186. */
  83187. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83188. /**
  83189. * Defines the name of the plugin.
  83190. */
  83191. name: string;
  83192. /**
  83193. * Defines the extension the plugin is able to load.
  83194. */
  83195. extensions: string;
  83196. /** @hidden */
  83197. obj: RegExp;
  83198. /** @hidden */
  83199. group: RegExp;
  83200. /** @hidden */
  83201. mtllib: RegExp;
  83202. /** @hidden */
  83203. usemtl: RegExp;
  83204. /** @hidden */
  83205. smooth: RegExp;
  83206. /** @hidden */
  83207. vertexPattern: RegExp;
  83208. /** @hidden */
  83209. normalPattern: RegExp;
  83210. /** @hidden */
  83211. uvPattern: RegExp;
  83212. /** @hidden */
  83213. facePattern1: RegExp;
  83214. /** @hidden */
  83215. facePattern2: RegExp;
  83216. /** @hidden */
  83217. facePattern3: RegExp;
  83218. /** @hidden */
  83219. facePattern4: RegExp;
  83220. /** @hidden */
  83221. facePattern5: RegExp;
  83222. private _forAssetContainer;
  83223. private _meshLoadOptions;
  83224. /**
  83225. * Creates loader for .OBJ files
  83226. *
  83227. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83228. */
  83229. constructor(meshLoadOptions?: MeshLoadOptions);
  83230. private static get currentMeshLoadOptions();
  83231. /**
  83232. * Calls synchronously the MTL file attached to this obj.
  83233. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83234. * Without this function materials are not displayed in the first frame (but displayed after).
  83235. * In consequence it is impossible to get material information in your HTML file
  83236. *
  83237. * @param url The URL of the MTL file
  83238. * @param rootUrl
  83239. * @param onSuccess Callback function to be called when the MTL file is loaded
  83240. * @private
  83241. */
  83242. private _loadMTL;
  83243. /**
  83244. * Instantiates a OBJ file loader plugin.
  83245. * @returns the created plugin
  83246. */
  83247. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83248. /**
  83249. * If the data string can be loaded directly.
  83250. *
  83251. * @param data string containing the file data
  83252. * @returns if the data can be loaded directly
  83253. */
  83254. canDirectLoad(data: string): boolean;
  83255. /**
  83256. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83257. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83258. * @param scene the scene the meshes should be added to
  83259. * @param data the OBJ data to load
  83260. * @param rootUrl root url to load from
  83261. * @param onProgress event that fires when loading progress has occured
  83262. * @param fileName Defines the name of the file to load
  83263. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83264. */
  83265. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83266. meshes: AbstractMesh[];
  83267. particleSystems: IParticleSystem[];
  83268. skeletons: Skeleton[];
  83269. animationGroups: AnimationGroup[];
  83270. }>;
  83271. /**
  83272. * Imports all objects from the loaded OBJ data and adds them to the scene
  83273. * @param scene the scene the objects should be added to
  83274. * @param data the OBJ data to load
  83275. * @param rootUrl root url to load from
  83276. * @param onProgress event that fires when loading progress has occured
  83277. * @param fileName Defines the name of the file to load
  83278. * @returns a promise which completes when objects have been loaded to the scene
  83279. */
  83280. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83281. /**
  83282. * Load into an asset container.
  83283. * @param scene The scene to load into
  83284. * @param data The data to import
  83285. * @param rootUrl The root url for scene and resources
  83286. * @param onProgress The callback when the load progresses
  83287. * @param fileName Defines the name of the file to load
  83288. * @returns The loaded asset container
  83289. */
  83290. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83291. /**
  83292. * Read the OBJ file and create an Array of meshes.
  83293. * Each mesh contains all information given by the OBJ and the MTL file.
  83294. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83295. *
  83296. * @param meshesNames
  83297. * @param scene Scene The scene where are displayed the data
  83298. * @param data String The content of the obj file
  83299. * @param rootUrl String The path to the folder
  83300. * @returns Array<AbstractMesh>
  83301. * @private
  83302. */
  83303. private _parseSolid;
  83304. }
  83305. }
  83306. declare module BABYLON {
  83307. /**
  83308. * STL file type loader.
  83309. * This is a babylon scene loader plugin.
  83310. */
  83311. export class STLFileLoader implements ISceneLoaderPlugin {
  83312. /** @hidden */
  83313. solidPattern: RegExp;
  83314. /** @hidden */
  83315. facetsPattern: RegExp;
  83316. /** @hidden */
  83317. normalPattern: RegExp;
  83318. /** @hidden */
  83319. vertexPattern: RegExp;
  83320. /**
  83321. * Defines the name of the plugin.
  83322. */
  83323. name: string;
  83324. /**
  83325. * Defines the extensions the stl loader is able to load.
  83326. * force data to come in as an ArrayBuffer
  83327. * we'll convert to string if it looks like it's an ASCII .stl
  83328. */
  83329. extensions: ISceneLoaderPluginExtensions;
  83330. /**
  83331. * Import meshes into a scene.
  83332. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83333. * @param scene The scene to import into
  83334. * @param data The data to import
  83335. * @param rootUrl The root url for scene and resources
  83336. * @param meshes The meshes array to import into
  83337. * @param particleSystems The particle systems array to import into
  83338. * @param skeletons The skeletons array to import into
  83339. * @param onError The callback when import fails
  83340. * @returns True if successful or false otherwise
  83341. */
  83342. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83343. /**
  83344. * Load into a scene.
  83345. * @param scene The scene to load into
  83346. * @param data The data to import
  83347. * @param rootUrl The root url for scene and resources
  83348. * @param onError The callback when import fails
  83349. * @returns true if successful or false otherwise
  83350. */
  83351. load(scene: Scene, data: any, rootUrl: string): boolean;
  83352. /**
  83353. * Load into an asset container.
  83354. * @param scene The scene to load into
  83355. * @param data The data to import
  83356. * @param rootUrl The root url for scene and resources
  83357. * @param onError The callback when import fails
  83358. * @returns The loaded asset container
  83359. */
  83360. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83361. private _isBinary;
  83362. private _parseBinary;
  83363. private _parseASCII;
  83364. }
  83365. }
  83366. declare module BABYLON {
  83367. /**
  83368. * Class for generating OBJ data from a Babylon scene.
  83369. */
  83370. export class OBJExport {
  83371. /**
  83372. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83373. * @param mesh defines the list of meshes to serialize
  83374. * @param materials defines if materials should be exported
  83375. * @param matlibname defines the name of the associated mtl file
  83376. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83377. * @returns the OBJ content
  83378. */
  83379. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83380. /**
  83381. * Exports the material(s) of a mesh in .MTL file format (text)
  83382. * @param mesh defines the mesh to extract the material from
  83383. * @returns the mtl content
  83384. */
  83385. static MTL(mesh: Mesh): string;
  83386. }
  83387. }
  83388. declare module BABYLON {
  83389. /** @hidden */
  83390. export var __IGLTFExporterExtension: number;
  83391. /**
  83392. * Interface for extending the exporter
  83393. * @hidden
  83394. */
  83395. export interface IGLTFExporterExtension {
  83396. /**
  83397. * The name of this extension
  83398. */
  83399. readonly name: string;
  83400. /**
  83401. * Defines whether this extension is enabled
  83402. */
  83403. enabled: boolean;
  83404. /**
  83405. * Defines whether this extension is required
  83406. */
  83407. required: boolean;
  83408. }
  83409. }
  83410. declare module BABYLON.GLTF2.Exporter {
  83411. /** @hidden */
  83412. export var __IGLTFExporterExtensionV2: number;
  83413. /**
  83414. * Interface for a glTF exporter extension
  83415. * @hidden
  83416. */
  83417. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83418. /**
  83419. * Define this method to modify the default behavior before exporting a texture
  83420. * @param context The context when loading the asset
  83421. * @param babylonTexture The Babylon.js texture
  83422. * @param mimeType The mime-type of the generated image
  83423. * @returns A promise that resolves with the exported texture
  83424. */
  83425. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83426. /**
  83427. * Define this method to get notified when a texture info is created
  83428. * @param context The context when loading the asset
  83429. * @param textureInfo The glTF texture info
  83430. * @param babylonTexture The Babylon.js texture
  83431. */
  83432. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83433. /**
  83434. * Define this method to modify the default behavior when exporting texture info
  83435. * @param context The context when loading the asset
  83436. * @param meshPrimitive glTF mesh primitive
  83437. * @param babylonSubMesh Babylon submesh
  83438. * @param binaryWriter glTF serializer binary writer instance
  83439. * @returns nullable IMeshPrimitive promise
  83440. */
  83441. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83442. /**
  83443. * Define this method to modify the default behavior when exporting a node
  83444. * @param context The context when exporting the node
  83445. * @param node glTF node
  83446. * @param babylonNode BabylonJS node
  83447. * @returns nullable INode promise
  83448. */
  83449. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83450. [key: number]: number;
  83451. }): Promise<Nullable<INode>>;
  83452. /**
  83453. * Define this method to modify the default behavior when exporting a material
  83454. * @param material glTF material
  83455. * @param babylonMaterial BabylonJS material
  83456. * @returns nullable IMaterial promise
  83457. */
  83458. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83459. /**
  83460. * Define this method to return additional textures to export from a material
  83461. * @param material glTF material
  83462. * @param babylonMaterial BabylonJS material
  83463. * @returns List of textures
  83464. */
  83465. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83466. /** Gets a boolean indicating that this extension was used */
  83467. wasUsed: boolean;
  83468. /** Gets a boolean indicating that this extension is required for the file to work */
  83469. required: boolean;
  83470. /**
  83471. * Called after the exporter state changes to EXPORTING
  83472. */
  83473. onExporting?(): void;
  83474. }
  83475. }
  83476. declare module BABYLON.GLTF2.Exporter {
  83477. /**
  83478. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83479. * @hidden
  83480. */
  83481. export class _GLTFMaterialExporter {
  83482. /**
  83483. * Represents the dielectric specular values for R, G and B
  83484. */
  83485. private static readonly _DielectricSpecular;
  83486. /**
  83487. * Allows the maximum specular power to be defined for material calculations
  83488. */
  83489. private static readonly _MaxSpecularPower;
  83490. /**
  83491. * Mapping to store textures
  83492. */
  83493. private _textureMap;
  83494. /**
  83495. * Numeric tolerance value
  83496. */
  83497. private static readonly _Epsilon;
  83498. /**
  83499. * Reference to the glTF Exporter
  83500. */
  83501. private _exporter;
  83502. constructor(exporter: _Exporter);
  83503. /**
  83504. * Specifies if two colors are approximately equal in value
  83505. * @param color1 first color to compare to
  83506. * @param color2 second color to compare to
  83507. * @param epsilon threshold value
  83508. */
  83509. private static FuzzyEquals;
  83510. /**
  83511. * Gets the materials from a Babylon scene and converts them to glTF materials
  83512. * @param scene babylonjs scene
  83513. * @param mimeType texture mime type
  83514. * @param images array of images
  83515. * @param textures array of textures
  83516. * @param materials array of materials
  83517. * @param imageData mapping of texture names to base64 textures
  83518. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83519. */
  83520. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83521. /**
  83522. * Makes a copy of the glTF material without the texture parameters
  83523. * @param originalMaterial original glTF material
  83524. * @returns glTF material without texture parameters
  83525. */
  83526. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83527. /**
  83528. * Specifies if the material has any texture parameters present
  83529. * @param material glTF Material
  83530. * @returns boolean specifying if texture parameters are present
  83531. */
  83532. _hasTexturesPresent(material: IMaterial): boolean;
  83533. /**
  83534. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83535. * @param babylonStandardMaterial
  83536. * @returns glTF Metallic Roughness Material representation
  83537. */
  83538. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83539. /**
  83540. * Computes the metallic factor
  83541. * @param diffuse diffused value
  83542. * @param specular specular value
  83543. * @param oneMinusSpecularStrength one minus the specular strength
  83544. * @returns metallic value
  83545. */
  83546. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83547. /**
  83548. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83549. * @param glTFMaterial glTF material
  83550. * @param babylonMaterial Babylon material
  83551. */
  83552. private static _SetAlphaMode;
  83553. /**
  83554. * Converts a Babylon Standard Material to a glTF Material
  83555. * @param babylonStandardMaterial BJS Standard Material
  83556. * @param mimeType mime type to use for the textures
  83557. * @param images array of glTF image interfaces
  83558. * @param textures array of glTF texture interfaces
  83559. * @param materials array of glTF material interfaces
  83560. * @param imageData map of image file name to data
  83561. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83562. */
  83563. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83564. private _finishMaterial;
  83565. /**
  83566. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83567. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83568. * @param mimeType mime type to use for the textures
  83569. * @param images array of glTF image interfaces
  83570. * @param textures array of glTF texture interfaces
  83571. * @param materials array of glTF material interfaces
  83572. * @param imageData map of image file name to data
  83573. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83574. */
  83575. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83576. /**
  83577. * Converts an image typed array buffer to a base64 image
  83578. * @param buffer typed array buffer
  83579. * @param width width of the image
  83580. * @param height height of the image
  83581. * @param mimeType mimetype of the image
  83582. * @returns base64 image string
  83583. */
  83584. private _createBase64FromCanvasAsync;
  83585. /**
  83586. * Generates a white texture based on the specified width and height
  83587. * @param width width of the texture in pixels
  83588. * @param height height of the texture in pixels
  83589. * @param scene babylonjs scene
  83590. * @returns white texture
  83591. */
  83592. private _createWhiteTexture;
  83593. /**
  83594. * 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
  83595. * @param texture1 first texture to resize
  83596. * @param texture2 second texture to resize
  83597. * @param scene babylonjs scene
  83598. * @returns resized textures or null
  83599. */
  83600. private _resizeTexturesToSameDimensions;
  83601. /**
  83602. * Converts an array of pixels to a Float32Array
  83603. * Throws an error if the pixel format is not supported
  83604. * @param pixels - array buffer containing pixel values
  83605. * @returns Float32 of pixels
  83606. */
  83607. private _convertPixelArrayToFloat32;
  83608. /**
  83609. * Convert Specular Glossiness Textures to Metallic Roughness
  83610. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83611. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83612. * @param diffuseTexture texture used to store diffuse information
  83613. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83614. * @param factors specular glossiness material factors
  83615. * @param mimeType the mime type to use for the texture
  83616. * @returns pbr metallic roughness interface or null
  83617. */
  83618. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83619. /**
  83620. * Converts specular glossiness material properties to metallic roughness
  83621. * @param specularGlossiness interface with specular glossiness material properties
  83622. * @returns interface with metallic roughness material properties
  83623. */
  83624. private _convertSpecularGlossinessToMetallicRoughness;
  83625. /**
  83626. * Calculates the surface reflectance, independent of lighting conditions
  83627. * @param color Color source to calculate brightness from
  83628. * @returns number representing the perceived brightness, or zero if color is undefined
  83629. */
  83630. private _getPerceivedBrightness;
  83631. /**
  83632. * Returns the maximum color component value
  83633. * @param color
  83634. * @returns maximum color component value, or zero if color is null or undefined
  83635. */
  83636. private _getMaxComponent;
  83637. /**
  83638. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83639. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83640. * @param mimeType mime type to use for the textures
  83641. * @param images array of glTF image interfaces
  83642. * @param textures array of glTF texture interfaces
  83643. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83644. * @param imageData map of image file name to data
  83645. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83646. * @returns glTF PBR Metallic Roughness factors
  83647. */
  83648. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83649. private _getGLTFTextureSampler;
  83650. private _getGLTFTextureWrapMode;
  83651. private _getGLTFTextureWrapModesSampler;
  83652. /**
  83653. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83654. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83655. * @param mimeType mime type to use for the textures
  83656. * @param images array of glTF image interfaces
  83657. * @param textures array of glTF texture interfaces
  83658. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83659. * @param imageData map of image file name to data
  83660. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83661. * @returns glTF PBR Metallic Roughness factors
  83662. */
  83663. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83664. /**
  83665. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83666. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83667. * @param mimeType mime type to use for the textures
  83668. * @param images array of glTF image interfaces
  83669. * @param textures array of glTF texture interfaces
  83670. * @param materials array of glTF material interfaces
  83671. * @param imageData map of image file name to data
  83672. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83673. */
  83674. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83675. private setMetallicRoughnessPbrMaterial;
  83676. private getPixelsFromTexture;
  83677. /**
  83678. * Extracts a texture from a Babylon texture into file data and glTF data
  83679. * @param babylonTexture Babylon texture to extract
  83680. * @param mimeType Mime Type of the babylonTexture
  83681. * @return glTF texture info, or null if the texture format is not supported
  83682. */
  83683. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83684. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83685. /**
  83686. * Builds a texture from base64 string
  83687. * @param base64Texture base64 texture string
  83688. * @param baseTextureName Name to use for the texture
  83689. * @param mimeType image mime type for the texture
  83690. * @param images array of images
  83691. * @param textures array of textures
  83692. * @param imageData map of image data
  83693. * @returns glTF texture info, or null if the texture format is not supported
  83694. */
  83695. private _getTextureInfoFromBase64;
  83696. }
  83697. }
  83698. declare module BABYLON {
  83699. /**
  83700. * Class for holding and downloading glTF file data
  83701. */
  83702. export class GLTFData {
  83703. /**
  83704. * Object which contains the file name as the key and its data as the value
  83705. */
  83706. glTFFiles: {
  83707. [fileName: string]: string | Blob;
  83708. };
  83709. /**
  83710. * Initializes the glTF file object
  83711. */
  83712. constructor();
  83713. /**
  83714. * Downloads the glTF data as files based on their names and data
  83715. */
  83716. downloadFiles(): void;
  83717. }
  83718. }
  83719. declare module BABYLON {
  83720. /**
  83721. * Holds a collection of exporter options and parameters
  83722. */
  83723. export interface IExportOptions {
  83724. /**
  83725. * Function which indicates whether a babylon node should be exported or not
  83726. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83727. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83728. */
  83729. shouldExportNode?(node: Node): boolean;
  83730. /**
  83731. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83732. * @param metadata source metadata to read from
  83733. * @returns the data to store to glTF node extras
  83734. */
  83735. metadataSelector?(metadata: any): any;
  83736. /**
  83737. * The sample rate to bake animation curves
  83738. */
  83739. animationSampleRate?: number;
  83740. /**
  83741. * Begin serialization without waiting for the scene to be ready
  83742. */
  83743. exportWithoutWaitingForScene?: boolean;
  83744. /**
  83745. * Indicates if coordinate system swapping root nodes should be included in export
  83746. */
  83747. includeCoordinateSystemConversionNodes?: boolean;
  83748. }
  83749. /**
  83750. * Class for generating glTF data from a Babylon scene.
  83751. */
  83752. export class GLTF2Export {
  83753. /**
  83754. * Exports the geometry of the scene to .gltf file format asynchronously
  83755. * @param scene Babylon scene with scene hierarchy information
  83756. * @param filePrefix File prefix to use when generating the glTF file
  83757. * @param options Exporter options
  83758. * @returns Returns an object with a .gltf file and associates texture names
  83759. * as keys and their data and paths as values
  83760. */
  83761. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83762. private static _PreExportAsync;
  83763. private static _PostExportAsync;
  83764. /**
  83765. * Exports the geometry of the scene to .glb file format asychronously
  83766. * @param scene Babylon scene with scene hierarchy information
  83767. * @param filePrefix File prefix to use when generating glb file
  83768. * @param options Exporter options
  83769. * @returns Returns an object with a .glb filename as key and data as value
  83770. */
  83771. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83772. }
  83773. }
  83774. declare module BABYLON.GLTF2.Exporter {
  83775. /**
  83776. * @hidden
  83777. */
  83778. export class _GLTFUtilities {
  83779. /**
  83780. * Creates a buffer view based on the supplied arguments
  83781. * @param bufferIndex index value of the specified buffer
  83782. * @param byteOffset byte offset value
  83783. * @param byteLength byte length of the bufferView
  83784. * @param byteStride byte distance between conequential elements
  83785. * @param name name of the buffer view
  83786. * @returns bufferView for glTF
  83787. */
  83788. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83789. /**
  83790. * Creates an accessor based on the supplied arguments
  83791. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83792. * @param name The name of the accessor
  83793. * @param type The type of the accessor
  83794. * @param componentType The datatype of components in the attribute
  83795. * @param count The number of attributes referenced by this accessor
  83796. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83797. * @param min Minimum value of each component in this attribute
  83798. * @param max Maximum value of each component in this attribute
  83799. * @returns accessor for glTF
  83800. */
  83801. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83802. /**
  83803. * Calculates the minimum and maximum values of an array of position floats
  83804. * @param positions Positions array of a mesh
  83805. * @param vertexStart Starting vertex offset to calculate min and max values
  83806. * @param vertexCount Number of vertices to check for min and max values
  83807. * @returns min number array and max number array
  83808. */
  83809. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83810. min: number[];
  83811. max: number[];
  83812. };
  83813. /**
  83814. * Converts a new right-handed Vector3
  83815. * @param vector vector3 array
  83816. * @returns right-handed Vector3
  83817. */
  83818. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83819. /**
  83820. * Converts a Vector3 to right-handed
  83821. * @param vector Vector3 to convert to right-handed
  83822. */
  83823. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83824. /**
  83825. * Converts a three element number array to right-handed
  83826. * @param vector number array to convert to right-handed
  83827. */
  83828. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83829. /**
  83830. * Converts a new right-handed Vector3
  83831. * @param vector vector3 array
  83832. * @returns right-handed Vector3
  83833. */
  83834. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83835. /**
  83836. * Converts a Vector3 to right-handed
  83837. * @param vector Vector3 to convert to right-handed
  83838. */
  83839. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83840. /**
  83841. * Converts a three element number array to right-handed
  83842. * @param vector number array to convert to right-handed
  83843. */
  83844. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83845. /**
  83846. * Converts a Vector4 to right-handed
  83847. * @param vector Vector4 to convert to right-handed
  83848. */
  83849. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83850. /**
  83851. * Converts a Vector4 to right-handed
  83852. * @param vector Vector4 to convert to right-handed
  83853. */
  83854. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83855. /**
  83856. * Converts a Quaternion to right-handed
  83857. * @param quaternion Source quaternion to convert to right-handed
  83858. */
  83859. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83860. /**
  83861. * Converts a Quaternion to right-handed
  83862. * @param quaternion Source quaternion to convert to right-handed
  83863. */
  83864. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83865. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83866. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83867. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83868. }
  83869. }
  83870. declare module BABYLON.GLTF2.Exporter {
  83871. /**
  83872. * Converts Babylon Scene into glTF 2.0.
  83873. * @hidden
  83874. */
  83875. export class _Exporter {
  83876. /**
  83877. * Stores the glTF to export
  83878. */
  83879. _glTF: IGLTF;
  83880. /**
  83881. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83882. */
  83883. _bufferViews: IBufferView[];
  83884. /**
  83885. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83886. */
  83887. _accessors: IAccessor[];
  83888. /**
  83889. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83890. */
  83891. _nodes: INode[];
  83892. /**
  83893. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83894. */
  83895. private _scenes;
  83896. /**
  83897. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83898. */
  83899. private _meshes;
  83900. /**
  83901. * Stores all the generated material information, which represents the appearance of each primitive
  83902. */
  83903. _materials: IMaterial[];
  83904. _materialMap: {
  83905. [materialID: number]: number;
  83906. };
  83907. /**
  83908. * Stores all the generated texture information, which is referenced by glTF materials
  83909. */
  83910. _textures: ITexture[];
  83911. /**
  83912. * Stores all the generated image information, which is referenced by glTF textures
  83913. */
  83914. _images: IImage[];
  83915. /**
  83916. * Stores all the texture samplers
  83917. */
  83918. _samplers: ISampler[];
  83919. /**
  83920. * Stores all the generated glTF skins
  83921. */
  83922. _skins: ISkin[];
  83923. /**
  83924. * Stores all the generated animation samplers, which is referenced by glTF animations
  83925. */
  83926. /**
  83927. * Stores the animations for glTF models
  83928. */
  83929. private _animations;
  83930. /**
  83931. * Stores the total amount of bytes stored in the glTF buffer
  83932. */
  83933. private _totalByteLength;
  83934. /**
  83935. * Stores a reference to the Babylon scene containing the source geometry and material information
  83936. */
  83937. _babylonScene: Scene;
  83938. /**
  83939. * Stores a map of the image data, where the key is the file name and the value
  83940. * is the image data
  83941. */
  83942. _imageData: {
  83943. [fileName: string]: {
  83944. data: Uint8Array;
  83945. mimeType: ImageMimeType;
  83946. };
  83947. };
  83948. protected _orderedImageData: Array<{
  83949. data: Uint8Array;
  83950. mimeType: ImageMimeType;
  83951. }>;
  83952. /**
  83953. * Stores a map of the unique id of a node to its index in the node array
  83954. */
  83955. _nodeMap: {
  83956. [key: number]: number;
  83957. };
  83958. /**
  83959. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83960. */
  83961. _convertToRightHandedSystem: boolean;
  83962. /**
  83963. * Specifies if a Babylon node should be converted to right-handed on export
  83964. */
  83965. _convertToRightHandedSystemMap: {
  83966. [nodeId: number]: boolean;
  83967. };
  83968. _includeCoordinateSystemConversionNodes: boolean;
  83969. /**
  83970. * Baked animation sample rate
  83971. */
  83972. private _animationSampleRate;
  83973. private _options;
  83974. private _localEngine;
  83975. _glTFMaterialExporter: _GLTFMaterialExporter;
  83976. private _extensions;
  83977. private static _ExtensionNames;
  83978. private static _ExtensionFactories;
  83979. private _applyExtension;
  83980. private _applyExtensions;
  83981. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83982. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83983. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83984. [key: number]: number;
  83985. }): Promise<Nullable<INode>>;
  83986. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83987. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83988. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83989. private _forEachExtensions;
  83990. private _extensionsOnExporting;
  83991. /**
  83992. * Load glTF serializer extensions
  83993. */
  83994. private _loadExtensions;
  83995. /**
  83996. * Creates a glTF Exporter instance, which can accept optional exporter options
  83997. * @param babylonScene Babylon scene object
  83998. * @param options Options to modify the behavior of the exporter
  83999. */
  84000. constructor(babylonScene: Scene, options?: IExportOptions);
  84001. dispose(): void;
  84002. /**
  84003. * Registers a glTF exporter extension
  84004. * @param name Name of the extension to export
  84005. * @param factory The factory function that creates the exporter extension
  84006. */
  84007. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84008. /**
  84009. * Un-registers an exporter extension
  84010. * @param name The name fo the exporter extension
  84011. * @returns A boolean indicating whether the extension has been un-registered
  84012. */
  84013. static UnregisterExtension(name: string): boolean;
  84014. /**
  84015. * Lazy load a local engine
  84016. */
  84017. _getLocalEngine(): Engine;
  84018. private reorderIndicesBasedOnPrimitiveMode;
  84019. /**
  84020. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84021. * clock-wise during export to glTF
  84022. * @param submesh BabylonJS submesh
  84023. * @param primitiveMode Primitive mode of the mesh
  84024. * @param sideOrientation the winding order of the submesh
  84025. * @param vertexBufferKind The type of vertex attribute
  84026. * @param meshAttributeArray The vertex attribute data
  84027. * @param byteOffset The offset to the binary data
  84028. * @param binaryWriter The binary data for the glTF file
  84029. * @param convertToRightHandedSystem Converts the values to right-handed
  84030. */
  84031. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84032. /**
  84033. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84034. * clock-wise during export to glTF
  84035. * @param submesh BabylonJS submesh
  84036. * @param primitiveMode Primitive mode of the mesh
  84037. * @param sideOrientation the winding order of the submesh
  84038. * @param vertexBufferKind The type of vertex attribute
  84039. * @param meshAttributeArray The vertex attribute data
  84040. * @param byteOffset The offset to the binary data
  84041. * @param binaryWriter The binary data for the glTF file
  84042. * @param convertToRightHandedSystem Converts the values to right-handed
  84043. */
  84044. private reorderTriangleFillMode;
  84045. /**
  84046. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84047. * clock-wise during export to glTF
  84048. * @param submesh BabylonJS submesh
  84049. * @param primitiveMode Primitive mode of the mesh
  84050. * @param sideOrientation the winding order of the submesh
  84051. * @param vertexBufferKind The type of vertex attribute
  84052. * @param meshAttributeArray The vertex attribute data
  84053. * @param byteOffset The offset to the binary data
  84054. * @param binaryWriter The binary data for the glTF file
  84055. * @param convertToRightHandedSystem Converts the values to right-handed
  84056. */
  84057. private reorderTriangleStripDrawMode;
  84058. /**
  84059. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84060. * clock-wise during export to glTF
  84061. * @param submesh BabylonJS submesh
  84062. * @param primitiveMode Primitive mode of the mesh
  84063. * @param sideOrientation the winding order of the submesh
  84064. * @param vertexBufferKind The type of vertex attribute
  84065. * @param meshAttributeArray The vertex attribute data
  84066. * @param byteOffset The offset to the binary data
  84067. * @param binaryWriter The binary data for the glTF file
  84068. * @param convertToRightHandedSystem Converts the values to right-handed
  84069. */
  84070. private reorderTriangleFanMode;
  84071. /**
  84072. * Writes the vertex attribute data to binary
  84073. * @param vertices The vertices to write to the binary writer
  84074. * @param byteOffset The offset into the binary writer to overwrite binary data
  84075. * @param vertexAttributeKind The vertex attribute type
  84076. * @param meshAttributeArray The vertex attribute data
  84077. * @param binaryWriter The writer containing the binary data
  84078. * @param convertToRightHandedSystem Converts the values to right-handed
  84079. */
  84080. private writeVertexAttributeData;
  84081. /**
  84082. * Writes mesh attribute data to a data buffer
  84083. * Returns the bytelength of the data
  84084. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84085. * @param meshAttributeArray Array containing the attribute data
  84086. * @param byteStride Specifies the space between data
  84087. * @param binaryWriter The buffer to write the binary data to
  84088. * @param convertToRightHandedSystem Converts the values to right-handed
  84089. */
  84090. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84091. /**
  84092. * Writes mesh attribute data to a data buffer
  84093. * Returns the bytelength of the data
  84094. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84095. * @param meshAttributeArray Array containing the attribute data
  84096. * @param byteStride Specifies the space between data
  84097. * @param binaryWriter The buffer to write the binary data to
  84098. * @param convertToRightHandedSystem Converts the values to right-handed
  84099. */
  84100. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84101. /**
  84102. * Generates glTF json data
  84103. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84104. * @param glTFPrefix Text to use when prefixing a glTF file
  84105. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84106. * @returns json data as string
  84107. */
  84108. private generateJSON;
  84109. /**
  84110. * Generates data for .gltf and .bin files based on the glTF prefix string
  84111. * @param glTFPrefix Text to use when prefixing a glTF file
  84112. * @param dispose Dispose the exporter
  84113. * @returns GLTFData with glTF file data
  84114. */
  84115. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84116. /**
  84117. * Creates a binary buffer for glTF
  84118. * @returns array buffer for binary data
  84119. */
  84120. private _generateBinaryAsync;
  84121. /**
  84122. * Pads the number to a multiple of 4
  84123. * @param num number to pad
  84124. * @returns padded number
  84125. */
  84126. private _getPadding;
  84127. /**
  84128. * @hidden
  84129. */
  84130. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84131. /**
  84132. * Sets the TRS for each node
  84133. * @param node glTF Node for storing the transformation data
  84134. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84135. * @param convertToRightHandedSystem Converts the values to right-handed
  84136. */
  84137. private setNodeTransformation;
  84138. private getVertexBufferFromMesh;
  84139. /**
  84140. * Creates a bufferview based on the vertices type for the Babylon mesh
  84141. * @param kind Indicates the type of vertices data
  84142. * @param componentType Indicates the numerical type used to store the data
  84143. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84144. * @param binaryWriter The buffer to write the bufferview data to
  84145. * @param convertToRightHandedSystem Converts the values to right-handed
  84146. */
  84147. private createBufferViewKind;
  84148. /**
  84149. * Creates a bufferview based on the vertices type for the Babylon mesh
  84150. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84151. * @param babylonMorphTarget the morph target to be exported
  84152. * @param binaryWriter The buffer to write the bufferview data to
  84153. * @param convertToRightHandedSystem Converts the values to right-handed
  84154. */
  84155. private setMorphTargetAttributes;
  84156. /**
  84157. * The primitive mode of the Babylon mesh
  84158. * @param babylonMesh The BabylonJS mesh
  84159. */
  84160. private getMeshPrimitiveMode;
  84161. /**
  84162. * Sets the primitive mode of the glTF mesh primitive
  84163. * @param meshPrimitive glTF mesh primitive
  84164. * @param primitiveMode The primitive mode
  84165. */
  84166. private setPrimitiveMode;
  84167. /**
  84168. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84169. * @param meshPrimitive glTF mesh primitive
  84170. * @param attributeKind vertex attribute
  84171. * @returns boolean specifying if uv coordinates are present
  84172. */
  84173. private setAttributeKind;
  84174. /**
  84175. * Sets data for the primitive attributes of each submesh
  84176. * @param mesh glTF Mesh object to store the primitive attribute information
  84177. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84178. * @param binaryWriter Buffer to write the attribute data to
  84179. * @param convertToRightHandedSystem Converts the values to right-handed
  84180. */
  84181. private setPrimitiveAttributesAsync;
  84182. /**
  84183. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84184. * @param node The node to check
  84185. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84186. */
  84187. private isBabylonCoordinateSystemConvertingNode;
  84188. /**
  84189. * Creates a glTF scene based on the array of meshes
  84190. * Returns the the total byte offset
  84191. * @param babylonScene Babylon scene to get the mesh data from
  84192. * @param binaryWriter Buffer to write binary data to
  84193. */
  84194. private createSceneAsync;
  84195. /**
  84196. * Creates a mapping of Node unique id to node index and handles animations
  84197. * @param babylonScene Babylon Scene
  84198. * @param nodes Babylon transform nodes
  84199. * @param binaryWriter Buffer to write binary data to
  84200. * @returns Node mapping of unique id to index
  84201. */
  84202. private createNodeMapAndAnimationsAsync;
  84203. /**
  84204. * Creates a glTF node from a Babylon mesh
  84205. * @param babylonMesh Source Babylon mesh
  84206. * @param binaryWriter Buffer for storing geometry data
  84207. * @param convertToRightHandedSystem Converts the values to right-handed
  84208. * @param nodeMap Node mapping of unique id to glTF node index
  84209. * @returns glTF node
  84210. */
  84211. private createNodeAsync;
  84212. /**
  84213. * Creates a glTF skin from a Babylon skeleton
  84214. * @param babylonScene Babylon Scene
  84215. * @param nodes Babylon transform nodes
  84216. * @param binaryWriter Buffer to write binary data to
  84217. * @returns Node mapping of unique id to index
  84218. */
  84219. private createSkinsAsync;
  84220. }
  84221. /**
  84222. * @hidden
  84223. *
  84224. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84225. */
  84226. export class _BinaryWriter {
  84227. /**
  84228. * Array buffer which stores all binary data
  84229. */
  84230. private _arrayBuffer;
  84231. /**
  84232. * View of the array buffer
  84233. */
  84234. private _dataView;
  84235. /**
  84236. * byte offset of data in array buffer
  84237. */
  84238. private _byteOffset;
  84239. /**
  84240. * Initialize binary writer with an initial byte length
  84241. * @param byteLength Initial byte length of the array buffer
  84242. */
  84243. constructor(byteLength: number);
  84244. /**
  84245. * Resize the array buffer to the specified byte length
  84246. * @param byteLength
  84247. */
  84248. private resizeBuffer;
  84249. /**
  84250. * Get an array buffer with the length of the byte offset
  84251. * @returns ArrayBuffer resized to the byte offset
  84252. */
  84253. getArrayBuffer(): ArrayBuffer;
  84254. /**
  84255. * Get the byte offset of the array buffer
  84256. * @returns byte offset
  84257. */
  84258. getByteOffset(): number;
  84259. /**
  84260. * Stores an UInt8 in the array buffer
  84261. * @param entry
  84262. * @param byteOffset If defined, specifies where to set the value as an offset.
  84263. */
  84264. setUInt8(entry: number, byteOffset?: number): void;
  84265. /**
  84266. * Stores an UInt16 in the array buffer
  84267. * @param entry
  84268. * @param byteOffset If defined, specifies where to set the value as an offset.
  84269. */
  84270. setUInt16(entry: number, byteOffset?: number): void;
  84271. /**
  84272. * Gets an UInt32 in the array buffer
  84273. * @param entry
  84274. * @param byteOffset If defined, specifies where to set the value as an offset.
  84275. */
  84276. getUInt32(byteOffset: number): number;
  84277. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84278. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84279. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84280. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84281. /**
  84282. * Stores a Float32 in the array buffer
  84283. * @param entry
  84284. */
  84285. setFloat32(entry: number, byteOffset?: number): void;
  84286. /**
  84287. * Stores an UInt32 in the array buffer
  84288. * @param entry
  84289. * @param byteOffset If defined, specifies where to set the value as an offset.
  84290. */
  84291. setUInt32(entry: number, byteOffset?: number): void;
  84292. }
  84293. }
  84294. declare module BABYLON.GLTF2.Exporter {
  84295. /**
  84296. * @hidden
  84297. * Interface to store animation data.
  84298. */
  84299. export interface _IAnimationData {
  84300. /**
  84301. * Keyframe data.
  84302. */
  84303. inputs: number[];
  84304. /**
  84305. * Value data.
  84306. */
  84307. outputs: number[][];
  84308. /**
  84309. * Animation interpolation data.
  84310. */
  84311. samplerInterpolation: AnimationSamplerInterpolation;
  84312. /**
  84313. * Minimum keyframe value.
  84314. */
  84315. inputsMin: number;
  84316. /**
  84317. * Maximum keyframe value.
  84318. */
  84319. inputsMax: number;
  84320. }
  84321. /**
  84322. * @hidden
  84323. */
  84324. export interface _IAnimationInfo {
  84325. /**
  84326. * The target channel for the animation
  84327. */
  84328. animationChannelTargetPath: AnimationChannelTargetPath;
  84329. /**
  84330. * The glTF accessor type for the data.
  84331. */
  84332. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84333. /**
  84334. * Specifies if quaternions should be used.
  84335. */
  84336. useQuaternion: boolean;
  84337. }
  84338. /**
  84339. * @hidden
  84340. * Utility class for generating glTF animation data from BabylonJS.
  84341. */
  84342. export class _GLTFAnimation {
  84343. /**
  84344. * @ignore
  84345. *
  84346. * Creates glTF channel animation from BabylonJS animation.
  84347. * @param babylonTransformNode - BabylonJS mesh.
  84348. * @param animation - animation.
  84349. * @param animationChannelTargetPath - The target animation channel.
  84350. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84351. * @param useQuaternion - Specifies if quaternions are used.
  84352. * @returns nullable IAnimationData
  84353. */
  84354. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84355. private static _DeduceAnimationInfo;
  84356. /**
  84357. * @ignore
  84358. * Create node animations from the transform node animations
  84359. * @param babylonNode
  84360. * @param runtimeGLTFAnimation
  84361. * @param idleGLTFAnimations
  84362. * @param nodeMap
  84363. * @param nodes
  84364. * @param binaryWriter
  84365. * @param bufferViews
  84366. * @param accessors
  84367. * @param convertToRightHandedSystem
  84368. * @param animationSampleRate
  84369. */
  84370. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84371. [key: number]: number;
  84372. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84373. /**
  84374. * @ignore
  84375. * Create individual morph animations from the mesh's morph target animation tracks
  84376. * @param babylonNode
  84377. * @param runtimeGLTFAnimation
  84378. * @param idleGLTFAnimations
  84379. * @param nodeMap
  84380. * @param nodes
  84381. * @param binaryWriter
  84382. * @param bufferViews
  84383. * @param accessors
  84384. * @param convertToRightHandedSystem
  84385. * @param animationSampleRate
  84386. */
  84387. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84388. [key: number]: number;
  84389. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84390. /**
  84391. * @ignore
  84392. * Create node and morph animations from the animation groups
  84393. * @param babylonScene
  84394. * @param glTFAnimations
  84395. * @param nodeMap
  84396. * @param nodes
  84397. * @param binaryWriter
  84398. * @param bufferViews
  84399. * @param accessors
  84400. * @param convertToRightHandedSystemMap
  84401. * @param animationSampleRate
  84402. */
  84403. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84404. [key: number]: number;
  84405. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84406. [nodeId: number]: boolean;
  84407. }, animationSampleRate: number): void;
  84408. private static AddAnimation;
  84409. /**
  84410. * Create a baked animation
  84411. * @param babylonTransformNode BabylonJS mesh
  84412. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84413. * @param animationChannelTargetPath animation target channel
  84414. * @param minFrame minimum animation frame
  84415. * @param maxFrame maximum animation frame
  84416. * @param fps frames per second of the animation
  84417. * @param inputs input key frames of the animation
  84418. * @param outputs output key frame data of the animation
  84419. * @param convertToRightHandedSystem converts the values to right-handed
  84420. * @param useQuaternion specifies if quaternions should be used
  84421. */
  84422. private static _CreateBakedAnimation;
  84423. private static _ConvertFactorToVector3OrQuaternion;
  84424. private static _SetInterpolatedValue;
  84425. /**
  84426. * Creates linear animation from the animation key frames
  84427. * @param babylonTransformNode BabylonJS mesh
  84428. * @param animation BabylonJS animation
  84429. * @param animationChannelTargetPath The target animation channel
  84430. * @param frameDelta The difference between the last and first frame of the animation
  84431. * @param inputs Array to store the key frame times
  84432. * @param outputs Array to store the key frame data
  84433. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84434. * @param useQuaternion Specifies if quaternions are used in the animation
  84435. */
  84436. private static _CreateLinearOrStepAnimation;
  84437. /**
  84438. * Creates cubic spline animation from the animation key frames
  84439. * @param babylonTransformNode BabylonJS mesh
  84440. * @param animation BabylonJS animation
  84441. * @param animationChannelTargetPath The target animation channel
  84442. * @param frameDelta The difference between the last and first frame of the animation
  84443. * @param inputs Array to store the key frame times
  84444. * @param outputs Array to store the key frame data
  84445. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84446. * @param useQuaternion Specifies if quaternions are used in the animation
  84447. */
  84448. private static _CreateCubicSplineAnimation;
  84449. private static _GetBasePositionRotationOrScale;
  84450. /**
  84451. * Adds a key frame value
  84452. * @param keyFrame
  84453. * @param animation
  84454. * @param outputs
  84455. * @param animationChannelTargetPath
  84456. * @param basePositionRotationOrScale
  84457. * @param convertToRightHandedSystem
  84458. * @param useQuaternion
  84459. */
  84460. private static _AddKeyframeValue;
  84461. /**
  84462. * Determine the interpolation based on the key frames
  84463. * @param keyFrames
  84464. * @param animationChannelTargetPath
  84465. * @param useQuaternion
  84466. */
  84467. private static _DeduceInterpolation;
  84468. /**
  84469. * Adds an input tangent or output tangent to the output data
  84470. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84471. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84472. * @param outputs The animation data by keyframe
  84473. * @param animationChannelTargetPath The target animation channel
  84474. * @param interpolation The interpolation type
  84475. * @param keyFrame The key frame with the animation data
  84476. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84477. * @param useQuaternion Specifies if quaternions are used
  84478. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84479. */
  84480. private static AddSplineTangent;
  84481. /**
  84482. * Get the minimum and maximum key frames' frame values
  84483. * @param keyFrames animation key frames
  84484. * @returns the minimum and maximum key frame value
  84485. */
  84486. private static calculateMinMaxKeyFrames;
  84487. }
  84488. }
  84489. declare module BABYLON.GLTF2.Exporter {
  84490. /** @hidden */
  84491. export var textureTransformPixelShader: {
  84492. name: string;
  84493. shader: string;
  84494. };
  84495. }
  84496. declare module BABYLON.GLTF2.Exporter.Extensions {
  84497. /**
  84498. * @hidden
  84499. */
  84500. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84501. private _recordedTextures;
  84502. /** Name of this extension */
  84503. readonly name: string;
  84504. /** Defines whether this extension is enabled */
  84505. enabled: boolean;
  84506. /** Defines whether this extension is required */
  84507. required: boolean;
  84508. /** Reference to the glTF exporter */
  84509. private _wasUsed;
  84510. constructor(exporter: _Exporter);
  84511. dispose(): void;
  84512. /** @hidden */
  84513. get wasUsed(): boolean;
  84514. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84515. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84516. /**
  84517. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84518. * @param babylonTexture
  84519. * @param offset
  84520. * @param rotation
  84521. * @param scale
  84522. * @param scene
  84523. */
  84524. private _textureTransformTextureAsync;
  84525. }
  84526. }
  84527. declare module BABYLON.GLTF2.Exporter.Extensions {
  84528. /**
  84529. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84530. */
  84531. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84532. /** The name of this extension. */
  84533. readonly name: string;
  84534. /** Defines whether this extension is enabled. */
  84535. enabled: boolean;
  84536. /** Defines whether this extension is required */
  84537. required: boolean;
  84538. /** Reference to the glTF exporter */
  84539. private _exporter;
  84540. private _lights;
  84541. /** @hidden */
  84542. constructor(exporter: _Exporter);
  84543. /** @hidden */
  84544. dispose(): void;
  84545. /** @hidden */
  84546. get wasUsed(): boolean;
  84547. /** @hidden */
  84548. onExporting(): void;
  84549. /**
  84550. * Define this method to modify the default behavior when exporting a node
  84551. * @param context The context when exporting the node
  84552. * @param node glTF node
  84553. * @param babylonNode BabylonJS node
  84554. * @param nodeMap Node mapping of unique id to glTF node index
  84555. * @returns nullable INode promise
  84556. */
  84557. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84558. [key: number]: number;
  84559. }): Promise<Nullable<INode>>;
  84560. }
  84561. }
  84562. declare module BABYLON.GLTF2.Exporter.Extensions {
  84563. /**
  84564. * @hidden
  84565. */
  84566. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84567. /** Name of this extension */
  84568. readonly name: string;
  84569. /** Defines whether this extension is enabled */
  84570. enabled: boolean;
  84571. /** Defines whether this extension is required */
  84572. required: boolean;
  84573. /** Reference to the glTF exporter */
  84574. private _textureInfos;
  84575. private _exportedTextures;
  84576. private _wasUsed;
  84577. constructor(exporter: _Exporter);
  84578. dispose(): void;
  84579. /** @hidden */
  84580. get wasUsed(): boolean;
  84581. private _getTextureIndex;
  84582. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84583. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84584. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84585. }
  84586. }
  84587. declare module BABYLON.GLTF2.Exporter.Extensions {
  84588. /**
  84589. * @hidden
  84590. */
  84591. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84592. /** Name of this extension */
  84593. readonly name: string;
  84594. /** Defines whether this extension is enabled */
  84595. enabled: boolean;
  84596. /** Defines whether this extension is required */
  84597. required: boolean;
  84598. private _wasUsed;
  84599. constructor(exporter: _Exporter);
  84600. /** @hidden */
  84601. get wasUsed(): boolean;
  84602. dispose(): void;
  84603. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84604. }
  84605. }
  84606. declare module BABYLON {
  84607. /**
  84608. * Class for generating STL data from a Babylon scene.
  84609. */
  84610. export class STLExport {
  84611. /**
  84612. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84613. * @param meshes list defines the mesh to serialize
  84614. * @param download triggers the automatic download of the file.
  84615. * @param fileName changes the downloads fileName.
  84616. * @param binary changes the STL to a binary type.
  84617. * @param isLittleEndian toggle for binary type exporter.
  84618. * @returns the STL as UTF8 string
  84619. */
  84620. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84621. }
  84622. }
  84623. declare module "babylonjs-gltf2interface" {
  84624. export = BABYLON.GLTF2;
  84625. }
  84626. /**
  84627. * Module for glTF 2.0 Interface
  84628. */
  84629. declare module BABYLON.GLTF2 {
  84630. /**
  84631. * The datatype of the components in the attribute
  84632. */
  84633. const enum AccessorComponentType {
  84634. /**
  84635. * Byte
  84636. */
  84637. BYTE = 5120,
  84638. /**
  84639. * Unsigned Byte
  84640. */
  84641. UNSIGNED_BYTE = 5121,
  84642. /**
  84643. * Short
  84644. */
  84645. SHORT = 5122,
  84646. /**
  84647. * Unsigned Short
  84648. */
  84649. UNSIGNED_SHORT = 5123,
  84650. /**
  84651. * Unsigned Int
  84652. */
  84653. UNSIGNED_INT = 5125,
  84654. /**
  84655. * Float
  84656. */
  84657. FLOAT = 5126,
  84658. }
  84659. /**
  84660. * Specifies if the attirbute is a scalar, vector, or matrix
  84661. */
  84662. const enum AccessorType {
  84663. /**
  84664. * Scalar
  84665. */
  84666. SCALAR = "SCALAR",
  84667. /**
  84668. * Vector2
  84669. */
  84670. VEC2 = "VEC2",
  84671. /**
  84672. * Vector3
  84673. */
  84674. VEC3 = "VEC3",
  84675. /**
  84676. * Vector4
  84677. */
  84678. VEC4 = "VEC4",
  84679. /**
  84680. * Matrix2x2
  84681. */
  84682. MAT2 = "MAT2",
  84683. /**
  84684. * Matrix3x3
  84685. */
  84686. MAT3 = "MAT3",
  84687. /**
  84688. * Matrix4x4
  84689. */
  84690. MAT4 = "MAT4",
  84691. }
  84692. /**
  84693. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84694. */
  84695. const enum AnimationChannelTargetPath {
  84696. /**
  84697. * Translation
  84698. */
  84699. TRANSLATION = "translation",
  84700. /**
  84701. * Rotation
  84702. */
  84703. ROTATION = "rotation",
  84704. /**
  84705. * Scale
  84706. */
  84707. SCALE = "scale",
  84708. /**
  84709. * Weights
  84710. */
  84711. WEIGHTS = "weights",
  84712. }
  84713. /**
  84714. * Interpolation algorithm
  84715. */
  84716. const enum AnimationSamplerInterpolation {
  84717. /**
  84718. * The animated values are linearly interpolated between keyframes
  84719. */
  84720. LINEAR = "LINEAR",
  84721. /**
  84722. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84723. */
  84724. STEP = "STEP",
  84725. /**
  84726. * The animation's interpolation is computed using a cubic spline with specified tangents
  84727. */
  84728. CUBICSPLINE = "CUBICSPLINE",
  84729. }
  84730. /**
  84731. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84732. */
  84733. const enum CameraType {
  84734. /**
  84735. * A perspective camera containing properties to create a perspective projection matrix
  84736. */
  84737. PERSPECTIVE = "perspective",
  84738. /**
  84739. * An orthographic camera containing properties to create an orthographic projection matrix
  84740. */
  84741. ORTHOGRAPHIC = "orthographic",
  84742. }
  84743. /**
  84744. * The mime-type of the image
  84745. */
  84746. const enum ImageMimeType {
  84747. /**
  84748. * JPEG Mime-type
  84749. */
  84750. JPEG = "image/jpeg",
  84751. /**
  84752. * PNG Mime-type
  84753. */
  84754. PNG = "image/png",
  84755. }
  84756. /**
  84757. * The alpha rendering mode of the material
  84758. */
  84759. const enum MaterialAlphaMode {
  84760. /**
  84761. * The alpha value is ignored and the rendered output is fully opaque
  84762. */
  84763. OPAQUE = "OPAQUE",
  84764. /**
  84765. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84766. */
  84767. MASK = "MASK",
  84768. /**
  84769. * 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)
  84770. */
  84771. BLEND = "BLEND",
  84772. }
  84773. /**
  84774. * The type of the primitives to render
  84775. */
  84776. const enum MeshPrimitiveMode {
  84777. /**
  84778. * Points
  84779. */
  84780. POINTS = 0,
  84781. /**
  84782. * Lines
  84783. */
  84784. LINES = 1,
  84785. /**
  84786. * Line Loop
  84787. */
  84788. LINE_LOOP = 2,
  84789. /**
  84790. * Line Strip
  84791. */
  84792. LINE_STRIP = 3,
  84793. /**
  84794. * Triangles
  84795. */
  84796. TRIANGLES = 4,
  84797. /**
  84798. * Triangle Strip
  84799. */
  84800. TRIANGLE_STRIP = 5,
  84801. /**
  84802. * Triangle Fan
  84803. */
  84804. TRIANGLE_FAN = 6,
  84805. }
  84806. /**
  84807. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84808. */
  84809. const enum TextureMagFilter {
  84810. /**
  84811. * Nearest
  84812. */
  84813. NEAREST = 9728,
  84814. /**
  84815. * Linear
  84816. */
  84817. LINEAR = 9729,
  84818. }
  84819. /**
  84820. * Minification filter. All valid values correspond to WebGL enums
  84821. */
  84822. const enum TextureMinFilter {
  84823. /**
  84824. * Nearest
  84825. */
  84826. NEAREST = 9728,
  84827. /**
  84828. * Linear
  84829. */
  84830. LINEAR = 9729,
  84831. /**
  84832. * Nearest Mip-Map Nearest
  84833. */
  84834. NEAREST_MIPMAP_NEAREST = 9984,
  84835. /**
  84836. * Linear Mipmap Nearest
  84837. */
  84838. LINEAR_MIPMAP_NEAREST = 9985,
  84839. /**
  84840. * Nearest Mipmap Linear
  84841. */
  84842. NEAREST_MIPMAP_LINEAR = 9986,
  84843. /**
  84844. * Linear Mipmap Linear
  84845. */
  84846. LINEAR_MIPMAP_LINEAR = 9987,
  84847. }
  84848. /**
  84849. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84850. */
  84851. const enum TextureWrapMode {
  84852. /**
  84853. * Clamp to Edge
  84854. */
  84855. CLAMP_TO_EDGE = 33071,
  84856. /**
  84857. * Mirrored Repeat
  84858. */
  84859. MIRRORED_REPEAT = 33648,
  84860. /**
  84861. * Repeat
  84862. */
  84863. REPEAT = 10497,
  84864. }
  84865. /**
  84866. * glTF Property
  84867. */
  84868. interface IProperty {
  84869. /**
  84870. * Dictionary object with extension-specific objects
  84871. */
  84872. extensions?: {
  84873. [key: string]: any;
  84874. };
  84875. /**
  84876. * Application-Specific data
  84877. */
  84878. extras?: any;
  84879. }
  84880. /**
  84881. * glTF Child of Root Property
  84882. */
  84883. interface IChildRootProperty extends IProperty {
  84884. /**
  84885. * The user-defined name of this object
  84886. */
  84887. name?: string;
  84888. }
  84889. /**
  84890. * Indices of those attributes that deviate from their initialization value
  84891. */
  84892. interface IAccessorSparseIndices extends IProperty {
  84893. /**
  84894. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84895. */
  84896. bufferView: number;
  84897. /**
  84898. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84899. */
  84900. byteOffset?: number;
  84901. /**
  84902. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84903. */
  84904. componentType: AccessorComponentType;
  84905. }
  84906. /**
  84907. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84908. */
  84909. interface IAccessorSparseValues extends IProperty {
  84910. /**
  84911. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84912. */
  84913. bufferView: number;
  84914. /**
  84915. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84916. */
  84917. byteOffset?: number;
  84918. }
  84919. /**
  84920. * Sparse storage of attributes that deviate from their initialization value
  84921. */
  84922. interface IAccessorSparse extends IProperty {
  84923. /**
  84924. * The number of attributes encoded in this sparse accessor
  84925. */
  84926. count: number;
  84927. /**
  84928. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84929. */
  84930. indices: IAccessorSparseIndices;
  84931. /**
  84932. * 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
  84933. */
  84934. values: IAccessorSparseValues;
  84935. }
  84936. /**
  84937. * 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
  84938. */
  84939. interface IAccessor extends IChildRootProperty {
  84940. /**
  84941. * The index of the bufferview
  84942. */
  84943. bufferView?: number;
  84944. /**
  84945. * The offset relative to the start of the bufferView in bytes
  84946. */
  84947. byteOffset?: number;
  84948. /**
  84949. * The datatype of components in the attribute
  84950. */
  84951. componentType: AccessorComponentType;
  84952. /**
  84953. * Specifies whether integer data values should be normalized
  84954. */
  84955. normalized?: boolean;
  84956. /**
  84957. * The number of attributes referenced by this accessor
  84958. */
  84959. count: number;
  84960. /**
  84961. * Specifies if the attribute is a scalar, vector, or matrix
  84962. */
  84963. type: AccessorType;
  84964. /**
  84965. * Maximum value of each component in this attribute
  84966. */
  84967. max?: number[];
  84968. /**
  84969. * Minimum value of each component in this attribute
  84970. */
  84971. min?: number[];
  84972. /**
  84973. * Sparse storage of attributes that deviate from their initialization value
  84974. */
  84975. sparse?: IAccessorSparse;
  84976. }
  84977. /**
  84978. * Targets an animation's sampler at a node's property
  84979. */
  84980. interface IAnimationChannel extends IProperty {
  84981. /**
  84982. * The index of a sampler in this animation used to compute the value for the target
  84983. */
  84984. sampler: number;
  84985. /**
  84986. * The index of the node and TRS property to target
  84987. */
  84988. target: IAnimationChannelTarget;
  84989. }
  84990. /**
  84991. * The index of the node and TRS property that an animation channel targets
  84992. */
  84993. interface IAnimationChannelTarget extends IProperty {
  84994. /**
  84995. * The index of the node to target
  84996. */
  84997. node: number;
  84998. /**
  84999. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85000. */
  85001. path: AnimationChannelTargetPath;
  85002. }
  85003. /**
  85004. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85005. */
  85006. interface IAnimationSampler extends IProperty {
  85007. /**
  85008. * The index of an accessor containing keyframe input values, e.g., time
  85009. */
  85010. input: number;
  85011. /**
  85012. * Interpolation algorithm
  85013. */
  85014. interpolation?: AnimationSamplerInterpolation;
  85015. /**
  85016. * The index of an accessor, containing keyframe output values
  85017. */
  85018. output: number;
  85019. }
  85020. /**
  85021. * A keyframe animation
  85022. */
  85023. interface IAnimation extends IChildRootProperty {
  85024. /**
  85025. * An array of channels, each of which targets an animation's sampler at a node's property
  85026. */
  85027. channels: IAnimationChannel[];
  85028. /**
  85029. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85030. */
  85031. samplers: IAnimationSampler[];
  85032. }
  85033. /**
  85034. * Metadata about the glTF asset
  85035. */
  85036. interface IAsset extends IChildRootProperty {
  85037. /**
  85038. * A copyright message suitable for display to credit the content creator
  85039. */
  85040. copyright?: string;
  85041. /**
  85042. * Tool that generated this glTF model. Useful for debugging
  85043. */
  85044. generator?: string;
  85045. /**
  85046. * The glTF version that this asset targets
  85047. */
  85048. version: string;
  85049. /**
  85050. * The minimum glTF version that this asset targets
  85051. */
  85052. minVersion?: string;
  85053. }
  85054. /**
  85055. * A buffer points to binary geometry, animation, or skins
  85056. */
  85057. interface IBuffer extends IChildRootProperty {
  85058. /**
  85059. * 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
  85060. */
  85061. uri?: string;
  85062. /**
  85063. * The length of the buffer in bytes
  85064. */
  85065. byteLength: number;
  85066. }
  85067. /**
  85068. * A view into a buffer generally representing a subset of the buffer
  85069. */
  85070. interface IBufferView extends IChildRootProperty {
  85071. /**
  85072. * The index of the buffer
  85073. */
  85074. buffer: number;
  85075. /**
  85076. * The offset into the buffer in bytes
  85077. */
  85078. byteOffset?: number;
  85079. /**
  85080. * The lenth of the bufferView in bytes
  85081. */
  85082. byteLength: number;
  85083. /**
  85084. * The stride, in bytes
  85085. */
  85086. byteStride?: number;
  85087. }
  85088. /**
  85089. * An orthographic camera containing properties to create an orthographic projection matrix
  85090. */
  85091. interface ICameraOrthographic extends IProperty {
  85092. /**
  85093. * The floating-point horizontal magnification of the view. Must not be zero
  85094. */
  85095. xmag: number;
  85096. /**
  85097. * The floating-point vertical magnification of the view. Must not be zero
  85098. */
  85099. ymag: number;
  85100. /**
  85101. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85102. */
  85103. zfar: number;
  85104. /**
  85105. * The floating-point distance to the near clipping plane
  85106. */
  85107. znear: number;
  85108. }
  85109. /**
  85110. * A perspective camera containing properties to create a perspective projection matrix
  85111. */
  85112. interface ICameraPerspective extends IProperty {
  85113. /**
  85114. * The floating-point aspect ratio of the field of view
  85115. */
  85116. aspectRatio?: number;
  85117. /**
  85118. * The floating-point vertical field of view in radians
  85119. */
  85120. yfov: number;
  85121. /**
  85122. * The floating-point distance to the far clipping plane
  85123. */
  85124. zfar?: number;
  85125. /**
  85126. * The floating-point distance to the near clipping plane
  85127. */
  85128. znear: number;
  85129. }
  85130. /**
  85131. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85132. */
  85133. interface ICamera extends IChildRootProperty {
  85134. /**
  85135. * An orthographic camera containing properties to create an orthographic projection matrix
  85136. */
  85137. orthographic?: ICameraOrthographic;
  85138. /**
  85139. * A perspective camera containing properties to create a perspective projection matrix
  85140. */
  85141. perspective?: ICameraPerspective;
  85142. /**
  85143. * Specifies if the camera uses a perspective or orthographic projection
  85144. */
  85145. type: CameraType;
  85146. }
  85147. /**
  85148. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85149. */
  85150. interface IImage extends IChildRootProperty {
  85151. /**
  85152. * 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
  85153. */
  85154. uri?: string;
  85155. /**
  85156. * The image's MIME type
  85157. */
  85158. mimeType?: ImageMimeType;
  85159. /**
  85160. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85161. */
  85162. bufferView?: number;
  85163. }
  85164. /**
  85165. * Material Normal Texture Info
  85166. */
  85167. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85168. /**
  85169. * The scalar multiplier applied to each normal vector of the normal texture
  85170. */
  85171. scale?: number;
  85172. }
  85173. /**
  85174. * Material Occlusion Texture Info
  85175. */
  85176. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85177. /**
  85178. * A scalar multiplier controlling the amount of occlusion applied
  85179. */
  85180. strength?: number;
  85181. }
  85182. /**
  85183. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85184. */
  85185. interface IMaterialPbrMetallicRoughness {
  85186. /**
  85187. * The material's base color factor
  85188. */
  85189. baseColorFactor?: number[];
  85190. /**
  85191. * The base color texture
  85192. */
  85193. baseColorTexture?: ITextureInfo;
  85194. /**
  85195. * The metalness of the material
  85196. */
  85197. metallicFactor?: number;
  85198. /**
  85199. * The roughness of the material
  85200. */
  85201. roughnessFactor?: number;
  85202. /**
  85203. * The metallic-roughness texture
  85204. */
  85205. metallicRoughnessTexture?: ITextureInfo;
  85206. }
  85207. /**
  85208. * The material appearance of a primitive
  85209. */
  85210. interface IMaterial extends IChildRootProperty {
  85211. /**
  85212. * 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
  85213. */
  85214. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85215. /**
  85216. * The normal map texture
  85217. */
  85218. normalTexture?: IMaterialNormalTextureInfo;
  85219. /**
  85220. * The occlusion map texture
  85221. */
  85222. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85223. /**
  85224. * The emissive map texture
  85225. */
  85226. emissiveTexture?: ITextureInfo;
  85227. /**
  85228. * 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
  85229. */
  85230. emissiveFactor?: number[];
  85231. /**
  85232. * The alpha rendering mode of the material
  85233. */
  85234. alphaMode?: MaterialAlphaMode;
  85235. /**
  85236. * The alpha cutoff value of the material
  85237. */
  85238. alphaCutoff?: number;
  85239. /**
  85240. * Specifies whether the material is double sided
  85241. */
  85242. doubleSided?: boolean;
  85243. }
  85244. /**
  85245. * Geometry to be rendered with the given material
  85246. */
  85247. interface IMeshPrimitive extends IProperty {
  85248. /**
  85249. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85250. */
  85251. attributes: {
  85252. [name: string]: number;
  85253. };
  85254. /**
  85255. * The index of the accessor that contains the indices
  85256. */
  85257. indices?: number;
  85258. /**
  85259. * The index of the material to apply to this primitive when rendering
  85260. */
  85261. material?: number;
  85262. /**
  85263. * The type of primitives to render. All valid values correspond to WebGL enums
  85264. */
  85265. mode?: MeshPrimitiveMode;
  85266. /**
  85267. * 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
  85268. */
  85269. targets?: {
  85270. [name: string]: number;
  85271. }[];
  85272. }
  85273. /**
  85274. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85275. */
  85276. interface IMesh extends IChildRootProperty {
  85277. /**
  85278. * An array of primitives, each defining geometry to be rendered with a material
  85279. */
  85280. primitives: IMeshPrimitive[];
  85281. /**
  85282. * Array of weights to be applied to the Morph Targets
  85283. */
  85284. weights?: number[];
  85285. }
  85286. /**
  85287. * A node in the node hierarchy
  85288. */
  85289. interface INode extends IChildRootProperty {
  85290. /**
  85291. * The index of the camera referenced by this node
  85292. */
  85293. camera?: number;
  85294. /**
  85295. * The indices of this node's children
  85296. */
  85297. children?: number[];
  85298. /**
  85299. * The index of the skin referenced by this node
  85300. */
  85301. skin?: number;
  85302. /**
  85303. * A floating-point 4x4 transformation matrix stored in column-major order
  85304. */
  85305. matrix?: number[];
  85306. /**
  85307. * The index of the mesh in this node
  85308. */
  85309. mesh?: number;
  85310. /**
  85311. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85312. */
  85313. rotation?: number[];
  85314. /**
  85315. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85316. */
  85317. scale?: number[];
  85318. /**
  85319. * The node's translation along the x, y, and z axes
  85320. */
  85321. translation?: number[];
  85322. /**
  85323. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85324. */
  85325. weights?: number[];
  85326. }
  85327. /**
  85328. * Texture sampler properties for filtering and wrapping modes
  85329. */
  85330. interface ISampler extends IChildRootProperty {
  85331. /**
  85332. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85333. */
  85334. magFilter?: TextureMagFilter;
  85335. /**
  85336. * Minification filter. All valid values correspond to WebGL enums
  85337. */
  85338. minFilter?: TextureMinFilter;
  85339. /**
  85340. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85341. */
  85342. wrapS?: TextureWrapMode;
  85343. /**
  85344. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85345. */
  85346. wrapT?: TextureWrapMode;
  85347. }
  85348. /**
  85349. * The root nodes of a scene
  85350. */
  85351. interface IScene extends IChildRootProperty {
  85352. /**
  85353. * The indices of each root node
  85354. */
  85355. nodes: number[];
  85356. }
  85357. /**
  85358. * Joints and matrices defining a skin
  85359. */
  85360. interface ISkin extends IChildRootProperty {
  85361. /**
  85362. * 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
  85363. */
  85364. inverseBindMatrices?: number;
  85365. /**
  85366. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85367. */
  85368. skeleton?: number;
  85369. /**
  85370. * 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)
  85371. */
  85372. joints: number[];
  85373. }
  85374. /**
  85375. * A texture and its sampler
  85376. */
  85377. interface ITexture extends IChildRootProperty {
  85378. /**
  85379. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85380. */
  85381. sampler?: number;
  85382. /**
  85383. * The index of the image used by this texture
  85384. */
  85385. source: number;
  85386. }
  85387. /**
  85388. * Reference to a texture
  85389. */
  85390. interface ITextureInfo extends IProperty {
  85391. /**
  85392. * The index of the texture
  85393. */
  85394. index: number;
  85395. /**
  85396. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85397. */
  85398. texCoord?: number;
  85399. }
  85400. /**
  85401. * The root object for a glTF asset
  85402. */
  85403. interface IGLTF extends IProperty {
  85404. /**
  85405. * An array of accessors. An accessor is a typed view into a bufferView
  85406. */
  85407. accessors?: IAccessor[];
  85408. /**
  85409. * An array of keyframe animations
  85410. */
  85411. animations?: IAnimation[];
  85412. /**
  85413. * Metadata about the glTF asset
  85414. */
  85415. asset: IAsset;
  85416. /**
  85417. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85418. */
  85419. buffers?: IBuffer[];
  85420. /**
  85421. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85422. */
  85423. bufferViews?: IBufferView[];
  85424. /**
  85425. * An array of cameras
  85426. */
  85427. cameras?: ICamera[];
  85428. /**
  85429. * Names of glTF extensions used somewhere in this asset
  85430. */
  85431. extensionsUsed?: string[];
  85432. /**
  85433. * Names of glTF extensions required to properly load this asset
  85434. */
  85435. extensionsRequired?: string[];
  85436. /**
  85437. * An array of images. An image defines data used to create a texture
  85438. */
  85439. images?: IImage[];
  85440. /**
  85441. * An array of materials. A material defines the appearance of a primitive
  85442. */
  85443. materials?: IMaterial[];
  85444. /**
  85445. * An array of meshes. A mesh is a set of primitives to be rendered
  85446. */
  85447. meshes?: IMesh[];
  85448. /**
  85449. * An array of nodes
  85450. */
  85451. nodes?: INode[];
  85452. /**
  85453. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85454. */
  85455. samplers?: ISampler[];
  85456. /**
  85457. * The index of the default scene
  85458. */
  85459. scene?: number;
  85460. /**
  85461. * An array of scenes
  85462. */
  85463. scenes?: IScene[];
  85464. /**
  85465. * An array of skins. A skin is defined by joints and matrices
  85466. */
  85467. skins?: ISkin[];
  85468. /**
  85469. * An array of textures
  85470. */
  85471. textures?: ITexture[];
  85472. }
  85473. /**
  85474. * The glTF validation results
  85475. * @ignore
  85476. */
  85477. interface IGLTFValidationResults {
  85478. info: {
  85479. generator: string;
  85480. hasAnimations: boolean;
  85481. hasDefaultScene: boolean;
  85482. hasMaterials: boolean;
  85483. hasMorphTargets: boolean;
  85484. hasSkins: boolean;
  85485. hasTextures: boolean;
  85486. maxAttributesUsed: number;
  85487. primitivesCount: number
  85488. };
  85489. issues: {
  85490. messages: Array<string>;
  85491. numErrors: number;
  85492. numHints: number;
  85493. numInfos: number;
  85494. numWarnings: number;
  85495. truncated: boolean
  85496. };
  85497. mimeType: string;
  85498. uri: string;
  85499. validatedAt: string;
  85500. validatorVersion: string;
  85501. }
  85502. /**
  85503. * The glTF validation options
  85504. */
  85505. interface IGLTFValidationOptions {
  85506. /** Uri to use */
  85507. uri?: string;
  85508. /** Function used to load external resources */
  85509. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85510. /** Boolean indicating that we need to validate accessor data */
  85511. validateAccessorData?: boolean;
  85512. /** max number of issues allowed */
  85513. maxIssues?: number;
  85514. /** Ignored issues */
  85515. ignoredIssues?: Array<string>;
  85516. /** Value to override severy settings */
  85517. severityOverrides?: Object;
  85518. }
  85519. /**
  85520. * The glTF validator object
  85521. * @ignore
  85522. */
  85523. interface IGLTFValidator {
  85524. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85525. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85526. }
  85527. /**
  85528. * Interfaces from the EXT_lights_image_based extension
  85529. */
  85530. /** @hidden */
  85531. interface IEXTLightsImageBased_LightReferenceImageBased {
  85532. light: number;
  85533. }
  85534. /** @hidden */
  85535. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85536. intensity: number;
  85537. rotation: number[];
  85538. specularImageSize: number;
  85539. specularImages: number[][];
  85540. irradianceCoefficients: number[][];
  85541. }
  85542. /** @hidden */
  85543. interface IEXTLightsImageBased {
  85544. lights: IEXTLightsImageBased_LightImageBased[];
  85545. }
  85546. /**
  85547. * Interfaces from the EXT_mesh_gpu_instancing extension
  85548. * !!! Experimental Extension Subject to Changes !!!
  85549. */
  85550. /** @hidden */
  85551. interface IEXTMeshGpuInstancing {
  85552. mesh?: number;
  85553. attributes: { [name: string]: number };
  85554. }
  85555. /**
  85556. * Interfaces from the KHR_draco_mesh_compression extension
  85557. */
  85558. /** @hidden */
  85559. interface IKHRDracoMeshCompression {
  85560. bufferView: number;
  85561. attributes: { [name: string]: number };
  85562. }
  85563. /**
  85564. * Interfaces from the KHR_lights_punctual extension
  85565. */
  85566. /** @hidden */
  85567. const enum IKHRLightsPunctual_LightType {
  85568. DIRECTIONAL = "directional",
  85569. POINT = "point",
  85570. SPOT = "spot"
  85571. }
  85572. /** @hidden */
  85573. interface IKHRLightsPunctual_LightReference {
  85574. light: number;
  85575. }
  85576. /** @hidden */
  85577. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85578. type: IKHRLightsPunctual_LightType;
  85579. color?: number[];
  85580. intensity?: number;
  85581. range?: number;
  85582. spot?: {
  85583. innerConeAngle?: number;
  85584. outerConeAngle?: number;
  85585. };
  85586. }
  85587. /** @hidden */
  85588. interface IKHRLightsPunctual {
  85589. lights: IKHRLightsPunctual_Light[];
  85590. }
  85591. /**
  85592. * Interfaces from the KHR_materials_clearcoat extension
  85593. * !!! Experimental Extension Subject to Changes !!!
  85594. */
  85595. /** @hidden */
  85596. interface IKHRMaterialsClearcoat {
  85597. clearcoatFactor: number;
  85598. clearcoatTexture: ITextureInfo;
  85599. clearcoatRoughnessFactor: number;
  85600. clearcoatRoughnessTexture: ITextureInfo;
  85601. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85602. }
  85603. /**
  85604. * Interfaces from the KHR_materials_ior extension
  85605. * !!! Experimental Extension Subject to Changes !!!
  85606. */
  85607. /** @hidden */
  85608. interface IKHRMaterialsIor {
  85609. ior: number;
  85610. }
  85611. /**
  85612. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85613. */
  85614. /** @hidden */
  85615. interface IKHRMaterialsPbrSpecularGlossiness {
  85616. diffuseFactor: number[];
  85617. diffuseTexture: ITextureInfo;
  85618. specularFactor: number[];
  85619. glossinessFactor: number;
  85620. specularGlossinessTexture: ITextureInfo;
  85621. }
  85622. /**
  85623. * Interfaces from the KHR_materials_sheen extension
  85624. * !!! Experimental Extension Subject to Changes !!!
  85625. */
  85626. /** @hidden */
  85627. interface IKHRMaterialsSheen {
  85628. sheenColorFactor?: number[];
  85629. sheenTexture?: ITextureInfo;
  85630. sheenRoughnessFactor?: number;
  85631. }
  85632. /**
  85633. * Interfaces from the KHR_materials_specular extension
  85634. * !!! Experimental Extension Subject to Changes !!!
  85635. */
  85636. /** @hidden */
  85637. interface IKHRMaterialsSpecular {
  85638. specularFactor: number;
  85639. specularColorFactor: number[];
  85640. specularTexture: ITextureInfo;
  85641. }
  85642. /**
  85643. * Interfaces from the KHR_materials_transmission extension
  85644. * !!! Experimental Extension Subject to Changes !!!
  85645. */
  85646. /** @hidden */
  85647. interface IKHRMaterialsTransmission {
  85648. transmissionFactor?: number;
  85649. transmissionTexture?: ITextureInfo;
  85650. }
  85651. /**
  85652. * Interfaces from the KHR_materials_variants extension
  85653. * !!! Experimental Extension Subject to Changes !!!
  85654. */
  85655. /** @hidden */
  85656. interface IKHRMaterialVariants_Mapping extends IProperty {
  85657. mappings: Array<{
  85658. variants: number[];
  85659. material: number;
  85660. }>;
  85661. }
  85662. /** @hidden */
  85663. interface IKHRMaterialVariants_Variant extends IProperty {
  85664. name: string;
  85665. }
  85666. /** @hidden */
  85667. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85668. variants: Array<IKHRMaterialVariants_Variant>;
  85669. }
  85670. /**
  85671. * Interfaces from the KHR_texture_basisu extension
  85672. * !!! Experimental Extension Subject to Changes !!!
  85673. */
  85674. /** @hidden */
  85675. interface IKHRTextureBasisU {
  85676. source: number;
  85677. }
  85678. /**
  85679. * Interfaces from the EXT_texture_webp extension
  85680. */
  85681. /** @hidden */
  85682. interface IEXTTextureWebP {
  85683. source: number;
  85684. }
  85685. /**
  85686. * Interfaces from the KHR_texture_transform extension
  85687. */
  85688. /** @hidden */
  85689. interface IKHRTextureTransform {
  85690. offset?: number[];
  85691. rotation?: number;
  85692. scale?: number[];
  85693. texCoord?: number;
  85694. }
  85695. /**
  85696. * Interfaces from the KHR_xmp extension
  85697. * !!! Experimental Extension Subject to Changes !!!
  85698. */
  85699. /** @hidden */
  85700. interface IKHRXmp_Data {
  85701. [key: string]: unknown;
  85702. }
  85703. /** @hidden */
  85704. interface IKHRXmp_Gltf {
  85705. packets: IKHRXmp_Data[];
  85706. }
  85707. /** @hidden */
  85708. interface IKHRXmp_Node {
  85709. packet: number;
  85710. }
  85711. /**
  85712. * Interfaces from the MSFT_audio_emitter extension
  85713. */
  85714. /** @hidden */
  85715. interface IMSFTAudioEmitter_ClipReference {
  85716. clip: number;
  85717. weight?: number;
  85718. }
  85719. /** @hidden */
  85720. interface IMSFTAudioEmitter_EmittersReference {
  85721. emitters: number[];
  85722. }
  85723. /** @hidden */
  85724. const enum IMSFTAudioEmitter_DistanceModel {
  85725. linear = "linear",
  85726. inverse = "inverse",
  85727. exponential = "exponential",
  85728. }
  85729. /** @hidden */
  85730. interface IMSFTAudioEmitter_Emitter {
  85731. name?: string;
  85732. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85733. refDistance?: number;
  85734. maxDistance?: number;
  85735. rolloffFactor?: number;
  85736. innerAngle?: number;
  85737. outerAngle?: number;
  85738. loop?: boolean;
  85739. volume?: number;
  85740. clips: IMSFTAudioEmitter_ClipReference[];
  85741. }
  85742. /** @hidden */
  85743. const enum IMSFTAudioEmitter_AudioMimeType {
  85744. WAV = "audio/wav",
  85745. }
  85746. /** @hidden */
  85747. interface IMSFTAudioEmitter_Clip extends IProperty {
  85748. uri?: string;
  85749. bufferView?: number;
  85750. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85751. }
  85752. /** @hidden */
  85753. const enum IMSFTAudioEmitter_AnimationEventAction {
  85754. play = "play",
  85755. pause = "pause",
  85756. stop = "stop",
  85757. }
  85758. /** @hidden */
  85759. interface IMSFTAudioEmitter_AnimationEvent {
  85760. action: IMSFTAudioEmitter_AnimationEventAction;
  85761. emitter: number;
  85762. time: number;
  85763. startOffset?: number;
  85764. }
  85765. /**
  85766. * Interfaces from the MSFT_lod extension
  85767. */
  85768. /** @hidden */
  85769. interface IMSFTLOD {
  85770. ids: number[];
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /** @hidden */
  85775. export var cellPixelShader: {
  85776. name: string;
  85777. shader: string;
  85778. };
  85779. }
  85780. declare module BABYLON {
  85781. /** @hidden */
  85782. export var cellVertexShader: {
  85783. name: string;
  85784. shader: string;
  85785. };
  85786. }
  85787. declare module BABYLON {
  85788. export class CellMaterial extends BABYLON.PushMaterial {
  85789. private _diffuseTexture;
  85790. diffuseTexture: BABYLON.BaseTexture;
  85791. diffuseColor: BABYLON.Color3;
  85792. _computeHighLevel: boolean;
  85793. computeHighLevel: boolean;
  85794. private _disableLighting;
  85795. disableLighting: boolean;
  85796. private _maxSimultaneousLights;
  85797. maxSimultaneousLights: number;
  85798. constructor(name: string, scene: BABYLON.Scene);
  85799. needAlphaBlending(): boolean;
  85800. needAlphaTesting(): boolean;
  85801. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85802. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85803. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85804. getAnimatables(): BABYLON.IAnimatable[];
  85805. getActiveTextures(): BABYLON.BaseTexture[];
  85806. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85807. dispose(forceDisposeEffect?: boolean): void;
  85808. getClassName(): string;
  85809. clone(name: string): CellMaterial;
  85810. serialize(): any;
  85811. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85812. }
  85813. }
  85814. declare module BABYLON {
  85815. export class CustomShaderStructure {
  85816. FragmentStore: string;
  85817. VertexStore: string;
  85818. constructor();
  85819. }
  85820. export class ShaderSpecialParts {
  85821. constructor();
  85822. Fragment_Begin: string;
  85823. Fragment_Definitions: string;
  85824. Fragment_MainBegin: string;
  85825. Fragment_Custom_Diffuse: string;
  85826. Fragment_Before_Lights: string;
  85827. Fragment_Before_Fog: string;
  85828. Fragment_Custom_Alpha: string;
  85829. Fragment_Before_FragColor: string;
  85830. Vertex_Begin: string;
  85831. Vertex_Definitions: string;
  85832. Vertex_MainBegin: string;
  85833. Vertex_Before_PositionUpdated: string;
  85834. Vertex_Before_NormalUpdated: string;
  85835. Vertex_After_WorldPosComputed: string;
  85836. Vertex_MainEnd: string;
  85837. }
  85838. export class CustomMaterial extends BABYLON.StandardMaterial {
  85839. static ShaderIndexer: number;
  85840. CustomParts: ShaderSpecialParts;
  85841. _isCreatedShader: boolean;
  85842. _createdShaderName: string;
  85843. _customUniform: string[];
  85844. _newUniforms: string[];
  85845. _newUniformInstances: {
  85846. [name: string]: any;
  85847. };
  85848. _newSamplerInstances: {
  85849. [name: string]: BABYLON.Texture;
  85850. };
  85851. _customAttributes: string[];
  85852. FragmentShader: string;
  85853. VertexShader: string;
  85854. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85855. ReviewUniform(name: string, arr: string[]): string[];
  85856. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85857. constructor(name: string, scene: BABYLON.Scene);
  85858. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85859. AddAttribute(name: string): CustomMaterial;
  85860. Fragment_Begin(shaderPart: string): CustomMaterial;
  85861. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85862. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85863. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85864. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85865. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85866. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85867. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85868. Vertex_Begin(shaderPart: string): CustomMaterial;
  85869. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85870. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85871. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85872. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85873. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85874. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85875. }
  85876. }
  85877. declare module BABYLON {
  85878. export class ShaderAlebdoParts {
  85879. constructor();
  85880. Fragment_Begin: string;
  85881. Fragment_Definitions: string;
  85882. Fragment_MainBegin: string;
  85883. Fragment_Custom_Albedo: string;
  85884. Fragment_Before_Lights: string;
  85885. Fragment_Custom_MetallicRoughness: string;
  85886. Fragment_Custom_MicroSurface: string;
  85887. Fragment_Before_Fog: string;
  85888. Fragment_Custom_Alpha: string;
  85889. Fragment_Before_FragColor: string;
  85890. Vertex_Begin: string;
  85891. Vertex_Definitions: string;
  85892. Vertex_MainBegin: string;
  85893. Vertex_Before_PositionUpdated: string;
  85894. Vertex_Before_NormalUpdated: string;
  85895. Vertex_After_WorldPosComputed: string;
  85896. Vertex_MainEnd: string;
  85897. }
  85898. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85899. static ShaderIndexer: number;
  85900. CustomParts: ShaderAlebdoParts;
  85901. _isCreatedShader: boolean;
  85902. _createdShaderName: string;
  85903. _customUniform: string[];
  85904. _newUniforms: string[];
  85905. _newUniformInstances: {
  85906. [name: string]: any;
  85907. };
  85908. _newSamplerInstances: {
  85909. [name: string]: BABYLON.Texture;
  85910. };
  85911. _customAttributes: string[];
  85912. FragmentShader: string;
  85913. VertexShader: string;
  85914. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85915. ReviewUniform(name: string, arr: string[]): string[];
  85916. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85917. constructor(name: string, scene: BABYLON.Scene);
  85918. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85919. AddAttribute(name: string): PBRCustomMaterial;
  85920. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85921. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85922. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85923. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85924. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85925. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85926. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85927. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85928. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85929. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85930. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85931. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85932. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85933. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85934. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85935. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85936. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85937. }
  85938. }
  85939. declare module BABYLON {
  85940. /** @hidden */
  85941. export var firePixelShader: {
  85942. name: string;
  85943. shader: string;
  85944. };
  85945. }
  85946. declare module BABYLON {
  85947. /** @hidden */
  85948. export var fireVertexShader: {
  85949. name: string;
  85950. shader: string;
  85951. };
  85952. }
  85953. declare module BABYLON {
  85954. export class FireMaterial extends BABYLON.PushMaterial {
  85955. private _diffuseTexture;
  85956. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85957. private _distortionTexture;
  85958. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85959. private _opacityTexture;
  85960. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85961. diffuseColor: BABYLON.Color3;
  85962. speed: number;
  85963. private _scaledDiffuse;
  85964. private _lastTime;
  85965. constructor(name: string, scene: BABYLON.Scene);
  85966. needAlphaBlending(): boolean;
  85967. needAlphaTesting(): boolean;
  85968. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85969. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85970. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85971. getAnimatables(): BABYLON.IAnimatable[];
  85972. getActiveTextures(): BABYLON.BaseTexture[];
  85973. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85974. getClassName(): string;
  85975. dispose(forceDisposeEffect?: boolean): void;
  85976. clone(name: string): FireMaterial;
  85977. serialize(): any;
  85978. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85979. }
  85980. }
  85981. declare module BABYLON {
  85982. /** @hidden */
  85983. export var furPixelShader: {
  85984. name: string;
  85985. shader: string;
  85986. };
  85987. }
  85988. declare module BABYLON {
  85989. /** @hidden */
  85990. export var furVertexShader: {
  85991. name: string;
  85992. shader: string;
  85993. };
  85994. }
  85995. declare module BABYLON {
  85996. export class FurMaterial extends BABYLON.PushMaterial {
  85997. private _diffuseTexture;
  85998. diffuseTexture: BABYLON.BaseTexture;
  85999. private _heightTexture;
  86000. heightTexture: BABYLON.BaseTexture;
  86001. diffuseColor: BABYLON.Color3;
  86002. furLength: number;
  86003. furAngle: number;
  86004. furColor: BABYLON.Color3;
  86005. furOffset: number;
  86006. furSpacing: number;
  86007. furGravity: BABYLON.Vector3;
  86008. furSpeed: number;
  86009. furDensity: number;
  86010. furOcclusion: number;
  86011. furTexture: BABYLON.DynamicTexture;
  86012. private _disableLighting;
  86013. disableLighting: boolean;
  86014. private _maxSimultaneousLights;
  86015. maxSimultaneousLights: number;
  86016. highLevelFur: boolean;
  86017. _meshes: BABYLON.AbstractMesh[];
  86018. private _furTime;
  86019. constructor(name: string, scene: BABYLON.Scene);
  86020. get furTime(): number;
  86021. set furTime(furTime: number);
  86022. needAlphaBlending(): boolean;
  86023. needAlphaTesting(): boolean;
  86024. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86025. updateFur(): void;
  86026. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86027. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86028. getAnimatables(): BABYLON.IAnimatable[];
  86029. getActiveTextures(): BABYLON.BaseTexture[];
  86030. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86031. dispose(forceDisposeEffect?: boolean): void;
  86032. clone(name: string): FurMaterial;
  86033. serialize(): any;
  86034. getClassName(): string;
  86035. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86036. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86037. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86038. }
  86039. }
  86040. declare module BABYLON {
  86041. /** @hidden */
  86042. export var gradientPixelShader: {
  86043. name: string;
  86044. shader: string;
  86045. };
  86046. }
  86047. declare module BABYLON {
  86048. /** @hidden */
  86049. export var gradientVertexShader: {
  86050. name: string;
  86051. shader: string;
  86052. };
  86053. }
  86054. declare module BABYLON {
  86055. export class GradientMaterial extends BABYLON.PushMaterial {
  86056. private _maxSimultaneousLights;
  86057. maxSimultaneousLights: number;
  86058. topColor: BABYLON.Color3;
  86059. topColorAlpha: number;
  86060. bottomColor: BABYLON.Color3;
  86061. bottomColorAlpha: number;
  86062. offset: number;
  86063. scale: number;
  86064. smoothness: number;
  86065. private _disableLighting;
  86066. disableLighting: boolean;
  86067. constructor(name: string, scene: BABYLON.Scene);
  86068. needAlphaBlending(): boolean;
  86069. needAlphaTesting(): boolean;
  86070. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86071. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86072. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86073. getAnimatables(): BABYLON.IAnimatable[];
  86074. dispose(forceDisposeEffect?: boolean): void;
  86075. clone(name: string): GradientMaterial;
  86076. serialize(): any;
  86077. getClassName(): string;
  86078. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86079. }
  86080. }
  86081. declare module BABYLON {
  86082. /** @hidden */
  86083. export var gridPixelShader: {
  86084. name: string;
  86085. shader: string;
  86086. };
  86087. }
  86088. declare module BABYLON {
  86089. /** @hidden */
  86090. export var gridVertexShader: {
  86091. name: string;
  86092. shader: string;
  86093. };
  86094. }
  86095. declare module BABYLON {
  86096. /**
  86097. * The grid materials allows you to wrap any shape with a grid.
  86098. * Colors are customizable.
  86099. */
  86100. export class GridMaterial extends BABYLON.PushMaterial {
  86101. /**
  86102. * Main color of the grid (e.g. between lines)
  86103. */
  86104. mainColor: BABYLON.Color3;
  86105. /**
  86106. * Color of the grid lines.
  86107. */
  86108. lineColor: BABYLON.Color3;
  86109. /**
  86110. * The scale of the grid compared to unit.
  86111. */
  86112. gridRatio: number;
  86113. /**
  86114. * Allows setting an offset for the grid lines.
  86115. */
  86116. gridOffset: BABYLON.Vector3;
  86117. /**
  86118. * The frequency of thicker lines.
  86119. */
  86120. majorUnitFrequency: number;
  86121. /**
  86122. * The visibility of minor units in the grid.
  86123. */
  86124. minorUnitVisibility: number;
  86125. /**
  86126. * The grid opacity outside of the lines.
  86127. */
  86128. opacity: number;
  86129. /**
  86130. * Determine RBG output is premultiplied by alpha value.
  86131. */
  86132. preMultiplyAlpha: boolean;
  86133. private _opacityTexture;
  86134. opacityTexture: BABYLON.BaseTexture;
  86135. private _gridControl;
  86136. /**
  86137. * constructor
  86138. * @param name The name given to the material in order to identify it afterwards.
  86139. * @param scene The scene the material is used in.
  86140. */
  86141. constructor(name: string, scene: BABYLON.Scene);
  86142. /**
  86143. * Returns wehter or not the grid requires alpha blending.
  86144. */
  86145. needAlphaBlending(): boolean;
  86146. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86147. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86148. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86149. /**
  86150. * Dispose the material and its associated resources.
  86151. * @param forceDisposeEffect will also dispose the used effect when true
  86152. */
  86153. dispose(forceDisposeEffect?: boolean): void;
  86154. clone(name: string): GridMaterial;
  86155. serialize(): any;
  86156. getClassName(): string;
  86157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86158. }
  86159. }
  86160. declare module BABYLON {
  86161. /** @hidden */
  86162. export var lavaPixelShader: {
  86163. name: string;
  86164. shader: string;
  86165. };
  86166. }
  86167. declare module BABYLON {
  86168. /** @hidden */
  86169. export var lavaVertexShader: {
  86170. name: string;
  86171. shader: string;
  86172. };
  86173. }
  86174. declare module BABYLON {
  86175. export class LavaMaterial extends BABYLON.PushMaterial {
  86176. private _diffuseTexture;
  86177. diffuseTexture: BABYLON.BaseTexture;
  86178. noiseTexture: BABYLON.BaseTexture;
  86179. fogColor: BABYLON.Color3;
  86180. speed: number;
  86181. movingSpeed: number;
  86182. lowFrequencySpeed: number;
  86183. fogDensity: number;
  86184. private _lastTime;
  86185. diffuseColor: BABYLON.Color3;
  86186. private _disableLighting;
  86187. disableLighting: boolean;
  86188. private _unlit;
  86189. unlit: boolean;
  86190. private _maxSimultaneousLights;
  86191. maxSimultaneousLights: number;
  86192. private _scaledDiffuse;
  86193. constructor(name: string, scene: BABYLON.Scene);
  86194. needAlphaBlending(): boolean;
  86195. needAlphaTesting(): boolean;
  86196. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86197. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86198. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86199. getAnimatables(): BABYLON.IAnimatable[];
  86200. getActiveTextures(): BABYLON.BaseTexture[];
  86201. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86202. dispose(forceDisposeEffect?: boolean): void;
  86203. clone(name: string): LavaMaterial;
  86204. serialize(): any;
  86205. getClassName(): string;
  86206. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86207. }
  86208. }
  86209. declare module BABYLON {
  86210. /** @hidden */
  86211. export var mixPixelShader: {
  86212. name: string;
  86213. shader: string;
  86214. };
  86215. }
  86216. declare module BABYLON {
  86217. /** @hidden */
  86218. export var mixVertexShader: {
  86219. name: string;
  86220. shader: string;
  86221. };
  86222. }
  86223. declare module BABYLON {
  86224. export class MixMaterial extends BABYLON.PushMaterial {
  86225. /**
  86226. * Mix textures
  86227. */
  86228. private _mixTexture1;
  86229. mixTexture1: BABYLON.BaseTexture;
  86230. private _mixTexture2;
  86231. mixTexture2: BABYLON.BaseTexture;
  86232. /**
  86233. * Diffuse textures
  86234. */
  86235. private _diffuseTexture1;
  86236. diffuseTexture1: BABYLON.Texture;
  86237. private _diffuseTexture2;
  86238. diffuseTexture2: BABYLON.Texture;
  86239. private _diffuseTexture3;
  86240. diffuseTexture3: BABYLON.Texture;
  86241. private _diffuseTexture4;
  86242. diffuseTexture4: BABYLON.Texture;
  86243. private _diffuseTexture5;
  86244. diffuseTexture5: BABYLON.Texture;
  86245. private _diffuseTexture6;
  86246. diffuseTexture6: BABYLON.Texture;
  86247. private _diffuseTexture7;
  86248. diffuseTexture7: BABYLON.Texture;
  86249. private _diffuseTexture8;
  86250. diffuseTexture8: BABYLON.Texture;
  86251. /**
  86252. * Uniforms
  86253. */
  86254. diffuseColor: BABYLON.Color3;
  86255. specularColor: BABYLON.Color3;
  86256. specularPower: number;
  86257. private _disableLighting;
  86258. disableLighting: boolean;
  86259. private _maxSimultaneousLights;
  86260. maxSimultaneousLights: number;
  86261. constructor(name: string, scene: BABYLON.Scene);
  86262. needAlphaBlending(): boolean;
  86263. needAlphaTesting(): boolean;
  86264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86267. getAnimatables(): BABYLON.IAnimatable[];
  86268. getActiveTextures(): BABYLON.BaseTexture[];
  86269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86270. dispose(forceDisposeEffect?: boolean): void;
  86271. clone(name: string): MixMaterial;
  86272. serialize(): any;
  86273. getClassName(): string;
  86274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86275. }
  86276. }
  86277. declare module BABYLON {
  86278. /** @hidden */
  86279. export var normalPixelShader: {
  86280. name: string;
  86281. shader: string;
  86282. };
  86283. }
  86284. declare module BABYLON {
  86285. /** @hidden */
  86286. export var normalVertexShader: {
  86287. name: string;
  86288. shader: string;
  86289. };
  86290. }
  86291. declare module BABYLON {
  86292. export class NormalMaterial extends BABYLON.PushMaterial {
  86293. private _diffuseTexture;
  86294. diffuseTexture: BABYLON.BaseTexture;
  86295. diffuseColor: BABYLON.Color3;
  86296. private _disableLighting;
  86297. disableLighting: boolean;
  86298. private _maxSimultaneousLights;
  86299. maxSimultaneousLights: number;
  86300. constructor(name: string, scene: BABYLON.Scene);
  86301. needAlphaBlending(): boolean;
  86302. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86303. needAlphaTesting(): boolean;
  86304. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86305. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86306. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86307. getAnimatables(): BABYLON.IAnimatable[];
  86308. getActiveTextures(): BABYLON.BaseTexture[];
  86309. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86310. dispose(forceDisposeEffect?: boolean): void;
  86311. clone(name: string): NormalMaterial;
  86312. serialize(): any;
  86313. getClassName(): string;
  86314. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86315. }
  86316. }
  86317. declare module BABYLON {
  86318. /** @hidden */
  86319. export var shadowOnlyPixelShader: {
  86320. name: string;
  86321. shader: string;
  86322. };
  86323. }
  86324. declare module BABYLON {
  86325. /** @hidden */
  86326. export var shadowOnlyVertexShader: {
  86327. name: string;
  86328. shader: string;
  86329. };
  86330. }
  86331. declare module BABYLON {
  86332. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86333. private _activeLight;
  86334. private _needAlphaBlending;
  86335. constructor(name: string, scene: BABYLON.Scene);
  86336. shadowColor: BABYLON.Color3;
  86337. needAlphaBlending(): boolean;
  86338. needAlphaTesting(): boolean;
  86339. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86340. get activeLight(): BABYLON.IShadowLight;
  86341. set activeLight(light: BABYLON.IShadowLight);
  86342. private _getFirstShadowLightForMesh;
  86343. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86344. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86345. clone(name: string): ShadowOnlyMaterial;
  86346. serialize(): any;
  86347. getClassName(): string;
  86348. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86349. }
  86350. }
  86351. declare module BABYLON {
  86352. /** @hidden */
  86353. export var simplePixelShader: {
  86354. name: string;
  86355. shader: string;
  86356. };
  86357. }
  86358. declare module BABYLON {
  86359. /** @hidden */
  86360. export var simpleVertexShader: {
  86361. name: string;
  86362. shader: string;
  86363. };
  86364. }
  86365. declare module BABYLON {
  86366. export class SimpleMaterial extends BABYLON.PushMaterial {
  86367. private _diffuseTexture;
  86368. diffuseTexture: BABYLON.BaseTexture;
  86369. diffuseColor: BABYLON.Color3;
  86370. private _disableLighting;
  86371. disableLighting: boolean;
  86372. private _maxSimultaneousLights;
  86373. maxSimultaneousLights: number;
  86374. constructor(name: string, scene: BABYLON.Scene);
  86375. needAlphaBlending(): boolean;
  86376. needAlphaTesting(): boolean;
  86377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86378. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86380. getAnimatables(): BABYLON.IAnimatable[];
  86381. getActiveTextures(): BABYLON.BaseTexture[];
  86382. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86383. dispose(forceDisposeEffect?: boolean): void;
  86384. clone(name: string): SimpleMaterial;
  86385. serialize(): any;
  86386. getClassName(): string;
  86387. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86388. }
  86389. }
  86390. declare module BABYLON {
  86391. /** @hidden */
  86392. export var skyPixelShader: {
  86393. name: string;
  86394. shader: string;
  86395. };
  86396. }
  86397. declare module BABYLON {
  86398. /** @hidden */
  86399. export var skyVertexShader: {
  86400. name: string;
  86401. shader: string;
  86402. };
  86403. }
  86404. declare module BABYLON {
  86405. /**
  86406. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86407. * @see https://doc.babylonjs.com/extensions/sky
  86408. */
  86409. export class SkyMaterial extends BABYLON.PushMaterial {
  86410. /**
  86411. * Defines the overall luminance of sky in interval ]0, 1[.
  86412. */
  86413. luminance: number;
  86414. /**
  86415. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86416. */
  86417. turbidity: number;
  86418. /**
  86419. * Defines the sky appearance (light intensity).
  86420. */
  86421. rayleigh: number;
  86422. /**
  86423. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86424. */
  86425. mieCoefficient: number;
  86426. /**
  86427. * Defines the amount of haze particles following the Mie scattering theory.
  86428. */
  86429. mieDirectionalG: number;
  86430. /**
  86431. * Defines the distance of the sun according to the active scene camera.
  86432. */
  86433. distance: number;
  86434. /**
  86435. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86436. * "inclined".
  86437. */
  86438. inclination: number;
  86439. /**
  86440. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86441. * an object direction and a reference direction.
  86442. */
  86443. azimuth: number;
  86444. /**
  86445. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86446. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86447. */
  86448. sunPosition: BABYLON.Vector3;
  86449. /**
  86450. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86451. * .sunPosition property.
  86452. */
  86453. useSunPosition: boolean;
  86454. /**
  86455. * Defines an offset vector used to get a horizon offset.
  86456. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86457. */
  86458. cameraOffset: BABYLON.Vector3;
  86459. private _cameraPosition;
  86460. /**
  86461. * Instantiates a new sky material.
  86462. * This material allows to create dynamic and texture free
  86463. * effects for skyboxes by taking care of the atmosphere state.
  86464. * @see https://doc.babylonjs.com/extensions/sky
  86465. * @param name Define the name of the material in the scene
  86466. * @param scene Define the scene the material belong to
  86467. */
  86468. constructor(name: string, scene: BABYLON.Scene);
  86469. /**
  86470. * Specifies if the material will require alpha blending
  86471. * @returns a boolean specifying if alpha blending is needed
  86472. */
  86473. needAlphaBlending(): boolean;
  86474. /**
  86475. * Specifies if this material should be rendered in alpha test mode
  86476. * @returns false as the sky material doesn't need alpha testing.
  86477. */
  86478. needAlphaTesting(): boolean;
  86479. /**
  86480. * Get the texture used for alpha test purpose.
  86481. * @returns null as the sky material has no texture.
  86482. */
  86483. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86484. /**
  86485. * Get if the submesh is ready to be used and all its information available.
  86486. * Child classes can use it to update shaders
  86487. * @param mesh defines the mesh to check
  86488. * @param subMesh defines which submesh to check
  86489. * @param useInstances specifies that instances should be used
  86490. * @returns a boolean indicating that the submesh is ready or not
  86491. */
  86492. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86493. /**
  86494. * Binds the submesh to this material by preparing the effect and shader to draw
  86495. * @param world defines the world transformation matrix
  86496. * @param mesh defines the mesh containing the submesh
  86497. * @param subMesh defines the submesh to bind the material to
  86498. */
  86499. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86500. /**
  86501. * Get the list of animatables in the material.
  86502. * @returns the list of animatables object used in the material
  86503. */
  86504. getAnimatables(): BABYLON.IAnimatable[];
  86505. /**
  86506. * Disposes the material
  86507. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86508. */
  86509. dispose(forceDisposeEffect?: boolean): void;
  86510. /**
  86511. * Makes a duplicate of the material, and gives it a new name
  86512. * @param name defines the new name for the duplicated material
  86513. * @returns the cloned material
  86514. */
  86515. clone(name: string): SkyMaterial;
  86516. /**
  86517. * Serializes this material in a JSON representation
  86518. * @returns the serialized material object
  86519. */
  86520. serialize(): any;
  86521. /**
  86522. * Gets the current class name of the material e.g. "SkyMaterial"
  86523. * Mainly use in serialization.
  86524. * @returns the class name
  86525. */
  86526. getClassName(): string;
  86527. /**
  86528. * Creates a sky material from parsed material data
  86529. * @param source defines the JSON representation of the material
  86530. * @param scene defines the hosting scene
  86531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86532. * @returns a new sky material
  86533. */
  86534. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86535. }
  86536. }
  86537. declare module BABYLON {
  86538. /** @hidden */
  86539. export var terrainPixelShader: {
  86540. name: string;
  86541. shader: string;
  86542. };
  86543. }
  86544. declare module BABYLON {
  86545. /** @hidden */
  86546. export var terrainVertexShader: {
  86547. name: string;
  86548. shader: string;
  86549. };
  86550. }
  86551. declare module BABYLON {
  86552. export class TerrainMaterial extends BABYLON.PushMaterial {
  86553. private _mixTexture;
  86554. mixTexture: BABYLON.BaseTexture;
  86555. private _diffuseTexture1;
  86556. diffuseTexture1: BABYLON.Texture;
  86557. private _diffuseTexture2;
  86558. diffuseTexture2: BABYLON.Texture;
  86559. private _diffuseTexture3;
  86560. diffuseTexture3: BABYLON.Texture;
  86561. private _bumpTexture1;
  86562. bumpTexture1: BABYLON.Texture;
  86563. private _bumpTexture2;
  86564. bumpTexture2: BABYLON.Texture;
  86565. private _bumpTexture3;
  86566. bumpTexture3: BABYLON.Texture;
  86567. diffuseColor: BABYLON.Color3;
  86568. specularColor: BABYLON.Color3;
  86569. specularPower: number;
  86570. private _disableLighting;
  86571. disableLighting: boolean;
  86572. private _maxSimultaneousLights;
  86573. maxSimultaneousLights: number;
  86574. constructor(name: string, scene: BABYLON.Scene);
  86575. needAlphaBlending(): boolean;
  86576. needAlphaTesting(): boolean;
  86577. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86578. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86579. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86580. getAnimatables(): BABYLON.IAnimatable[];
  86581. getActiveTextures(): BABYLON.BaseTexture[];
  86582. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86583. dispose(forceDisposeEffect?: boolean): void;
  86584. clone(name: string): TerrainMaterial;
  86585. serialize(): any;
  86586. getClassName(): string;
  86587. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86588. }
  86589. }
  86590. declare module BABYLON {
  86591. /** @hidden */
  86592. export var triplanarPixelShader: {
  86593. name: string;
  86594. shader: string;
  86595. };
  86596. }
  86597. declare module BABYLON {
  86598. /** @hidden */
  86599. export var triplanarVertexShader: {
  86600. name: string;
  86601. shader: string;
  86602. };
  86603. }
  86604. declare module BABYLON {
  86605. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86606. mixTexture: BABYLON.BaseTexture;
  86607. private _diffuseTextureX;
  86608. diffuseTextureX: BABYLON.BaseTexture;
  86609. private _diffuseTextureY;
  86610. diffuseTextureY: BABYLON.BaseTexture;
  86611. private _diffuseTextureZ;
  86612. diffuseTextureZ: BABYLON.BaseTexture;
  86613. private _normalTextureX;
  86614. normalTextureX: BABYLON.BaseTexture;
  86615. private _normalTextureY;
  86616. normalTextureY: BABYLON.BaseTexture;
  86617. private _normalTextureZ;
  86618. normalTextureZ: BABYLON.BaseTexture;
  86619. tileSize: number;
  86620. diffuseColor: BABYLON.Color3;
  86621. specularColor: BABYLON.Color3;
  86622. specularPower: number;
  86623. private _disableLighting;
  86624. disableLighting: boolean;
  86625. private _maxSimultaneousLights;
  86626. maxSimultaneousLights: number;
  86627. constructor(name: string, scene: BABYLON.Scene);
  86628. needAlphaBlending(): boolean;
  86629. needAlphaTesting(): boolean;
  86630. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86631. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86632. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86633. getAnimatables(): BABYLON.IAnimatable[];
  86634. getActiveTextures(): BABYLON.BaseTexture[];
  86635. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86636. dispose(forceDisposeEffect?: boolean): void;
  86637. clone(name: string): TriPlanarMaterial;
  86638. serialize(): any;
  86639. getClassName(): string;
  86640. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86641. }
  86642. }
  86643. declare module BABYLON {
  86644. /** @hidden */
  86645. export var waterPixelShader: {
  86646. name: string;
  86647. shader: string;
  86648. };
  86649. }
  86650. declare module BABYLON {
  86651. /** @hidden */
  86652. export var waterVertexShader: {
  86653. name: string;
  86654. shader: string;
  86655. };
  86656. }
  86657. declare module BABYLON {
  86658. export class WaterMaterial extends BABYLON.PushMaterial {
  86659. renderTargetSize: BABYLON.Vector2;
  86660. private _bumpTexture;
  86661. bumpTexture: BABYLON.BaseTexture;
  86662. diffuseColor: BABYLON.Color3;
  86663. specularColor: BABYLON.Color3;
  86664. specularPower: number;
  86665. private _disableLighting;
  86666. disableLighting: boolean;
  86667. private _maxSimultaneousLights;
  86668. maxSimultaneousLights: number;
  86669. /**
  86670. * @param {number}: Represents the wind force
  86671. */
  86672. windForce: number;
  86673. /**
  86674. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86675. */
  86676. windDirection: BABYLON.Vector2;
  86677. /**
  86678. * @param {number}: Wave height, represents the height of the waves
  86679. */
  86680. waveHeight: number;
  86681. /**
  86682. * @param {number}: Bump height, represents the bump height related to the bump map
  86683. */
  86684. bumpHeight: number;
  86685. /**
  86686. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86687. */
  86688. private _bumpSuperimpose;
  86689. bumpSuperimpose: boolean;
  86690. /**
  86691. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86692. */
  86693. private _fresnelSeparate;
  86694. fresnelSeparate: boolean;
  86695. /**
  86696. * @param {boolean}: bump Waves modify the reflection.
  86697. */
  86698. private _bumpAffectsReflection;
  86699. bumpAffectsReflection: boolean;
  86700. /**
  86701. * @param {number}: The water color blended with the refraction (near)
  86702. */
  86703. waterColor: BABYLON.Color3;
  86704. /**
  86705. * @param {number}: The blend factor related to the water color
  86706. */
  86707. colorBlendFactor: number;
  86708. /**
  86709. * @param {number}: The water color blended with the reflection (far)
  86710. */
  86711. waterColor2: BABYLON.Color3;
  86712. /**
  86713. * @param {number}: The blend factor related to the water color (reflection, far)
  86714. */
  86715. colorBlendFactor2: number;
  86716. /**
  86717. * @param {number}: Represents the maximum length of a wave
  86718. */
  86719. waveLength: number;
  86720. /**
  86721. * @param {number}: Defines the waves speed
  86722. */
  86723. waveSpeed: number;
  86724. /**
  86725. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86726. * will avoid calculating useless pixels in the pixel shader of the water material.
  86727. */
  86728. disableClipPlane: boolean;
  86729. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86730. private _mesh;
  86731. private _refractionRTT;
  86732. private _reflectionRTT;
  86733. private _reflectionTransform;
  86734. private _lastTime;
  86735. private _lastDeltaTime;
  86736. private _useLogarithmicDepth;
  86737. private _waitingRenderList;
  86738. private _imageProcessingConfiguration;
  86739. private _imageProcessingObserver;
  86740. /**
  86741. * Gets a boolean indicating that current material needs to register RTT
  86742. */
  86743. get hasRenderTargetTextures(): boolean;
  86744. /**
  86745. * Constructor
  86746. */
  86747. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86748. get useLogarithmicDepth(): boolean;
  86749. set useLogarithmicDepth(value: boolean);
  86750. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86751. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86752. addToRenderList(node: any): void;
  86753. enableRenderTargets(enable: boolean): void;
  86754. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86755. get renderTargetsEnabled(): boolean;
  86756. needAlphaBlending(): boolean;
  86757. needAlphaTesting(): boolean;
  86758. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86759. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86760. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86761. private _createRenderTargets;
  86762. getAnimatables(): BABYLON.IAnimatable[];
  86763. getActiveTextures(): BABYLON.BaseTexture[];
  86764. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86765. dispose(forceDisposeEffect?: boolean): void;
  86766. clone(name: string): WaterMaterial;
  86767. serialize(): any;
  86768. getClassName(): string;
  86769. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86770. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86771. }
  86772. }
  86773. declare module BABYLON {
  86774. /** @hidden */
  86775. export var asciiartPixelShader: {
  86776. name: string;
  86777. shader: string;
  86778. };
  86779. }
  86780. declare module BABYLON {
  86781. /**
  86782. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86783. *
  86784. * It basically takes care rendering the font front the given font size to a texture.
  86785. * This is used later on in the postprocess.
  86786. */
  86787. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86788. private _font;
  86789. private _text;
  86790. private _charSize;
  86791. /**
  86792. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86793. */
  86794. get charSize(): number;
  86795. /**
  86796. * Create a new instance of the Ascii Art FontTexture class
  86797. * @param name the name of the texture
  86798. * @param font the font to use, use the W3C CSS notation
  86799. * @param text the caracter set to use in the rendering.
  86800. * @param scene the scene that owns the texture
  86801. */
  86802. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86803. /**
  86804. * Gets the max char width of a font.
  86805. * @param font the font to use, use the W3C CSS notation
  86806. * @return the max char width
  86807. */
  86808. private getFontWidth;
  86809. /**
  86810. * Gets the max char height of a font.
  86811. * @param font the font to use, use the W3C CSS notation
  86812. * @return the max char height
  86813. */
  86814. private getFontHeight;
  86815. /**
  86816. * Clones the current AsciiArtTexture.
  86817. * @return the clone of the texture.
  86818. */
  86819. clone(): AsciiArtFontTexture;
  86820. /**
  86821. * Parses a json object representing the texture and returns an instance of it.
  86822. * @param source the source JSON representation
  86823. * @param scene the scene to create the texture for
  86824. * @return the parsed texture
  86825. */
  86826. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86827. }
  86828. /**
  86829. * Option available in the Ascii Art Post Process.
  86830. */
  86831. export interface IAsciiArtPostProcessOptions {
  86832. /**
  86833. * The font to use following the w3c font definition.
  86834. */
  86835. font?: string;
  86836. /**
  86837. * The character set to use in the postprocess.
  86838. */
  86839. characterSet?: string;
  86840. /**
  86841. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86842. * This number is defined between 0 and 1;
  86843. */
  86844. mixToTile?: number;
  86845. /**
  86846. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86847. * This number is defined between 0 and 1;
  86848. */
  86849. mixToNormal?: number;
  86850. }
  86851. /**
  86852. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86853. *
  86854. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86855. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86856. */
  86857. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86858. /**
  86859. * The font texture used to render the char in the post process.
  86860. */
  86861. private _asciiArtFontTexture;
  86862. /**
  86863. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86864. * This number is defined between 0 and 1;
  86865. */
  86866. mixToTile: number;
  86867. /**
  86868. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86869. * This number is defined between 0 and 1;
  86870. */
  86871. mixToNormal: number;
  86872. /**
  86873. * Instantiates a new Ascii Art Post Process.
  86874. * @param name the name to give to the postprocess
  86875. * @camera the camera to apply the post process to.
  86876. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86877. */
  86878. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86879. }
  86880. }
  86881. declare module BABYLON {
  86882. /** @hidden */
  86883. export var digitalrainPixelShader: {
  86884. name: string;
  86885. shader: string;
  86886. };
  86887. }
  86888. declare module BABYLON {
  86889. /**
  86890. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86891. *
  86892. * It basically takes care rendering the font front the given font size to a texture.
  86893. * This is used later on in the postprocess.
  86894. */
  86895. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86896. private _font;
  86897. private _text;
  86898. private _charSize;
  86899. /**
  86900. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86901. */
  86902. get charSize(): number;
  86903. /**
  86904. * Create a new instance of the Digital Rain FontTexture class
  86905. * @param name the name of the texture
  86906. * @param font the font to use, use the W3C CSS notation
  86907. * @param text the caracter set to use in the rendering.
  86908. * @param scene the scene that owns the texture
  86909. */
  86910. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86911. /**
  86912. * Gets the max char width of a font.
  86913. * @param font the font to use, use the W3C CSS notation
  86914. * @return the max char width
  86915. */
  86916. private getFontWidth;
  86917. /**
  86918. * Gets the max char height of a font.
  86919. * @param font the font to use, use the W3C CSS notation
  86920. * @return the max char height
  86921. */
  86922. private getFontHeight;
  86923. /**
  86924. * Clones the current DigitalRainFontTexture.
  86925. * @return the clone of the texture.
  86926. */
  86927. clone(): DigitalRainFontTexture;
  86928. /**
  86929. * Parses a json object representing the texture and returns an instance of it.
  86930. * @param source the source JSON representation
  86931. * @param scene the scene to create the texture for
  86932. * @return the parsed texture
  86933. */
  86934. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86935. }
  86936. /**
  86937. * Option available in the Digital Rain Post Process.
  86938. */
  86939. export interface IDigitalRainPostProcessOptions {
  86940. /**
  86941. * The font to use following the w3c font definition.
  86942. */
  86943. font?: string;
  86944. /**
  86945. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86946. * This number is defined between 0 and 1;
  86947. */
  86948. mixToTile?: number;
  86949. /**
  86950. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86951. * This number is defined between 0 and 1;
  86952. */
  86953. mixToNormal?: number;
  86954. }
  86955. /**
  86956. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86957. *
  86958. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86959. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86960. */
  86961. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86962. /**
  86963. * The font texture used to render the char in the post process.
  86964. */
  86965. private _digitalRainFontTexture;
  86966. /**
  86967. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86968. * This number is defined between 0 and 1;
  86969. */
  86970. mixToTile: number;
  86971. /**
  86972. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86973. * This number is defined between 0 and 1;
  86974. */
  86975. mixToNormal: number;
  86976. /**
  86977. * Instantiates a new Digital Rain Post Process.
  86978. * @param name the name to give to the postprocess
  86979. * @camera the camera to apply the post process to.
  86980. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86981. */
  86982. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86983. }
  86984. }
  86985. declare module BABYLON {
  86986. /** @hidden */
  86987. export var brickProceduralTexturePixelShader: {
  86988. name: string;
  86989. shader: string;
  86990. };
  86991. }
  86992. declare module BABYLON {
  86993. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86994. private _numberOfBricksHeight;
  86995. private _numberOfBricksWidth;
  86996. private _jointColor;
  86997. private _brickColor;
  86998. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86999. updateShaderUniforms(): void;
  87000. get numberOfBricksHeight(): number;
  87001. set numberOfBricksHeight(value: number);
  87002. get numberOfBricksWidth(): number;
  87003. set numberOfBricksWidth(value: number);
  87004. get jointColor(): BABYLON.Color3;
  87005. set jointColor(value: BABYLON.Color3);
  87006. get brickColor(): BABYLON.Color3;
  87007. set brickColor(value: BABYLON.Color3);
  87008. /**
  87009. * Serializes this brick procedural texture
  87010. * @returns a serialized brick procedural texture object
  87011. */
  87012. serialize(): any;
  87013. /**
  87014. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87015. * @param parsedTexture defines parsed texture data
  87016. * @param scene defines the current scene
  87017. * @param rootUrl defines the root URL containing brick procedural texture information
  87018. * @returns a parsed Brick Procedural BABYLON.Texture
  87019. */
  87020. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87021. }
  87022. }
  87023. declare module BABYLON {
  87024. /** @hidden */
  87025. export var cloudProceduralTexturePixelShader: {
  87026. name: string;
  87027. shader: string;
  87028. };
  87029. }
  87030. declare module BABYLON {
  87031. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87032. private _skyColor;
  87033. private _cloudColor;
  87034. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87035. updateShaderUniforms(): void;
  87036. get skyColor(): BABYLON.Color4;
  87037. set skyColor(value: BABYLON.Color4);
  87038. get cloudColor(): BABYLON.Color4;
  87039. set cloudColor(value: BABYLON.Color4);
  87040. /**
  87041. * Serializes this cloud procedural texture
  87042. * @returns a serialized cloud procedural texture object
  87043. */
  87044. serialize(): any;
  87045. /**
  87046. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87047. * @param parsedTexture defines parsed texture data
  87048. * @param scene defines the current scene
  87049. * @param rootUrl defines the root URL containing cloud procedural texture information
  87050. * @returns a parsed Cloud Procedural BABYLON.Texture
  87051. */
  87052. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87053. }
  87054. }
  87055. declare module BABYLON {
  87056. /** @hidden */
  87057. export var fireProceduralTexturePixelShader: {
  87058. name: string;
  87059. shader: string;
  87060. };
  87061. }
  87062. declare module BABYLON {
  87063. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87064. private _time;
  87065. private _speed;
  87066. private _autoGenerateTime;
  87067. private _fireColors;
  87068. private _alphaThreshold;
  87069. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87070. updateShaderUniforms(): void;
  87071. render(useCameraPostProcess?: boolean): void;
  87072. static get PurpleFireColors(): BABYLON.Color3[];
  87073. static get GreenFireColors(): BABYLON.Color3[];
  87074. static get RedFireColors(): BABYLON.Color3[];
  87075. static get BlueFireColors(): BABYLON.Color3[];
  87076. get autoGenerateTime(): boolean;
  87077. set autoGenerateTime(value: boolean);
  87078. get fireColors(): BABYLON.Color3[];
  87079. set fireColors(value: BABYLON.Color3[]);
  87080. get time(): number;
  87081. set time(value: number);
  87082. get speed(): BABYLON.Vector2;
  87083. set speed(value: BABYLON.Vector2);
  87084. get alphaThreshold(): number;
  87085. set alphaThreshold(value: number);
  87086. /**
  87087. * Serializes this fire procedural texture
  87088. * @returns a serialized fire procedural texture object
  87089. */
  87090. serialize(): any;
  87091. /**
  87092. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87093. * @param parsedTexture defines parsed texture data
  87094. * @param scene defines the current scene
  87095. * @param rootUrl defines the root URL containing fire procedural texture information
  87096. * @returns a parsed Fire Procedural BABYLON.Texture
  87097. */
  87098. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87099. }
  87100. }
  87101. declare module BABYLON {
  87102. /** @hidden */
  87103. export var grassProceduralTexturePixelShader: {
  87104. name: string;
  87105. shader: string;
  87106. };
  87107. }
  87108. declare module BABYLON {
  87109. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87110. private _grassColors;
  87111. private _groundColor;
  87112. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87113. updateShaderUniforms(): void;
  87114. get grassColors(): BABYLON.Color3[];
  87115. set grassColors(value: BABYLON.Color3[]);
  87116. get groundColor(): BABYLON.Color3;
  87117. set groundColor(value: BABYLON.Color3);
  87118. /**
  87119. * Serializes this grass procedural texture
  87120. * @returns a serialized grass procedural texture object
  87121. */
  87122. serialize(): any;
  87123. /**
  87124. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87125. * @param parsedTexture defines parsed texture data
  87126. * @param scene defines the current scene
  87127. * @param rootUrl defines the root URL containing grass procedural texture information
  87128. * @returns a parsed Grass Procedural BABYLON.Texture
  87129. */
  87130. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87131. }
  87132. }
  87133. declare module BABYLON {
  87134. /** @hidden */
  87135. export var marbleProceduralTexturePixelShader: {
  87136. name: string;
  87137. shader: string;
  87138. };
  87139. }
  87140. declare module BABYLON {
  87141. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87142. private _numberOfTilesHeight;
  87143. private _numberOfTilesWidth;
  87144. private _amplitude;
  87145. private _jointColor;
  87146. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87147. updateShaderUniforms(): void;
  87148. get numberOfTilesHeight(): number;
  87149. set numberOfTilesHeight(value: number);
  87150. get amplitude(): number;
  87151. set amplitude(value: number);
  87152. get numberOfTilesWidth(): number;
  87153. set numberOfTilesWidth(value: number);
  87154. get jointColor(): BABYLON.Color3;
  87155. set jointColor(value: BABYLON.Color3);
  87156. /**
  87157. * Serializes this marble procedural texture
  87158. * @returns a serialized marble procedural texture object
  87159. */
  87160. serialize(): any;
  87161. /**
  87162. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87163. * @param parsedTexture defines parsed texture data
  87164. * @param scene defines the current scene
  87165. * @param rootUrl defines the root URL containing marble procedural texture information
  87166. * @returns a parsed Marble Procedural BABYLON.Texture
  87167. */
  87168. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87169. }
  87170. }
  87171. declare module BABYLON {
  87172. /** @hidden */
  87173. export var normalMapProceduralTexturePixelShader: {
  87174. name: string;
  87175. shader: string;
  87176. };
  87177. }
  87178. declare module BABYLON {
  87179. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87180. private _baseTexture;
  87181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87182. updateShaderUniforms(): void;
  87183. render(useCameraPostProcess?: boolean): void;
  87184. resize(size: any, generateMipMaps: any): void;
  87185. get baseTexture(): BABYLON.Texture;
  87186. set baseTexture(texture: BABYLON.Texture);
  87187. /**
  87188. * Serializes this normal map procedural texture
  87189. * @returns a serialized normal map procedural texture object
  87190. */
  87191. serialize(): any;
  87192. /**
  87193. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87194. * @param parsedTexture defines parsed texture data
  87195. * @param scene defines the current scene
  87196. * @param rootUrl defines the root URL containing normal map procedural texture information
  87197. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87198. */
  87199. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87200. }
  87201. }
  87202. declare module BABYLON {
  87203. /** @hidden */
  87204. export var perlinNoiseProceduralTexturePixelShader: {
  87205. name: string;
  87206. shader: string;
  87207. };
  87208. }
  87209. declare module BABYLON {
  87210. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87211. time: number;
  87212. timeScale: number;
  87213. translationSpeed: number;
  87214. private _currentTranslation;
  87215. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87216. updateShaderUniforms(): void;
  87217. render(useCameraPostProcess?: boolean): void;
  87218. resize(size: any, generateMipMaps: any): void;
  87219. /**
  87220. * Serializes this perlin noise procedural texture
  87221. * @returns a serialized perlin noise procedural texture object
  87222. */
  87223. serialize(): any;
  87224. /**
  87225. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87226. * @param parsedTexture defines parsed texture data
  87227. * @param scene defines the current scene
  87228. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87229. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87230. */
  87231. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. /** @hidden */
  87236. export var roadProceduralTexturePixelShader: {
  87237. name: string;
  87238. shader: string;
  87239. };
  87240. }
  87241. declare module BABYLON {
  87242. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87243. private _roadColor;
  87244. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87245. updateShaderUniforms(): void;
  87246. get roadColor(): BABYLON.Color3;
  87247. set roadColor(value: BABYLON.Color3);
  87248. /**
  87249. * Serializes this road procedural texture
  87250. * @returns a serialized road procedural texture object
  87251. */
  87252. serialize(): any;
  87253. /**
  87254. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87255. * @param parsedTexture defines parsed texture data
  87256. * @param scene defines the current scene
  87257. * @param rootUrl defines the root URL containing road procedural texture information
  87258. * @returns a parsed Road Procedural BABYLON.Texture
  87259. */
  87260. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87261. }
  87262. }
  87263. declare module BABYLON {
  87264. /** @hidden */
  87265. export var starfieldProceduralTexturePixelShader: {
  87266. name: string;
  87267. shader: string;
  87268. };
  87269. }
  87270. declare module BABYLON {
  87271. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87272. private _time;
  87273. private _alpha;
  87274. private _beta;
  87275. private _zoom;
  87276. private _formuparam;
  87277. private _stepsize;
  87278. private _tile;
  87279. private _brightness;
  87280. private _darkmatter;
  87281. private _distfading;
  87282. private _saturation;
  87283. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87284. updateShaderUniforms(): void;
  87285. get time(): number;
  87286. set time(value: number);
  87287. get alpha(): number;
  87288. set alpha(value: number);
  87289. get beta(): number;
  87290. set beta(value: number);
  87291. get formuparam(): number;
  87292. set formuparam(value: number);
  87293. get stepsize(): number;
  87294. set stepsize(value: number);
  87295. get zoom(): number;
  87296. set zoom(value: number);
  87297. get tile(): number;
  87298. set tile(value: number);
  87299. get brightness(): number;
  87300. set brightness(value: number);
  87301. get darkmatter(): number;
  87302. set darkmatter(value: number);
  87303. get distfading(): number;
  87304. set distfading(value: number);
  87305. get saturation(): number;
  87306. set saturation(value: number);
  87307. /**
  87308. * Serializes this starfield procedural texture
  87309. * @returns a serialized starfield procedural texture object
  87310. */
  87311. serialize(): any;
  87312. /**
  87313. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87314. * @param parsedTexture defines parsed texture data
  87315. * @param scene defines the current scene
  87316. * @param rootUrl defines the root URL containing startfield procedural texture information
  87317. * @returns a parsed Starfield Procedural BABYLON.Texture
  87318. */
  87319. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87320. }
  87321. }
  87322. declare module BABYLON {
  87323. /** @hidden */
  87324. export var woodProceduralTexturePixelShader: {
  87325. name: string;
  87326. shader: string;
  87327. };
  87328. }
  87329. declare module BABYLON {
  87330. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87331. private _ampScale;
  87332. private _woodColor;
  87333. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87334. updateShaderUniforms(): void;
  87335. get ampScale(): number;
  87336. set ampScale(value: number);
  87337. get woodColor(): BABYLON.Color3;
  87338. set woodColor(value: BABYLON.Color3);
  87339. /**
  87340. * Serializes this wood procedural texture
  87341. * @returns a serialized wood procedural texture object
  87342. */
  87343. serialize(): any;
  87344. /**
  87345. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87346. * @param parsedTexture defines parsed texture data
  87347. * @param scene defines the current scene
  87348. * @param rootUrl defines the root URL containing wood procedural texture information
  87349. * @returns a parsed Wood Procedural BABYLON.Texture
  87350. */
  87351. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87352. }
  87353. }